Publish website on AWS S3
While following seemingly simple procedure to turn AWS S3 bucket into a hosting service for your static website has some caveats I wish I knew beforehand. Maybe it's just me, but I couldn't access my website, all I got was 403 Access denied error all the time despite of all the efforts playing with public access options and bucket ACLs. Finally I made it work however certain steps need to be followed, here are they
- Create a bucket for website
- Enable Public Access on the bucket
- Create and apply bucket policy likewise:
{
"Id": "MyPolicy",
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadForGetBucketObjects",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::REPLACE_ME_BUCKET_NAME/*"
}
]
}
All these steps could be done from aws console or with help of aws-cli, commands below
aws s3 mb s3://REPLACE_ME_BUCKET_NAME
aws s3 website s3://REPLACE_ME_BUCKET_NAME --index-document index.html
aws s3api put-bucket-policy --bucket REPLACE_ME_BUCKET_NAME --policy file://website-bucket-policy.json
Comments
Post a Comment