My Experiments with AWS Cloud -  Cloud Resume Challenge

My Experiments with AWS Cloud - Cloud Resume Challenge

Updates: 7/30/2020: Added github Urls for the project.

Few weeks ago I came across Cloud Resume Challenge on Reddit while searching something. I passed my Amazon Solution Architect certification on Jun 26, So I was looking for something to do next on AWS. Initially I was hesitant to take this challenge because it looked too easy to do. However, that was not the case, I realized only later when I progressed on the challenge. But what really caught my attention was to do Infrastructure as Code(IaC). Its easy to do stuff on AWS console but not on SAM/IaC if you are a beginner. So now I was determined to take up this challenge.

If you are not willing to learn, no one can help you. If you are determined to learn no one can stop you. — Zig Ziglar

Challenge Instructions:

Below were the high level requirements of the challenge.

  1. Certification Get AWS Cloud Practitioner Certification

  2. HTML Your resume needs to be written in HTML.

  3. CSS Your resume needs to be styled with CSS.

  4. Static S3 Website Your HTML resume should be deployed online as an Amazon S3 static website.

  5. HTTPS The S3 website URL should use HTTPS for security.

  6. DNS Point a custom DNS domain name to the CloudFront distribution

  7. Javascript Your resume webpage should include a visitor counter that displays how many people have accessed the site.

  8. Database The visitor counter will need to retrieve and update its count in a database somewhere.

  9. API Do not communicate directly with DynamoDB from your Javascript code. Instead, you will need to create an API that accepts requests from your web app and communicates with the database.

  10. Python Write Lambda function in Python;

  11. Tests You should also include some tests for your Python code.

  12. Infrastructure as Code Implement API resources – the DynamoDB table, the API Gateway, the Lambda function as Infrastructure as Code (IaC)

  13. Source Control Use Git hub as source control

  14. CI/CD (Back end) Set up GitHub Actions to automate build, test and deployment of Code.

  15. CI/CD (Front end) Set up git hub actions to automate deployment of frontend code in AWS including cloudfront cache invalidation.

  16. Blog post on the learnings.

Implementing the Challenge

The first few steps were easy but things got more messier when I reached Lambda, SAM/IaC portion of the challenge. I got the Resume ready, registered the domain, setup the s3 bucket for static website, setup cloudfront for s3 bucket. At this point I was able to access site using the domain name. I never worked on python before. I spent sometime learning python, Boto3 for interacting with AWS and moto for writing unit test in Python. You can decorate the test to indicate to use mock dynamodb instead of hitting actual services. Python is very particular about indentation. If you are a java developer,you are going to hate Python!

Alt Text

Most time consuming part of the challenge was Serverless Application Model (SAM). There are not enough good articles available on SAM. Only source is AWS Documentation. With some trial and Error I started getting the hang of it. I coded DynamoDB table and Lamdba function in SAM. DynamoDB table would keep track of visitors for each page. I wanted it to be scalable so I added counter per page. PageName being the Primary key.

Alt Text

I got my Lambda function, database and API as IaC in SAM and was working flawlessly using SAM CLI. I can't describe the happiness you feel when you see below line after SAM Deploy.

Alt Text

Although things were working I was not quite satisfied because part of my infrastructure was still configured manually like Route53, Cloudfront, API Gateway. So I decided to make it truly IaC and Implemented All of the above in SAM. I also added custom domain name to the API so that API can be accessed through a URL that doesn't change. For Example:

https://api.rajanpanchal.net/Prod/someMethod

As If Python was not enough to torture me on Indentation , I used YAML for SAM templates instead of JSON. Once in a while I would feel like:

Alt Text

I used only Notepad/GEdit to write the SAM templates. I would recommend you do the same if you are beginner.

Next step was to automate CI/CD for both backend and frontend. I experimented with GitHub Actions to understand how it works and its very powerful. I was ignorant on AWS S3 Sync command and due to this I had to resort to bash scripting to get the changed files in commit for frontend and upload to S3. Later I simply changed to AWS S3 sync command. However, my bash script was not wasted. I used it to invalidate cache on the cloudfront for the files committed. Backend CI/CD

Alt Text

Frontend CI/CD

Alt Text

Final Thoughts

You can check the final outcome here: rajanpanchal.net Here is the github url:

github.com/rajanpanchal Projects: aws-cloud-resume-frontend aws-cloud-resume-backend

I want to thank Forrest Brazeal for bringing up this challenge and the Cloud Resume Challenge Discord community that has been helpful during this challenge. It was a great learning experience. I have sacrificed several nights and weekends for this challenge but it was really worth it.

Where do I go from here?

I want to build more such projects with various other AWS services and grow my skills. I've got a Cloud Fever and the only prescription is more Cloud!