This repository contains a GitHub Actions workflow that automates the deployment of a Dockerized application to AWS ECS using Amazon ECR and AWS CodeDeploy.
-
ECS and CodeDeploy Setup
- We have created an ECS cluster and service for the application.
- AWS CodeDeploy has been configured to manage deployments to the ECS service, including support for blue/green deployments.
-
Deployment Workflow
- The GitHub Actions workflow handles the entire deployment process automatically whenever changes are pushed to the
mainbranch or triggered manually. - Key steps include:
- Pushing Docker images to Amazon ECR tagged with the GitHub commit SHA.
- Updating the ECS Task Definition dynamically with the new image tag and environment variables at runtime.
- Triggering CodeDeploy deployments to roll out the updated ECS service.
- Optional monitoring of deployment status to ensure successful deployment and support rollback if needed.
- The GitHub Actions workflow handles the entire deployment process automatically whenever changes are pushed to the
-
Template Files
taskdef-template.jsonandappspec-template.ymlare included in the repository.- These files contain placeholders for environment variables and other runtime values.
- During workflow execution, the placeholders are replaced dynamically with actual values such as Docker image tag, environment variables, or resource names.
- Automated Deployment: No manual intervention is needed to update ECS or trigger CodeDeploy.
- Dynamic Updates: Task definitions and AppSpec files are updated at runtime to reflect the latest image and environment configuration.
- Safe Deployment: Using CodeDeploy’s blue/green strategy allows for zero-downtime deployments and easy rollback on failure.
- Reproducibility: Every commit triggers a consistent deployment pipeline, ensuring the latest code is always live in the ECS service.
This setup ensures a robust, automated, and reliable deployment pipeline for Dockerized applications on AWS ECS.
Initial deplooyment using Terraform
Deployment using the code-deploy workflow using code deployment
Code deploy for the subsequent deployment
AWS
Aws succeed deployment