Created
March 7, 2024 12:31
-
-
Save leandroribeiro/267a80cf24c08eb76a328ab42a838fea to your computer and use it in GitHub Desktop.
Create S3 Bucket with AWS CLI
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
# by parameter | |
# bucketName=$1 | |
# fixed value | |
bucketName=cw.sa-east-1.syn-results | |
# Create the bucket | |
aws s3api create-bucket --bucket ${bucketName} --region your-region | |
# Enable server-side encryption | |
aws s3api put-bucket-encryption --bucket ${bucketName} --server-side-encryption-configuration '{"Rules": [{"ApplyServerSideEncryptionByDefault": {"SSEAlgorithm": "AES256"}}]}' | |
# Add lifecycle configuration | |
aws s3api put-bucket-lifecycle-configuration --bucket ${bucketName} --lifecycle-configuration '{"Rules": [{"Status": "Enabled", "Expiration": {"Days": 180}}]}' | |
# Set public access block configuration | |
aws s3api put-public-access-block --bucket ${bucketName} --public-access-block-configuration '{"BlockPublicAcls": true, "IgnorePublicAcls": true, "BlockPublicPolicy": true, "RestrictPublicBuckets": true}' | |
# Add tags | |
aws s3api put-bucket-tagging --bucket ${bucketName} --tagging 'TagSet=[{"Key": "ALGUMA_CHAVE", "Value": "ALGUM_VALOR"}]' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment