Created
April 9, 2025 22:18
-
-
Save dux/ff5662b376f06f09a712997b3f1c312e to your computer and use it in GitHub Desktop.
Revisions
-
dux created this gist
Apr 9, 2025 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,49 @@ #!/bin/bash BUCKET_NAME="some-bucket-1" REGION="eu-central-1" if [ "$1" = "rm" ]; then echo "Removing bucket: $BUCKET_NAME" aws s3 rm s3://$BUCKET_NAME --recursive aws s3 rb s3://$BUCKET_NAME --force echo "Bucket $BUCKET_NAME has been removed" else aws s3 mb s3://$BUCKET_NAME --region $REGION aws s3 sync ./root s3://$BUCKET_NAME aws s3api put-public-access-block \ --bucket $BUCKET_NAME \ --public-access-block-configuration "BlockPublicAcls=false,IgnorePublicAcls=false,BlockPublicPolicy=false,RestrictPublicBuckets=false" cat <<EOF > policy.json { "Version": "2012-10-17", "Statement": [ { "Sid": "PublicReadGetObject", "Effect": "Allow", "Principal": "*", "Action": "s3:GetObject", "Resource": "arn:aws:s3:::$BUCKET_NAME/*" } ] } EOF aws s3api put-bucket-policy --bucket $BUCKET_NAME --policy file://policy.json rm policy.json aws s3 website s3://$BUCKET_NAME/ --index-document index.html echo echo "Access your website at:" echo "https://$BUCKET_NAME.s3.$REGION.amazonaws.com/index.html" echo "or" echo "http://$BUCKET_NAME.s3-website.$REGION.amazonaws.com/" fi