Sometimes you need to create a quick landing page for a site ready to go live or a maintenance page as a fall over if your site crashes at the DNS level using Route 53 in AWS. Whatever the intent, s3 is a great place to house static content.
After you’ve created your s3 bucket, and enabled static web hosting, the last thing left to do is ensure your Bucket Policy allows the public to view your content.
You’ll need to insert the following content into the bucket policy. Just replace the bucketname with the name of your bucket.
If you want to generate your policy, use the generator below, & ensure you select ‘GetObject’ in the utility and copy your ARN number from the bucket policy screen beforehand.
https://awspolicygen.s3.amazonaws.com/policygen.html
Note: I couldn’t find this in the documentation for AWS but you must save the bucket the same name as the website for it to work with Route 53.
For example if your website name is example.com. You will need to call your bucket example.com. When you point your a record to s3 via an alias, the s3 bucket will only show when you named it correctly.
{
"Version": "2012-10-17",
"Id": "Policy1547697954106",
"Statement": [
{
"Sid": "Stmt1547697949608",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": [
"arn:aws:s3:::bucketname/*",
"arn:aws:s3:::bucketname"
]
}
]
}