Showing posts with label aws. Show all posts
Showing posts with label aws. Show all posts

Wednesday, March 3, 2021

403 Forbidden static web hosting on AWS S3

I encounterd an error while making the bucket for static webhosting on AWS S3. Made the below update in the policy and it worked fine. Done on the aws console.
Thanks to stack overflow ;)
{
  "Version":"2012-10-17",
  "Statement":[{
    "Sid":"PublicReadGetObject",
    "Effect":"Allow",
    "Principal": "*",
    "Action":["s3:GetObject"],
    "Resource":["arn:aws:s3:::example.com/*"]
  }]
}

Substitute the bucket name example.com with your bucket name
 

 Recommended Reading

S3 CreateBucket Error: unspecified location constraint is incompatible for the region specific endpoint

If you ever encounterd below error while creating bucket?
 

An error occurred (IllegalLocationConstraintException) when calling the CreateBucket operation: The unspecified location constraint is incompatible for the region specific endpoint this request was sent to.

 

I got this error when trying to run this command in the AWS CLI and the region specifiied is us-east-2

 

aws s3api create-bucket --bucket yourbucketname --region us-east-2
 
Solution:
 
You need to specify the location constaint for every region except us-east-1. so I have tried the below command and it worked. Here I specified the location constraint.
 
aws s3api create-bucket --bucket yourbucketname --region us-east-2 --create-bucket-configuration LocationConstraint=us-east-2
 
This worked!