Carry over the lab 5 solution
Bring the application, own tests, Dockerfile, toolchain, compose stack,
HAProxy, k6, RustFS and RabbitMQ configuration, migrations, hooks,
scenario scripts and the CI job from the lab 5 solution commit 64d5c67,
keep the lab 5 Makefile targets on top of the unchanged skeleton
targets, and append the lab 5 solution variables to the skeleton
.env.example. The package and the application follow the contract
version 1.6.0, and the image, the throwaway test containers and the
broker vhost description are tagged lab6 so they do not collide with a
lab 5 stand on the same host.
This is the starting point of the lab 6 cycle: lint, own tests and the
offline skeleton check pass before any lab 6 change.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
a0d3947710
commit
5ae3d77152
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [
|
||||
{
|
||||
"Sid": "MessengerApiObjects",
|
||||
"Effect": "Allow",
|
||||
"Action": [
|
||||
"s3:GetObject",
|
||||
"s3:PutObject",
|
||||
"s3:DeleteObject",
|
||||
"s3:AbortMultipartUpload",
|
||||
"s3:ListMultipartUploadParts"
|
||||
],
|
||||
"Resource": ["arn:aws:s3:::messenger-attachments/*"]
|
||||
},
|
||||
{
|
||||
"Sid": "MessengerApiBucket",
|
||||
"Effect": "Allow",
|
||||
"Action": ["s3:ListBucket", "s3:ListBucketMultipartUploads", "s3:GetBucketLocation"],
|
||||
"Resource": ["arn:aws:s3:::messenger-attachments"]
|
||||
}
|
||||
]
|
||||
}
|
||||
Executable
+12
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
secret() { tr -d '\r\n' < "/run/secrets/$1"; }
|
||||
endpoint="${S3_ENDPOINT:-http://s3:9000}"
|
||||
RC_HOST_root="${endpoint%%://*}://$(secret s3_root_user):$(secret s3_root_password)@${endpoint#*://}"
|
||||
RC_HOST_api="${endpoint%%://*}://$(secret s3_access_key_id):$(secret s3_secret_access_key)@${endpoint#*://}"
|
||||
export RC_HOST_root RC_HOST_api
|
||||
rc alias set anon "$endpoint" --anonymous >/dev/null
|
||||
case "${1:-}" in
|
||||
sh|wget) exec "$@" ;;
|
||||
esac
|
||||
exec rc "$@"
|
||||
Executable
+26
@@ -0,0 +1,26 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
secret() { tr -d '\r\n' < "/run/secrets/$1"; }
|
||||
bucket="${S3_BUCKET:-messenger-attachments}"
|
||||
endpoint="${S3_ENDPOINT:-http://s3:9000}"
|
||||
policy="${S3_API_POLICY:-messenger-api}"
|
||||
RC_HOST_root="${endpoint%%://*}://$(secret s3_root_user):$(secret s3_root_password)@${endpoint#*://}"
|
||||
export RC_HOST_root
|
||||
api_key=$(secret s3_access_key_id)
|
||||
rc ready root --timeout 10 >/dev/null
|
||||
rc bucket create --ignore-existing "root/$bucket" >/dev/null
|
||||
rc bucket anonymous set private "root/$bucket" >/dev/null
|
||||
sed "s/messenger-attachments/$bucket/g" /s3/api-policy.json > /tmp/api-policy.json
|
||||
rc admin policy create root "$policy" /tmp/api-policy.json >/dev/null
|
||||
rc admin user add root "$api_key" "$(secret s3_secret_access_key)" >/dev/null
|
||||
rc admin policy attach root "$policy" --user "$api_key" >/dev/null
|
||||
worker_key=$(secret s3_worker_access_key_id)
|
||||
sed "s/messenger-attachments/$bucket/g" /s3/worker-policy.json > /tmp/worker-policy.json
|
||||
rc admin policy create root messenger-worker /tmp/worker-policy.json >/dev/null
|
||||
rc admin user add root "$worker_key" "$(secret s3_worker_secret_access_key)" >/dev/null
|
||||
rc admin policy attach root messenger-worker --user "$worker_key" >/dev/null
|
||||
rc bucket lifecycle rule import "root/$bucket" /s3/lifecycle.json >/dev/null
|
||||
rc bucket anonymous get "root/$bucket" --json | grep -q '"permission": *"private"'
|
||||
rc admin user info root "$api_key" --json | grep -q "\"$policy\""
|
||||
rc admin user info root "$worker_key" --json | grep -q '"messenger-worker"'
|
||||
echo "s3-init: bucket=$bucket anonymous=private policy=$policy worker=messenger-worker lifecycle=abort-incomplete-uploads"
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"rules": [
|
||||
{
|
||||
"id": "abort-incomplete-uploads",
|
||||
"status": "Enabled",
|
||||
"prefix": "",
|
||||
"abortIncompleteMultipartUploadDays": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [
|
||||
{
|
||||
"Sid": "MessengerWorkerRead",
|
||||
"Effect": "Allow",
|
||||
"Action": ["s3:GetObject"],
|
||||
"Resource": [
|
||||
"arn:aws:s3:::messenger-attachments/staging/*",
|
||||
"arn:aws:s3:::messenger-attachments/originals/*",
|
||||
"arn:aws:s3:::messenger-attachments/variants/*"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Sid": "MessengerWorkerWrite",
|
||||
"Effect": "Allow",
|
||||
"Action": ["s3:PutObject", "s3:AbortMultipartUpload", "s3:ListMultipartUploadParts"],
|
||||
"Resource": [
|
||||
"arn:aws:s3:::messenger-attachments/originals/*",
|
||||
"arn:aws:s3:::messenger-attachments/variants/*"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user