S3 and Cloudfront
29 January, 2021
BackYou can serve a website hosted in S3 from Cloudfront for your content to reach a speedy fast global audience.
- Spin up an S3 bucket and host 3 files in the following order.
/index.html
/error/error.html
/blocked/blocked.html
- Go to the Permissions tab and scroll down to bucket policy. Copy and paste this but replace the
your-s3-bucket-name
with your own.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:ListBucket",
"Resource": "arn:aws:s3:::your-s3-bucket-name"
},
{
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": [
"s3:GetObject",
"s3:PutObject"
],
"Resource": "arn:aws:s3:::your-s3-bucket-name/*"
}
]
}
- Once it's created, you can access your website with a link that looks something like this
dz4255swmz0m4.cloudfront.net
. - Explore the rest of the settings by customizing your own error page and geo-restricted error page by using error.html and blocked.html.
Back