Continuous Deployments using AWS CodeBuild for FrontEnd

Shuja Abedin
Airlift Technologies
3 min readJun 15, 2020
Continues Deployments using AWS CodeBuild for FrontEnd

Every startup needs to start small and then scale the infrastructure as the customer base grows.

As a starting point, Airlift started by having simple server based hosting for our Frontend. But as soon as demand increased for our product, we realized the need for an infrastructure that scales itself, so that it could handle the growing requests.

A look at the background:

We all know deploying anything on EC2 instances is quite easy. It’s like deploying anything in a local environment — just access the instance, pull all your latest work from the git repository & Voila!, everything is there on the frontend website.

However, for static websites, AWS best practice is to host the static content in an encrypted S3 bucket and serve it to your users via the AWS CDN — CloudFront.

For this to work, we push (or upload) our code to the S3 bucket whenever there are changes to the Codebase. There are multiple ways to do it:

  1. Uploading your files to s3 manually
  2. Pushing it using AWS CLI.

For the first approach, you have to sign in to the AWS console and perform the upload process manually but that gets tedious if you have to do it multiple times a day.

For the second approach, AWS Access Keys are used to push the code, which is always considered a threat if they get exposed due to any reason.

The Final Solution:

We needed an automated solution which the dev team could easily use for deployments — a solution that did not unnecessarily involve Cloud Engineers. For this, we used AWS Developer Tools. We integrated AWS CodeBuild and it helped us to perform deployment with just a few clicks. The workflow diagram below explains our overall solution:

Deployment Workflow

Let me explain the workflow:

  • Developer pushes the code to the git repository.
  • Developer starts the build using AWS CodeBuild Console. CodeBuild will spin up a server and pull all latest work from the git repository and push it to s3 bucket. (this is done by only 2 clicks)
  • Once the latest code is deployed on S3 bucket, CloudFront will deploy the latest content on the Frontend Website. (You need to flush your CloudFront cache manually or wait for the cache refresh period to clear cache for the content to start showing)
  • WAF is a Web Application Firewall used for security purposes to avoid any attacks. AWS WAF controls how traffic reaches your applications by enabling you to create security rules that block common attack patterns like SQL injection or cross-site scripting, and rules that filter out specific traffic patterns you define.

Moving things to AWS CodeBuild via its console was fairly easy and straightforward. You just need to add your git repository, select an image that will be used for deployment and define the S3 artifact / bucket that will hold your code as well as few other settings as per need.

And there you go! Our goal was to make the process simple for every member of the Dev / QA Team to perform deployments on any environment themselves without having to rely on someone from the Cloud Team.

Shuja works on the Technology team as a Senior Cloud Infrastructure Engineer. He loves to read about new technologies, play & watch Dota2 competitive scene. He just started blogging and is looking forward to many more entries. He can be reached at shuja.abedin@rideairlift.com. To join our team, please click here to visit our job board to browse open positions.

--

--