forked from mtusi2026/mtusi2026lab4
Implement lab4 private S3 attachments, safe reconciliation and defense guide
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
global
|
||||
maxconn 512
|
||||
log stdout format raw local0
|
||||
defaults
|
||||
log global
|
||||
mode http
|
||||
timeout connect 500ms
|
||||
timeout client 35s
|
||||
timeout server 35s
|
||||
timeout check 800ms
|
||||
retries 0
|
||||
resolvers docker
|
||||
nameserver dns 127.0.0.11:53
|
||||
resolve_retries 2
|
||||
timeout resolve 1s
|
||||
timeout retry 1s
|
||||
hold valid 1s
|
||||
hold obsolete 1s
|
||||
frontend public
|
||||
bind :8080
|
||||
default_backend replicas
|
||||
backend replicas
|
||||
balance roundrobin
|
||||
option httpchk GET /health/ready
|
||||
http-check expect status 200
|
||||
default-server inter 1s fall 2 rise 1
|
||||
server-template api 4 api:8080 check resolvers docker init-addr libc,none resolve-prefer ipv4
|
||||
@@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
trap 'exit 0' TERM INT
|
||||
while :; do
|
||||
# A dependency outage fails this pass without permitting destructive repair.
|
||||
messenger reconcile --apply || printf '%s\n' 'Reconcile pass failed; retry next minute' >&2
|
||||
sleep 60 &
|
||||
wait $! || true
|
||||
done
|
||||
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
# Do not enable shell tracing: mc arguments contain local credentials.
|
||||
mc alias set local http://s3:9000 "$(cat /run/secrets/s3_root_user)" "$(cat /run/secrets/s3_root_password)" >/dev/null
|
||||
mc mb --ignore-existing local/messenger-attachments >/dev/null
|
||||
mc anonymous set none local/messenger-attachments >/dev/null
|
||||
mc admin policy create local messenger-app /config/s3-policy.json >/dev/null
|
||||
mc admin user add local "$(cat /run/secrets/s3_access_key_id)" "$(cat /run/secrets/s3_secret_access_key)" >/dev/null
|
||||
mc admin policy attach local messenger-app --user "$(cat /run/secrets/s3_access_key_id)" >/dev/null
|
||||
printf '%s\n' 'Private bucket and restricted application user ready'
|
||||
@@ -0,0 +1 @@
|
||||
{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":["s3:ListBucket","s3:GetBucketLocation"],"Resource":["arn:aws:s3:::messenger-attachments"]},{"Effect":"Allow","Action":["s3:GetObject","s3:PutObject","s3:DeleteObject"],"Resource":["arn:aws:s3:::messenger-attachments/originals/*"]}]}
|
||||
Reference in New Issue
Block a user