Static Hosting on AWS
I've been using AWS a lot more now mostly because I have credits (don't want to lie to you). If you follow me on social media then you know I recently fell in love with linode for small projects (I also have some credit there), but for things that won't change such as my personal site and business site I'm going to stick with AWS. This is a guide to remember how to host a site using s3 buckets and route 53. It took me forever to figure out the first time. So let's begin...
Setting up Buckets
- Sign into your console and select s3
- Create 2 buckets:
domain.name
andwww.domain.name
I have my things in Ohio as that is the closest city to me
Setting up the www.domain.name bucket
- Click on your
www.domain.name
bucket - Go to
Properties
and selectStatic website hosting
- Pick
redirect requests
- In the
target bucket or domain
blank putdomain.name
and hit save
Setting up the domain.name bucket
- Click on your
domain.name
bucket - In overview if you have your site already made hit
upload
else move to the next step - Go to
Properties
and selectStatic website hosting
- Pick
Use this bucket to host a website
- In the
Index document
blank putindex.html
and hit save - Go to
Permissions
and selectBucket Policy
- insert the following
I actually don't know why the version is for that date but it works so go with it
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::domain.name/*"
}
]
}
- Hit save and we can blow this popsicle stand!
Route53 Setup
- Click on
Hosted zones
and then hitCreate Hosted Zone
- Hit
Create Record Set
- Make sure the
Type:
isA - IPv4 address
- Set
Alias
to yes - From the dropdown you should see
domain.name
, if so click on it but if not wait a few moments and look again - Hit save
DNS Things
So at this point the last thing is connecting DNS to your domain provider. I'm not sure who you use so I'm just going to tell you to find said name servers.
Still in Route53 continuing from the last step
- Click on the
NS
record - On the right you will see a section called
Value:
- Those 4 lines are what need to be copied for your custom DNS "points"
Now hit save and wait a few minutes. You have officially got your new static site hosted. Enjoy!