forked from mtusi2026/mtusi2026lab4
ЛР 4 — вложения S3 и reconciler
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
global
|
||||
log stdout format raw local0
|
||||
maxconn 2048
|
||||
hard-stop-after 8s
|
||||
|
||||
defaults
|
||||
log global
|
||||
mode http
|
||||
option httplog
|
||||
timeout connect 1s
|
||||
timeout client 60s
|
||||
timeout server 60s
|
||||
timeout http-request 5s
|
||||
retries 1
|
||||
option redispatch
|
||||
option httpchk GET /health/ready
|
||||
http-check expect status 200
|
||||
|
||||
resolvers docker
|
||||
nameserver embedded 127.0.0.11:53
|
||||
resolve_retries 3
|
||||
timeout resolve 1s
|
||||
timeout retry 1s
|
||||
hold valid 2s
|
||||
hold obsolete 2s
|
||||
|
||||
frontend public_api
|
||||
bind :8080
|
||||
default_backend messenger_api
|
||||
|
||||
backend messenger_api
|
||||
balance roundrobin
|
||||
server-template api 1-16 api:8080 check inter 1s fall 2 rise 2 resolvers docker init-addr libc,none
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [{
|
||||
"Effect": "Allow",
|
||||
"Action": ["s3:ListBucket"],
|
||||
"Resource": ["arn:aws:s3:::messenger-attachments"],
|
||||
"Condition": {"StringLike": {"s3:prefix": ["attachments/*"]}}
|
||||
}, {
|
||||
"Effect": "Allow",
|
||||
"Action": ["s3:GetObject", "s3:PutObject", "s3:DeleteObject"],
|
||||
"Resource": ["arn:aws:s3:::messenger-attachments/attachments/*"]
|
||||
}]
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
rc alias set local http://rustfs:9000 "$RUSTFS_ROOT_ACCESS_KEY" "$RUSTFS_ROOT_SECRET_KEY" >/dev/null
|
||||
attempt=0
|
||||
until rc ls local/ >/dev/null 2>&1; do
|
||||
attempt=$((attempt + 1))
|
||||
if [ "$attempt" -ge 60 ]; then echo 'RustFS did not become ready' >&2; exit 1; fi
|
||||
sleep 2
|
||||
done
|
||||
rc bucket create --ignore-existing "local/$S3_BUCKET" >/dev/null
|
||||
if ! rc admin user list local/ 2>/dev/null | grep -Fq "$S3_API_ACCESS_KEY"; then
|
||||
rc admin user add local/ "$S3_API_ACCESS_KEY" "$S3_API_SECRET_KEY" >/dev/null
|
||||
fi
|
||||
sed "s/messenger-attachments/$S3_BUCKET/g" /bootstrap/policy.json > /tmp/messenger-api-policy.json
|
||||
rc admin policy create local/ messenger-api /tmp/messenger-api-policy.json >/dev/null 2>&1 || true
|
||||
rc admin policy attach local/ messenger-api --user "$S3_API_ACCESS_KEY" >/dev/null
|
||||
printf '%s\n' 'Private bucket and restricted API user are ready.'
|
||||
Reference in New Issue
Block a user