Created
November 9, 2021 13:21
-
-
Save egeneralov/f203476e2ad8c8da927bfc37f391fe37 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
BUCKET_NAME=test | |
mc alias set minio-dev-domain-com https://minio-dev.domain.com/ d37f64f326f191e426c8c9f255e32dee 79884709becc128c3acaac2fc50f2e00 | |
mc alias set minio-prod-domain-com https://minio-prod.domain.com/ d37f64f326f191e426c8c9f255e32dee 79884709becc128c3acaac2fc50f2e00 | |
mkdir -p minio-policy/ | |
for ENV in dev prod; do | |
mc admin user add minio-${ENV}-domain-com ${BUCKET_NAME}-owner 8e858b7c3d2f73eac072c34eca029004 | |
mc admin user add minio-${ENV}-domain-com ${BUCKET_NAME}-ro 44258076704277c7b82f721ce362b7c2 | |
mc mb minio-${ENV}-domain-com/${BUCKET_NAME} | |
mc policy set none minio-${ENV}-domain-com/${BUCKET_NAME} | |
cat << EOF > minio-policy/${BUCKET_NAME}-owner-policy.json | |
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Action": [ | |
"s3:PutBucketPolicy", | |
"s3:GetBucketPolicy", | |
"s3:DeleteBucketPolicy", | |
"s3:ListAllMyBuckets", | |
"s3:ListBucket" | |
], | |
"Effect": "Allow", | |
"Resource": [ | |
"arn:aws:s3:::${BUCKET_NAME}" | |
], | |
"Sid": "" | |
}, | |
{ | |
"Action": [ | |
"s3:AbortMultipartUpload", | |
"s3:DeleteObject", | |
"s3:GetObject", | |
"s3:ListMultipartUploadParts", | |
"s3:PutObject" | |
], | |
"Effect": "Allow", | |
"Resource": [ | |
"arn:aws:s3:::${BUCKET_NAME}/*" | |
], | |
"Sid": "" | |
} | |
] | |
} | |
EOF | |
cat << EOF > minio-policy/${BUCKET_NAME}-ro-policy.json | |
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Action": [ | |
"s3:ListAllMyBuckets", | |
"s3:ListBucket" | |
], | |
"Effect": "Allow", | |
"Resource": [ | |
"arn:aws:s3:::${BUCKET_NAME}" | |
], | |
"Sid": "" | |
}, | |
{ | |
"Action": [ | |
"s3:GetObject", | |
"s3:ListMultipartUploadParts" | |
], | |
"Effect": "Allow", | |
"Resource": [ | |
"arn:aws:s3:::${BUCKET_NAME}/*" | |
], | |
"Sid": "" | |
} | |
] | |
} | |
EOF | |
mc admin policy add minio-${ENV}-domain-com ${BUCKET_NAME}-owner-policy minio-policy/${BUCKET_NAME}-owner-policy.json | |
mc admin policy set minio-${ENV}-domain-com ${BUCKET_NAME}-owner-policy user=${BUCKET_NAME}-owner | |
mc admin policy add minio-${ENV}-domain-com ${BUCKET_NAME}-ro-policy minio-policy/${BUCKET_NAME}-ro-policy.json | |
mc admin policy set minio-${ENV}-domain-com ${BUCKET_NAME}-ro-policy user=${BUCKET_NAME}-ro | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment