Skip to content

Instantly share code, notes, and snippets.

@AlexMikhalev
Created September 6, 2024 11:33
Show Gist options
  • Save AlexMikhalev/43309ac4a8934a31db4fa4e2240bd25b to your computer and use it in GitHub Desktop.
Save AlexMikhalev/43309ac4a8934a31db4fa4e2240bd25b to your computer and use it in GitHub Desktop.
Create AWS s3 bucket and make it publick
#!/bin/bash
bucket_name="my-unique-name"
aws s3api create-bucket --bucket "${bucket_name}" > /dev/null # 1
aws s3api put-public-access-block --bucket "${bucket_name}" --public-access-block-configuration "BlockPublicPolicy=false" # 2
aws s3api put-bucket-policy --bucket "${bucket_name}" --policy '{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": [
"s3:GetObject"
],
"Resource": [
"arn:aws:s3:::'"${bucket_name}"'/*"
]
}
]
}' # 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment