Complete lab 7 security infrastructure

This commit is contained in:
Yuliiiaaaa
2026-11-30 21:23:07 +03:00
parent 20afc2c790
commit c00d245263
55 changed files with 3515 additions and 28 deletions
+22
View File
@@ -0,0 +1,22 @@
#!/bin/sh
set -eu
set +x
CA=/root/.mc/certs/CAs/service-ca.crt
[ "$S3_BUCKET" = "messenger-attachments" ] || { echo "S3_BUCKET must remain messenger-attachments because IAM policies are scoped to that bucket" >&2; exit 2; }
ready=0
for attempt in $(seq 1 30); do
if mc alias set local "https://minio:9000" "$MINIO_ROOT_USER" "$MINIO_ROOT_PASSWORD" --api S3v4 >/dev/null 2>&1; then
ready=1
break
fi
sleep 2
done
[ "$ready" -eq 1 ] || { echo "S3 service did not become ready" >&2; exit 1; }
mc mb --ignore-existing "local/${S3_BUCKET}"
mc admin policy create local messenger-api /policies/api-policy.json >/dev/null 2>&1 || true
mc admin policy create local messenger-worker /policies/worker-policy.json >/dev/null 2>&1 || true
mc admin user add local "$S3_ACCESS_KEY" "$S3_SECRET_KEY" || true
mc admin user add local "$S3_WORKER_ACCESS_KEY" "$S3_WORKER_SECRET_KEY" || true
mc admin policy attach local messenger-api --user "$S3_ACCESS_KEY"
mc admin policy attach local messenger-worker --user "$S3_WORKER_ACCESS_KEY"
echo "S3 bucket and scoped API/worker users are ready. Secret values were not printed."