feat: complete lab 7 for grade 4

This commit is contained in:
sashadugina06
2026-12-04 13:55:32 +03:00
parent 20afc2c790
commit 11390b65fd
91 changed files with 10163 additions and 50 deletions
+39
View File
@@ -0,0 +1,39 @@
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:PutObject"
],
"Resource": [
"arn:aws:s3:::messenger-attachments/staging/*"
]
},
{
"Effect": "Allow",
"Action": [
"s3:GetObject"
],
"Resource": [
"arn:aws:s3:::messenger-attachments/results/*"
]
},
{
"Effect": "Allow",
"Action": [
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::messenger-attachments"
],
"Condition": {
"StringEquals": {
"s3:prefix": [
"originals/"
]
}
}
}
]
}
+30
View File
@@ -0,0 +1,30 @@
#!/bin/sh
set -eu
export MC_CONFIG_DIR=/tmp/mc
mkdir -p "$MC_CONFIG_DIR/certs/CAs"
cp /run/trust/ca.crt "$MC_CONFIG_DIR/certs/CAs/lab.crt"
if ! mc alias set local https://s3:9000 labroot "$(cat /run/identity/admin)" >/dev/null 2>&1; then
echo 'MinIO administrative connection failed' >&2
exit 1
fi
# New buckets are private by default. Keep the existing bucket policy on replay.
mc mb --ignore-existing local/messenger-attachments >/dev/null
users=$(mc --no-color admin user list local)
policies=$(mc --no-color admin policy list local)
for role in api worker recovery; do
name="lab-$role"
if ! printf '%s\n' "$policies" | grep -Fxq "$name"; then
mc admin policy create local "$name" "/lab/$role.json" >/dev/null
fi
user=$(printf '%s\n' "$users" | awk -v name="$name" '$2 == name')
if [ -z "$user" ]; then
if ! mc admin user add local "$name" "$(cat "/run/identity/$role")" >/dev/null 2>&1; then
printf 'Could not create MinIO user %s\n' "$name" >&2
exit 1
fi
elif [ -n "$(printf '%s\n' "$user" | awk '{print $3}')" ]; then
continue
fi
mc admin policy attach local "$name" --user "$name" >/dev/null
done
+30
View File
@@ -0,0 +1,30 @@
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:DeleteObject"
],
"Resource": [
"arn:aws:s3:::messenger-attachments/staging/*"
]
},
{
"Effect": "Allow",
"Action": [
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::messenger-attachments"
],
"Condition": {
"StringEquals": {
"s3:prefix": [
"staging/"
]
}
}
}
]
}
+25
View File
@@ -0,0 +1,25 @@
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:GetObject"
],
"Resource": [
"arn:aws:s3:::messenger-attachments/staging/*",
"arn:aws:s3:::messenger-attachments/originals/*",
"arn:aws:s3:::messenger-attachments/results/*"
]
},
{
"Effect": "Allow",
"Action": [
"s3:PutObject"
],
"Resource": [
"arn:aws:s3:::messenger-attachments/results/*"
]
}
]
}