Deploy The Build Automation With SSM

Now that our AMI Builder Pipeline is built, we can now work on the final automation stage with Systems Manager.

In this section we will orchestrate the build of a newly patched AMI and its associated deployment into our application cluster.

To automate this activities we will leverage AWS Systems Manager Automation Document.

Using our SSM Automation document we will execute the following activities:

  • Automate the execution of the EC2 Image Builder Pipeline.
  • Wait for the pipeline to complete the build, and capture the newly created AMI with updated OS patch.
  • Then it will Update the CloudFormation application stack with the new patched Amazon Machine Image.
  • This AMI update to the stack will in turn trigger the CloudFormation AutoScalingReplacingUpdate policy to perform a simple equivalent of a blue/green deployment of the new Autoscaling group.


Using this approach, we streamline the creation of our AMI, and at the same time minimize interruption to applications within the environment.

Additionally, by leveraging the automation built in Cloudformation through autoscaling update policy, we reduce the complexity associated with building out a blue/green deployment structure manually. Lets look at how this works in detail:

  • Firstly, CloudFormation detects the need to update the LaunchConfiguration with a new Amazon Machine Image.
  • Then, CloudFormation will launch a new AutoScalingGroup, along with it’s compute resource (EC2 Instance) with the newly patched AMI.
  • CloudFormation will then wait until all instances are detected healthy by the Load balancer, before terminating the old AutoScaling Group, ultimately achieving a blue/green model of deployment.
  • Should the new compute resource failed to deploy, cloudformation will rollback and keep the old compute resource running.

For details about how this is implemented in the CloudFormation template, please review the pattern3-application.yml template deployed in section 2.

Once we complete this section our architecture will reflect the following diagram:

Section4 Automation Architecture Diagram

In this section you have the option to build the resources manually using AWS console. If however you are keen to complete the lab quickly, you can simply deploy from the CloudFormation template and take a look at the deployed architecture. Select the appropriate section:

Build with a CloudFormation template on the command-line
Build with a CloudFormation template in the console
Build Automation Document Manually