My First Foray Into Developing A Serverless App On AWS
Published: 2020-09-09 19:49:39

Around two years ago I started my first programming experience at Epicodus, a programming boot camp in Seattle. It was a very rough time, going from being a professional Archaeologist and Conservationist to learning about HTML, CSS, Javascript and all the other things you must learn as a budding programmer. Since then, I've been working on expanding my skill set and programming knowledge. 

In July, I had a friend give me a contact. This contact informed me about the Cloud Resume Challenge by Forrest Brazeal. I have had zero experience using AWS prior to this, and only had a vague idea of what it was about. After reading through the rules of the code challenge, I realized I would need to get my AWS Certified Cloud Practitioner Certification. 

Three weeks later, I passed the AWS CCP Certification exam with a score of 882. I was incredibly excited about my score, as I had taken the test online and had some issues with the webcam resolution and face recognition during the test. I assumed at this point that I had enough knowledge of how things worked to complete the Cloud Resume Challenge. Boy was I in for some hard work.

The goals for the challenge sounded fairly easy. Deploy a static web page in a S3 bucket that holds resume information, distribute it using Cloudfront with HTTPS on a custom domain and create a back end in python that uses API Gateway, Lambda, and DynamoDB to keep track of a visitor count. All of this should be deployed using CI/CD and Infrastructure as Code(IaC) for the back end. Sounds easy enough!

So off I go, down that road that we've all done before. Setting up the initial project structure and getting to work on the stuff I knew how to do the best: Creating a static website. This was easy enough, as I used React to build the website. The tricky part was that the challenge required you to deploy the web site to the S3 bucket using CI/CD Github Actions. 

For those that haven't experienced the trial and error that goes into creating a CI/CD deployment, let me give you my full experience rundown. Normally you would just commit your changes to Github, and then deploy the website content manually. To create proper CI/CD using Github, you'll want to use Github Actions. This requires you to create a deploy.yml file that gives Github the necessary information to send and deploy your project to a S3 bucket, or any other resource. It took me a couple attempts at tinkering with the file, but in the end I was able to create a working Github Actions CI/CD deployment.

After a couple days of working on the front end portion of the project, and having a working Github Actions deployment, I was ready to start working on the back end and the IaC using a SAM(Serverless Application Model) template. I consider myself a Full Stack Developer, as I've worked with Node.js and other back end technologies in the past, but I will say this. As a developer who is new to AWS, creating a proper SAM template took me much longer than creating and writing the actual code for the Lambda function.

I spent many days, just delving deep into AWS Documentation, Stackoverflow posts and comments, trying to learn and digest as much information as I could about the SAM template. And then one day, I committed my back end that was pretty much just a blank python file with the SAM template, went over to the AWS console and BOOM. There everything was, properly set up and structured. One of the best days I've had in a long time. I had a SAM template that ACTUALLY created the AWS resources that I needed. Time to get working on the back end python code.

The last time I worked with Python was midway through my boot camp, where I spent the Thanksgiving week learning it. You could say that I pretty much have zero python knowledge, I understand how it looks and works, but writing it? That's a different story. I looked around and found some examples for a similar project and brought them into mine to see how it worked and interacted with AWS and DynamoDB. About a week later, I had culled and re-written the example code and had a working back end. I even had APi Gateway set up to test my Lambda code, and everything was working as expected.

All I needed was to call my API from the front end to retrieve the visitor counter information and update the database to reflect the new visit. Simple enough, just a get and a post and we're good! Well, I ended up having an error with CORS. Six hours later after delving into every post about CORS and AWS I could find, I was still having issues. CORS was enabled everywhere I could find it, my API was set up perfect, the get was working on my website but the post was not. 

Turns out, my fetch for the POST api was sending a GET request. After all my troubles and issues from start to finish, it was just a small change at the very end to finally have the project complete. Obviously, I had one more issue with invalidating my Cloudfront cache, which was expected. 

All in all, I believe that my experience in creating this project has been very enlightening. The Certified Cloud Practitioner exam did not really prepare me for this as much as I had expected it would. I knew how everything worked, and what everything was, but I had no idea how to implement ANY of this. It was all brand new, and also was incredibly complicated from a new user perspective.

I am happy to say that I have finished the Cloud Resume Challenge, despite the end date being a little over a month ago. I had started the course a week prior to the deadline, and never expected to hit it, but I still wanted to challenge myself and complete it.

AWS may look complicated and scary for a new user, but once you have everything set up and automated, it is a wild and fun trip seeing something you create running on the cloud. I wish the best for anyone going down this path.