First AWS project – Route 53 and S3 Buckets

To get to grips with AWS we need to actually build things and learn how it all fits together securely and cheaply (ideally free)

Create a static web page – version 1

You can create a static website with AWS simple storage service or S3

Bought a domain called abcloudcomputing.com as in ABCloud Computing ‘Cloud Computing as easy as AB’. OK so the branding needs a little work but lets go ahead and get this through Route 53 (Route 53 is a big road in America that connects loads of towns and cities and stuff).

We don’t need to have bought a domain from AWS but we do need to have on registered in AWS Route 53 as you need a hosted zone to put the details in. The key to this project is getting the Internet and the public the ability to see something you have done in this case a simple web site with a single web page.

To get to a website we need a few things

  1. Domain name like ABCloudComputing.com
  2. The domain linked to something that can be displayed in a browser
  3. Record that links the domain name to the something to display

When you buy a website with fancy templates and wizzy things they take care of all this but we want to learn how to do it for ourselves.

In Route 53 there are a few things we need to do but before we the need to setup the webpage that we will serve to the internet like its 1995. For this we need to put the page somewhere and that place is the AWS S3 which stands for simple storage service.

Buckets and Hashing

The system of storing things in S3 is in buckets. Now, you may be thinking some fancy trendy marketing came up with using bucket but no – some fancy trendy computer science came up with it as a way of organising things to store and, importantly find. A bucket is created when we apply a rule on how to organise things. Very simply imagine trying to store bowling shoes at a bowling alley. We have a rule that divides the shoe rack up so if someone turns up with their name we don’t look for the shoes in row of shoes but we look in the bucket where they should be e.g. names beginning with A go in the A bucket, B go in the B bucket. The rule of creating buckets is called hashing or running a has function. Hashing creates a hashing table which can associate all objects to a location or key. Hashing is also used in other ways to manipulate data which we may get into if we talk about security. For now we are going to store things (objects to be more specific) in a bucket (which itself is an object).

We are going to keep this super simple. Go to S3 and create a bucket with the same name as the domain name i.e. abcloudcomputing.com. Then create a html page called index.html in the bucket. Awesome. We now have a page and a domain. Now we have to do two things: 1) give permission for the bucket to be accessed by the public and 2) link the bucket to the domain.

To give public permission to the bucket click on the bucket called ABCloudComputing.com that has the index.html page in it. Then enable Static website hosting (AWS will recommend using AWS Amplify Hosting but ignore that). In the Static website hosting you can specify two documents – index and error. We didn’t bother with error one but feel free to add it in. Save the changes. This means the bucket is set work like a website when someone enters the right address.

Next is you need to change the bucket permissions in two ways. The first one is change the Block publics by switching of the Block All Public Access (it’s just for this bucket which is fine as you are making the bucket publicly available). The second thing, as this is a bit trickier, is add a bucket policy.

{
“Version”: “2012-10-17”,
“Statement”: [
{
“Sid”: “AddPerm”,
“Effect”: “Allow”,
“Principal”: “*“,
“Action”: “s3:GetObject”,
“Resource”: “arn:aws:s3:::abcloudcomputing.com/
}
]
}

This looks a little intimidating but it’s a policy or set of permission on what someone can do. In this case the someone or the principal is everyone (*) and they are allowed to do (Effect) and what activity (Action) and to what resource. Don’t worry about it now – the key thing here is you are letting the world access everything in the bucket which is cool as it’s what you want.

OK. The final part. Setting up the routing and this is where AWS is pretty neat.

In the world of DNS there are lots of ways that we can connect a protocol (an agreed way of doing things) with a thing of interest. For websites this means we need to set up a way to connect the world (website) with the bucket that we now have the index file in has the right permissions.

In Route 53 you will find all the external routes (websites/domains) that are registered with the account. Each domain is divided into a Hosted Zone which has records. When you have a domain registered with an accounts there are two records already setup – Name Server (NS) record which are the authority (named servers) that hold the domain so when someone look up a domain this record says “that’s us”. The other record is the Start of Authority (SOA) which is exactly what it says it is – it’s where there domain name service (DNS) starts.

OK. For our website to work we need to create an Address (A) record which is the backbone of DNS as it links a text name to a number address. In the old days of telephone we had to know the number and for some polite reason you would answer the phone by stating the number a person had just dialled ‘Hello, 01 234 567’ ahhh… better times. Now you search for the name and click call and vice versa – you look at the screen and ignore who it’s from (the only numbers you don’t answer are the ones with numbers!).

So we need to connect the DNS to the bucket via an Address (A) record. Easy. In Route 52 click Create Record. Keep everything as default apart from the Alias switch. Toggle that on and the boxes underneath change to Route traffic to and Choose Endpoint and Choose Region. The endpoint is an internal resource on the account like an S3 bucket – hooray. Pick that and then in the Choose region – Europe (London). This is where the buckets are and from you can choose the S3 buckets we created earlier. Pick the domain named bucket and click Save.

Now you have to wait as the records have to propagate through the account and the wider AWS and global DNS records – probably take about a minute. Once done you have a static website on the Internet baby!. Now you can spend more time and build a fancy site but it will just be static and it will be http not https which encrypted traffic for passwords and stuff. That’s for another day.

In summary – technologies: Route 53, S3 buckets nice and easy. What’s next…. let’s do some coding snizzle.