- Navigate to S3 bucket home page
- Click "Create Bucket" link on top
- Input the bucket name and untick the "Block all public access" checkbox, and click "Create Bucket" button
- The new bucket will be visible in S3 bucket listing. Click on the bucket name to explore it
- Inside the bucket view click on the Properties tab
- Then click on the Static website hosting option
- Select radio button for "Use this bucket to host a website"
- Enter Index document as index.html and Error document as 404/index.html and click Save
- Now open Permissions tab
- Edit the Block Public Access setting
- Untick Block all public access checkbox and click Save
- Now navigate to Bucket Policy tab and copy paste the below snippet over there, and replace the bucket name with your bucket name
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::your-bucket-name/*"
}
]
}
- Click Save
Serving resources through S3 bucket directly is not recommended. You should ideally serve all assets through a CDN.
See the CDN setup guide to setup the CloudFront CDN on AWS.