Resume Website on AWS Pt. 2 - Reflections

Mark DownsMark Downs
3 min read

Introduction

This blog is a continuation to the cloud resume project that I started. So far I had built a website and hosted it on AWS. In this part I created an API to keep track of how many visitors my website gets.

Lambda & DynamoDB

  • Created a lambda function using python that retrieves viewer count on dynamodb and increases it by 1

  • Utilized boto3 library to create lambda function

  • Created IAM role for lambda function to update dynamodb table

  • Learned how to use CORs on lambda function to make it so only my website can use the function

  • Learned how to use the debugging console on lambda to debug my function

API

  • Utilized Javascript to create a function that calls on my lambda function everytime my website is loaded

  • Displays viewer count from fetched data

  • Learned how to call APIs using javascript and also how to alter html using javascript

Github Actions CICD Frontend

  • Utilized Github Actions to create a CICD pipeline that automatically updates my website once new code is commited to my repository

  • Found a bug that my website was not updating even though S3 bucket was updated

    • Learned that I needed to invalidate cloudfront distribution to make changes appear immediately
  • Added cloudfront invalidation to cicd pipeline

  • Learned how to trigger CICD only when files I want are modified

Terraform

  • Utilized terraform to rebuild dynamodb and lambda infrastructure

  • Created roles and policies for lambda to modify dynamodb table

  • Applied terraform changes using my local environment

  • Learned terraform's syntax and how to initialize, plan, and apply terraform plans

Github Actions CICD Backend

  • Utilized Github Actions to create a CICD pipeline for my terraform files whenever they are modified

  • Learned how to validate aws credentials in github actions

  • Learned that github actions does not save the state of terraform files, therefore I need to create a backend to save the state

  • Learned how to trigger CICD only when terraform files are modified

Areas of Improvement

  • I worked off the main branch in github and committed my changes without making pull requests

    • That's why I have some failed deployments on my github repository

    • Pull requests would have fixed this issue

  • In this project I did not use unit tests

    • By creating unit tests I would have been able to detect bugs easier
  • For the terraform files, I could have created a backend using an s3 bucket to save the state and dynamodb table to lock the state

    • However, I just deleted the table and lambda function to make the deployment easier

    • Adding this backend will make it easier to add changes to my terraform files and deploy them use them github actions

0
Subscribe to my newsletter

Read articles from Mark Downs directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Mark Downs
Mark Downs