- Newest
- Most votes
- Most comments
The behavior change you're experiencing with AWS CodePipeline and ECS deployments is related to how ECS handles task definition revisions and image resolution.
In the past, when a deployment failed, CodePipeline would mark the stage as failed and roll back to the previous task definition. However, the current behavior appears to be creating a new task definition revision with the old (working) image when a deployment fails, and then marking the pipeline as successful since that deployment succeeds.
To address this issue and maintain the previous behavior, you have a few options:
-
Force new deployments: When updating your ECS service, use the "Force new deployment" option to ensure it resolves to the latest image digest.
-
Update your pipeline configuration: Modify your CodePipeline to explicitly handle failures differently, ensuring it marks the stage as failed rather than attempting an automatic recovery.
-
Use unique image tags: Instead of using static tags like "latest", use unique tags for each image version (such as build numbers or commit hashes) and update your task definition accordingly.
-
Implement error handling: Add specific error handling in your deployment stage to properly detect and report failures rather than automatically falling back to a previous working version.
-
Consider using a Lambda function in your pipeline that can validate the deployment and explicitly fail the pipeline stage if the intended image isn't deployed.
These approaches should help you maintain better visibility into your deployment status and prevent the pipeline from showing success when the intended deployment actually failed.
Sources
Avoid ecs task definition revision during deploy stage of codepipeline | AWS re:Post
ECS task definition image tag | AWS re:Post
Relevant content
- asked 3 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 months ago

not help me alot