Perform ECS to CodeDeploy deployment using CodePipeline and ECR

Lab Details

  1. This lab walks you through how to perform ECS to CodeDeploy deployment using ECR as a source and CodePipeline as Pipeline with the help of ECS. In other words, you will learn to deploy container applications using blue-green deployment.

  2. Duration: 120 minutes

  3. AWS Region: US East (N. Virginia) us-east-1

Introduction

What is AWS CodePipeline?

  • AWS CodePipeline helps you in modeling, visualizing, and automating the steps required to continuously deliver the release of your software.

  • Using AWS CodePipeline, you can create and configure various stages of a software release process. It helps you automate the delivery of software having a frequent release.

  • AWS CodePipeline can help you do various tasks, such as

    • Automating release process of software delivery

    • View Pipeline history details

    • Customize the stages and action

    • Choose the source, build and deploy stage.

    • Add the manual approval for the release process.

    • Integration with various AWS Services.

  • AWS CodePipeline at a glance.

  • Source: A place where source code with its revisions is stored. It can be Amazon S3 Bucket, CodeCommit repository, or Git-based repositories such as GitHub and Bitbucket.

  • Build: In this phase, the buildspec.yml file plays a very important role. This is the phase where software is tested and build. 

  • Staging: A place where code is deployed into a testing environment or also called a pre-production environment. You use this phase to test the software before making it live for public users. This is an optional stage if the application is well tested before uploading to the source.

  • Manual approval: This phase helps software engineers to get the approval for the code, deployed and well tested into the testing environment. It uses SNS to get the approvals on the email. This is the optional stage.

  • Deploy: The last phase for the delivery of software. Using AWS CodePipeline, applications can be deployed on Amazon EC2 Instances using CodeDeploy, Elastic Beanstalk, or AWS OpsWorks Stacks. 

Architecture Diagram

Task Details

  1. Launching Lab Environment

  2. Create an AWS CodeCommit repository

  3. Create a Security Group for the ECS Cluster

  4. Create a Key Pair

  5. Launching an ECS Cluster

  6. SSH into the EC2 Instance of ECS Cluster

  7. Create an image and ECR Repository then push the image on the repository

  8. Register task definition using taskdef.json and upload to CodeCommit repository

  9. Upload the appspec.yaml file to the CodeCommit repository

  10. Create target groups and application load balancer

  11. Create the ECS Cluster and ECS Service

  12. Create a CodeDeploy application and Deployment group

  13. Create a pipeline, add ECR as a source, and wire your source artifacts to the deploy action

  14. Check the output in the ECS console

  15. Delete the resources created