Using Amazon ECS for Blue-Green Deployments

Lab Steps

Logging in to the Amazon Web Services Console
Creating the Elastic Container Repository
Building the Docker Images
Creating the ECS Cluster
Creating the Task Definitions
Creating the Target Group and Load Balancer
Creating the ECS Services
Viewing Instances and Application Message
Updating the Services and Application Deployments
Deleting the ECS Laboratory Resources

Ready for the real environment experience?

Time Limit2h 30m


Amazon Elastic Container Registry (ECR) is a fully-managed Docker container registry that helps you store, manage, and deploy Docker container images.  ECR is integrated with Amazon Elastic Container Service (ECS), streamlining your development and deployment operations. You can use Amazon's other services such as Simple Storage Service (S3) and Identity and Access Management (IAM) to control and manage your entire container-based solution. In this Lab, you will build two Docker container images with Amazon CodeBuild, push the images to ECR, and perform a blue-green deployment operation using ECS.

Lab Objectives

Upon completion of this Lab you will be able to:

  • Use application source files to create Docker container images and place them in Amazon ECR.
  • Create an Amazon ECS cluster.
  • Use the Amazon ECR images to create task definitions and services.
  • Implement the services in ECS container instances and adjust instance numbers.
  • Register ECS container instances with an Application Load Balancer (ALB).
  • Switch from one deployed application to another quickly and with no downtime.

Lab Prerequisites

You should be familiar with:

  • Basic understanding of local operating system and computer use.
  • An understanding of Docker and container concepts is helpful, but not required.


May 3rd, 2022 - Updated lab step to improve clarity and user experience

March 18th, 2022 - Updated step 3 to 7 with more/clear screenshots and added instructions

December 27th, 2021 - Updated screenshots and instructions to reflect the latest UI

December 14th, 2021 - Corrected the name of the S3 bucket name referred to in the CodeBuild project 

August, 9th, 2021 - Updated the AWS CodeBuild lab step to reflect the latest user interface changes and clarified some instructions

October 29th, 2020 - Addressed an issue that prevented the ECS services from starting

July 30th, 2020 - Increased time limit based on student feedback

March 5th, 2020 - Added a new lab step that instructs you to remove resources from the lab

May 30th, 2019 - Added a new validation Lab Step to check the work you perform in the Lab in more detail

May 24th, 2019 - Updated CodeBuild instructions and buildspec.yaml to work with the new standard Docker image

January 10th, 2019 - Added a validation Lab Step to check the work you perform in the Lab

July 18th, 2018 - Updated screenshots and instructions to match the new Console experience

Environment before
Environment after
About the Author

Eric is a Lab Researcher and Developer working to add to Cloud Academy's library of hands-on labs. He is an IT veteran who enjoys the ever-changing landscape of cloud computing. He also relishes live classical music performances, because sometimes engineering is better heard than seen.