Last active
October 12, 2020 04:50
-
-
Save jtwray/27ce3cfaeeae3ec4b51c44be29da9bed to your computer and use it in GitHub Desktop.
json string to setup an AWS bucket for serverless static site deployment
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
- use aws cloud9 very similar to codesandbox | |
- git clone you repo into cloud9 | |
- create a new s3 bucket in the provided terminal ( the aws cli ) | |
all lowercase dashes and periods only cant start or end with a number | |
aws s3 mb s3://REPLACE_ME_BUCKET_NAME | |
- run 2nd command to enable the bucket to be used for state website hosting | |
config s3 bucket to serve a root file index.html | |
aws s3 website s3://REPLACE_ME_BUCKET_NAME --index-document index.html | |
- update bucket policy fully private by default | |
update the principal to allow all or be publically accessible by all internet traffic with '*' | |
replatce the resourece string with the name of your newly created bucket | |
the part after the three ::: | |
the /* is required to allow any subdomains to be accessible passed the root of your site | |
{ | |
"Id": "MyPolicy", | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Sid": "PublicReadForGetBucketObjects", | |
"Effect": "Allow", | |
"Principal": "*", | |
"Action": "s3:GetObject", | |
"Resource": "arn:aws:s3:::alexas-adoptables-bucket/*" | |
} | |
] | |
} | |
- run prompt to add new bycket policy for the website | |
be sure to use the correct filepath to your website-bucket-policy.json file you created in the cloud9 instance | |
aws s3api put-bucket-policy --bucket REPLACE_ME_BUCKET_NAME --policy file://~/environment/aws-modern-application-workshop/module-1/aws-cli/website-bucket-policy.json | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
for the full tutorial follow this link and complete steps 1-9 in an hour or so