My Portfolio AWS Architecture
BACK

My Portfolio AWS Architecture

Services used: Route 53, S3, CloudFront, ACM

Languages used: JSON

Objective: Create a domain name with Route 53 for the portfolio website. Create an S3 bucket to store all of the website data. Enable the bucket to be publicly accessed and allow it to host a static website. Test the static website using the HTTP protocol. Disable the bucket to be publicly accessed and use CloudFront to deliver the content globally instead. Create a certificate with ACM to create secure HTTPS connections to the portfolio website. Create another S3 bucket and redirect users to the subdomain. Create A records in Route 53 to the CloudFront distributions for both IPv4 and IPv6.

First, we will create a domain in Route 53. Search for and open Route 53 in the console and click Get started.

Select Register domain then click Get started. Here we can search for the availability of a domain name of our choice. Click Select for your desired domain then Proceed to checkout.

Select your desired Duration and ensure that Auto-renew is On. Click Next.

Enter your contact information and ensure that Privacy protection is turned on. Click Next.

Review the information then scroll down and review/accept the Terms and conditions. Click Submit.

Once the domain is created, go to Hosted zones. Click the Hosted zone name.

Ensure that we have the NS and SOA records. The NS record ensures that the AWS DNS will be used to answer DNS queries, which will be Route 53.

Now search for and open S3. Click Create bucket.

Create your own Bucket name (website URL created in Route 53) and ensure that it is globally unique. Select your desired AWS region. For now, we will leave all the default settings. Scroll down and click Create bucket.

Click the Bucket Name that was just created.

Here we can add the files and folders of our portfolio website. Click Upload.

Click Add files and select the desired files to upload. Click Upload.

Go back to the S3 bucket and review all of the Objects. Next, go to the Permissions tab.

We will now allow our S3 bucket to have public access so that our portfolio can be viewed by the public. Click Edit in Block public access.

Unselect the Block all public access check box and click Save changes. Ensure that you want all contents of the bucket to be available to the public. Confirm changes.

Scroll down to Bucket policy and click Edit.

Click Policy examples which will take you a new page. Copy the Bucket ARN for a later step.

In our case, we will be Granting read-only permission to anonymous users and have already completed all the steps.

Head back to the console and click Policy generator.

For Policy Type, select S3 Bucket Policy. For Add Statements, Allow anyone * to GetObject. Paste the Bucket ARN that we copied earlier and add /* to the end of it to allow any object in the bucket. Click Add Statement.

Click Generate Policy and copy the JSON code.

Go back to the console and paste the JSON code into the policy. Ensure that it is a public bucket so that anyone can get any object from the bucket. Scroll down and click Save changes.

Review the Permissions overview and ensure that there is Public Access.

Go back to the Objects tab and select a file to ensure that it can be viewed from the public internet.

Head to the Properties tab then scroll down to Static website hosting and click Edit.

Enable and select Host a static website. Add your home page URL such as index.html. Click Save changes.

The next step is to create a new record that will allow users to visit the URL created in Route 53, and be redirected to the S3 bucket with our portfolio website files. Search for and open Route 53. Go to Hosted zones and click the URL.

Click Create record.

Click Switch to wizard then select Simple routing and click Next.

Click Define simple record. Leave the subdomain Record name empty. For the Choose endpoint dropdown select Alias to S3 website endpoint. Select the same region where the URL was created. Select the URL in the dropdown menu. Untick Evaluate target health and click Define simple record. On the next page click Create records.

Test the website with the http:// prefix.

Now that we have tested the website, head back to the S3 bucket and select the Permissions tab. Turn Block public access back on and delete the Bucket policy.

Go to the Properties tab and scroll down to disable Static website hosting.

Refresh the website that we tested and there should be an error.

Next Search for and open CloudFront. Click Create distribution.

Select our S3 bucket as the Origin domain and choose Origin access control settings. Click Create control setting and then Create.

Scroll down and disable WAF. WAF is always recommended as a first line of defense at edge locations globally, but we are not storing any important data in this case.

Scroll down and for the Default root object add index.html then click Create distribution.

Click Copy policy then take the shortcut directly to our website S3 bucket.

Scroll down and click Edit.

Paste the policy we copied. Scroll down and select Save changes.

Go back to the CloudFront tab and copy the Distribution domain name.

Paste in a new window and we should see our website. Go through the different tabs once. When you go through and click the tabs again it should load instantly from the cache in the CloudFront distribution.

We now need to create a certificate for CloudFront to encrypt connections using HTTPS. Search for and open ACM. Click Request a certificate.

Select Request a public certificate then Next.

Enter the Domain name and add another name with a *. so that any subdomain can use the wildcard certificate. Scroll down and click Request.

Next select the Certificate ID.

Select Create records in Route 53.

Ensure the record type is CNAME and click Create records.

Search for and go to S3. Create a new bucket for the subdomain, making it the same as the website bucket but adding www. where users will be redirected to. Ensure that all the files are only in the new bucket.

Return to the original bucket and go to the Properties tab. Scroll down to Static website hosting and click Edit.

Select Enable then Redirect requests for an object. Enter the subdomain and select HTTPS. Click Save changes.

Return to the CloudFront distribution we created. Go to Behaviors and click Edit.

Select Redirect HTTP to HTTPS. Scroll down and click Save changes.

Go to the General tab and under settings click Edit. Choose Add item for Alternate domain name and type the subdomain. Select the Custom SSL certificate we created in ACM. Scroll down and click Save changes.

Go to the Origins tab and click Edit. Choose the subdomain S3 bucket. Select Legacy access identities and select or create a new OAI.

Recreate another CloudFront Distribution but with the root domain bucket website endpoint.

Search for and go to Route 53. Click the Hosted zone name.

Select Create record.

Select Simple routing and click Next.

Click Define simple record.

Add www to the name. Select the endpoint Alias to Cloudfront distributions. Select the subdomain distribution. Click Define simple record.

Since IPv6 is enabled for our CloudFront distribution, we must create another Alias for it. Repeat but with the AAAA record. Create two of the same records but with the domain name for rerouting purposes.

Click Create records.

Now type your root domain in a new browser. Success!