Free-Tier AWS native CI/CD pipeline for dev using Docker on EC2.

Carlos Garcia
2 min readDec 10, 2020

Lack and constraint of resources is a wonderful thing. It creates a need to make things possible by leveraging limited options; Especially when dealing with startups who want to leverage cloud platforms such as AWS or companies who want to dip their toes in AWS (cloud in general) before considering their options.

Over the weekend I was approached by a family member who was interested in developing a very cool app using AWS as the cloud choice. However, there were no funds and it needed to be hands-off — of course, we know that hands-off really means higher costs unless you leverage open-source tools with a pinch of automation scripting. Lucky for him I had a working concept in my personal environment.

The pipeline is fairly simple and falls within the Free-Tier offered by AWS — Perfect for a DEV environment. Of course, this is considering the usage limit imposed by this tier. Keep in mind that for this scenario, I decided to skip Jenkins or Travis in order to keep the majority of the workflow in favor of AWS native resources.

  • AWS IAM handles repo access (From dev user and also from the designated serv account used by the EC2 instance — As of 12/20, CodeCommit does not allow API calls to clone/pull based on Role)
  • Code repository: handled by AWS CodeCommit
  • Push/Merge actions trigger an AWS Lambda function (AWS CodeBuild runs on $).
  • The AWS Lambda function parses the information and passes the parameters to AWS Systems Manager (SSM)
  • SSM does a run command (Shell Script) call to an active t2.nano EC2 amz2 linux (Docker host)
  • Script cleans local files and processes, pulls repo, and builds a new Docker image which then replaces the old container.

Again, this is a very basic example that jumps through hoops in order to keep things within the AWS Free-Tier. This example is a quick and easy way to setup a CI/CD pipeline for personal / small development projects. I do not recommend doing this architecture for team projects.

--

--

Carlos Garcia

AWS Engineer and DevOps dude. Keep it simple and to the point!