How to auto-deploy a new Docker image from ECR when a new image version is pushed and ready to deploy to an ECS Cluster using AWS CDK (CloudFormation) for the Infrastructure as Code
The goal for this problem is you got an ECS Cluster behind an Application Load Balancer inside your VPC, you need a way to ship a new version into your ECS Cluster and you pick GitHub as your code repository and Docker image builder where you push it into your ECR (Elastic Container Registry) Repository.
What I think will be a good process between your GitHub repository and your ECS Cluster will be a CloudWatch there listen to events from your ECR Repo for new image pushed to it, then trigger a Lambda function there can contain different information so you, in the end, can trigger an AWS CodeBuild process, this AWS CodeBuild will start your deployment for a new version into your ECS Cluster.
The first step is to create your ECR repository manual in the web console
Before we are doing all the fun stuff, you need to create an ECR repository you want to play with, its locked to your account and region so you can just use the same name as I did for this test repository ecs-deploy-prototype just use the default settings when you are creating the ECR…