AWS Cloud resume challenge
Published: 2023-04-19 02:13:39

In this article I describe how things I worked on the AWS CRC project With some slight comparison with Google Cloud based on my own experience. By the way, I also wrote an article about the Google Cloud version of this project, you can have a look at it [here](https://blog.davidwoglo.me/google-cloud-resume-challenge).

It is better if you are new to all this Cloud related stuff, to take the  [AWS Cloud Practitioner certification](https://aws.amazon.com/certification/certified-cloud-practitioner/) exam, as recommended in the [CRC guide](https://cloudresumechallenge.dev/docs/the-challenge/aws/) as a first step. If you are not familiar with cloud environments or come from another cloud provider, taking this exam will help you validate your knowledge of the cloud and your familiarity with the different services of AWS (in case you come from another cloud provider). 

Personally, I had to quickly complete the [AWS Cloud Practitioner Quest](https://www.credly.com/badges/aec0902e-11fc-4056-82e3-0fba80d07dc3/linked_in_profile) to refresh my knowledge of AWS as I am quite familiar with the cloud and regarding AWS, I have already worked with some services. The quest is free; you can try it [here](http://skillbuilder.aws/cloudquest?acq=sec&sec=syq).

Well now it's good for the intro, let's get to the heart of the matter

# Big picture of deployments

This project is about creating a website which is hosted on amazon S3, then on the site display the number of visitors which is calculated with an AWS Lambda Function and stored in DynamoDB table, then automate all process, Website publication and the resources deployment  via a CI/CD pipeline. 
My resume page is available [https://aws.davidwoglo.me/](https://aws.davidwoglo.me/)



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lkcaxrs3hq9apsv8c043.png)


# Website

The first steps of the project consist in setting up a website, using a completely different approach than the traditional one. In a traditional way, we set up a machine or VM on which we install a web server (Apache, Nginx, or whatever you choose) then we upload the html/CSS files etc. and we proceed to some configuration to make the site available. 

![website.png](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gduqcev1meyjuwwuzhlj.png)



There I'm spared this server preparation task (and the underlying configs). I just uploaded the website files to [Amazon S3](https://aws.amazon.com/s3/) bucket, the object storage service of AWS, the equivalent of Cloud Storage at Google Cloud, then I did some small configuration in two three clicks, just to let S3 know that I want to use this bucket to host a static website, and then we have a ready to use website. No need for a physical server or additional tools to install. ***This is the serverless approach***, and this is what the rest of the project is based on, I didn't need to use any server or VM. 

In order for my site to be accessible via a user friendly and secure HTTPS URL, it is necessary to manage the DNS and the ssl certificate configuration, so I used [AWS Certificate Manager](https://aws.amazon.com/certificate-manager/) to obtain a certificate for my domain which ownership had to be verified by automatic mail, due to some problems related to my Custom Domain provider but it is recommended to use a CNAME record to do that. Then to route the DNS traffic I used [Amazon Route 53](https://aws.amazon.com/route53/), and the distribution of website content is sped up by [Amazon CloudFront](https://aws.amazon.com/cloudfront/)(CDN Service). All these configurations were done manually in a separate way and tied together at the end to make things work. 

At this point let's make a small comparison with how Google Cloud handles it. At Google Cloud all this can be included in the creation of a Load Balancer where we will just have to activate the automatic management of SSL for HTTPS and CDN for content caching. 

# Counting website visitors 


![visitor count](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fzbfwgw9ayd5gyt7oell.png)



My web page include a visitor counter that displays how many people have accessed the site.To do this, I created an  [AWS Lambda](https://aws.amazon.com/lambda/) function, a [DynamoDB](https://aws.amazon.com/dynamodb/) table and a REST API. On one side, I wrote a python code that is executed by Lambda, the python function is to get the current number of visitors stored in DYnamoDB and increment it by 1 each time a visitor access my page,  on the other side, I added a javaScript code to the files of my site. The job of this script is to get the number of visitors present in the Dynamo table and display it on my page, the communication between the JS code and the database is done via a REST API that I set up using [Amazon API Gateway](https://aws.amazon.com/api-gateway/). 

This is the part that gave me headaches when I was doing the project on Google Cloud. I didn't use an API Gateway there (because honestly, I didn't know), so I used an open source [Functions Framework for Python](https://github.com/GoogleCloudPlatform/functions-framework-python) in which I used client library API to communicate with Cloud Firestore which is the equivalent of DynamoDB. 

# Automation (CI/CD, IaC, Source Control)




![IAC](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a31bfk3a0j8o4kxcb0tf.png)



To accelerate and simplify the update of my deployments, whether it is the website (frontend) or the underlying resources (backend), I need to set up a CI/CD pipeline. A CI/CD pipeline is a series of steps that must be performed in order to deliver a new version of software. 
Well for the website, it's ok, we can manage it as software, (it's composed of files as a software is), the question you could ask yourself is : What about the cloud resources in the background ? Since they are not files, right? This is where Infrastructure as Code (IaC) comes in. But before talking about it, let's see how the CI/CD for the front end was set up. 
I created a source control  repository on Github where I put the website files, then I wrote a workflow file that instructs [Github Action](https://docs.github.com/en/actions) on how to update my website every time I make a push. 
Now let's talk about the [Infrastructure as Code](https://www.hashicorp.com/resources/what-is-infrastructure-as-code/) stuff, i.e. how to manage provision resources through machine-readable definition files, rather than use an interactive configuration as it is traditionally done.
Well I used [Terraform](https://www.terraform.io/docs) to define the DynamoDB table, the API Gateway, the Lambda function configurations in a template and deploy them with Terraform CLI. You see, now that we can also manage our infrastructure as a software, we can integrate it in a CICD to accelerate the process of deployment and update of the infrastructure resources. 
I proceeded in the same way as the website to set up the Backend pipeline, just that here the Github Actions workflow file is a bit more complex.

You can access my frontend repository [here](https://github.com/davWK/cloud-resume-challenge-AWS) and the backend one [here](https://github.com/davWK/cicd-cloud-resume-challenge-AWS)


Well, here is how things went during this project. Thanks for reading :) 
Please check below for some useful resources.

# Useful resources
- [Use an Amazon CloudFront distribution to serve a static website](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/getting-started-cloudfront-overview.html)
- [What is DNS? | How DNS works](https://www.cloudflare.com/learning/dns/what-is-dns/)
- [Serverless Land](https://serverlessland.com/)
- [DynamoDB Guide](https://www.dynamodbguide.com/)
- [API Projects](https://theultimateapichallenge.com/)
- [Python](https://wiki.python.org/moin/BeginnersGuide/NonProgrammers)
- [Amazon API Gateway CORS Configurator](https://cors.serverlessland.com/)
- [Java Script](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Language_Overview)
- [API Calls](https://www.freecodecamp.org/news/how-to-make-api-calls-with-fetch)
- [Automate Terraform with GitHub Actions](https://developer.hashicorp.com/terraform/tutorials/automation/github-actions)