Wouldn’t it be great to just check in your infrastructure and code changes and they get deployed automatically?

Randy Findley
Jan 6, 2018 · 3 min read

Back in October I posted the Services Stack. The Services Stack is a collection of CloudFormation templates, to create a microservices application on AWS. If you haven’t seen it already please go check it out.

After posting the Services Stack I got a lot of great feedback, mostly all good ;). Turns out what was missing was Continuous Integration and Continuous Deployment (CI/CD).

I’ve gone back and added these features and am happy to share them with you today. And without further delay, here is the code…


Everything is a pipeline

I use CodePipeline to continuously update all the CloudFormation stacks, build the code, and deploy the code. There is a pipeline for the application and one for each service.

Take a look at this diagram and then we’ll go into more details below:

Application Pipeline

The application pipeline creates the application specific stacks (i.e. nothing service related) and then bootstraps each of the service pipelines.

The application pipeline is initially created via the command line. It then executes every time a commit is pushed.

The application pipeline consists of the following stages:

  1. Notifications Stage
  2. VPC Stage
  3. ECS Stage
  4. Services Stage

Notifications Stage

The notifications stage contains two actions. The first action creates a CloudFormation stack with resources to notify the user about DevOps events like build status, deployment status, etc…The second action executes a CodeBuild to test and deploy a Lambda function within the previous stack, always keeping it fresh.

VPC Stage

The VPC stage contains one action. A CloudFormation stack that sets up a VPC for our application.

ECS Stage

The ECS stage contains one action. A CloudFormation stack that sets up an ECS Cluster with EC2’s and an ALB.

Services Stage

The Services stage contains an action for each microservice. Each action is a CloudFormation stack that creates the pipeline for that service.

Service Pipeline

The service pipeline creates the service specific stack, performs the code build, and finally the code deployment.

Each service pipeline is executed on every code push to that specific service.

The service pipeline consists of the following stages:

  1. ECR & CodeBuild Stage
  2. Service Stage

ECR & CodeBuild Stage

The ECR & CodeBuild stage has two actions.

The ECR action simply creates an ECR repository for our Docker images.

The CodeBuild action first builds the code, then pushes the image to ECR.

Service Stage

The Service stage has a single action which is a CloudFormation stack for all the service related resources. The newly created ECR image from the previous stage is used when creating the ECR task, thereby deploying the latest changes. A specific version can be used if one wishes to deploy manually.


Two environments are supported, sandbox and production. Sandbox is triggered off the `develop` branch and production is triggered off the `master` branch.


Infrastructure is just as important as Code. Putting both through CI/CD is the best practice. I hope you like this stack. Please clap if you do (or don’t).


how hackers start their afternoons.

Randy Findley

Written by

Software Engineer & Entrepreneur


how hackers start their afternoons.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade