Welcome to my Education Lounge

Where I write about security and tech how-tos

Home
7 August 2018

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

  1. Sign into your console and select s3
  2. Create 2 buckets: domain.name and www.domain.name

    I have my things in Ohio as that is the closest city to me

Setting up the www.domain.name bucket

  1. Click on your www.domain.name bucket
  2. Go to Properties and select Static website hosting
  3. Pick redirect requests
  4. In the target bucket or domain blank put domain.name and hit save

Setting up the domain.name bucket

  1. Click on your domain.name bucket
  2. In overview if you have your site already made hit upload else move to the next step
  3. Go to Properties and select Static website hosting
  4. Pick Use this bucket to host a website
  5. In the Index document blank put index.html and hit save
  6. Go to Permissions and select Bucket Policy
  7. 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/*"
         }
     ]
    }
    
  8. Hit save and we can blow this popsicle stand!

Route53 Setup

  1. Click on Hosted zones and then hit Create Hosted Zone
  2. Hit Create Record Set
  3. Make sure the Type: is A - IPv4 address
  4. Set Alias to yes
  5. From the dropdown you should see domain.name, if so click on it but if not wait a few moments and look again
  6. 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

  1. Click on the NS record
  2. On the right you will see a section called Value:
  3. 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!

tags: aws - static hosting - s3 - route53