
latest tag:
latest tag:
latest tag, rolling back to revision 3 still causes ECS to pull whatever image is currently labeled ...:latest in ECR. If latest has been overwritten by a newer (possibly broken) build, the rollback will not restore the known-good image. This explains why the rollback did not fix the problem.
Avoid using a mutable tag like
latest in production task definitions. Always reference an immutable tag (for example, a commit hash or build number) in the task definition so that each revision pulls the exact image you expect.latest and a commit-hash tag — but the task definitions we registered used :latest. Below is the buildspec we used during the demo (updated to a modern, recommended login flow):
:$IMAGE_TAG (typically a commit hash) and :latest and pushes both to ECR. The important detail is what gets written into task-definition.json when registering the task definition. If task-definition.json contains ...:latest, each revision will still point to the mutable latest image — making rollbacks ineffective.
How to fix this
Summary of recommended changes:
Step-by-step approach
- Ensure your pipeline builds and pushes an immutable tag (for example, the commit hash).
- Do not register a task definition that hardcodes
:latest. Instead, update the task definition to reference the immutable tag produced by the build. - Replace the image field in the task definition during the pipeline (post-build) before calling
aws ecs register-task-definition.
- Amazon ECR: https://docs.aws.amazon.com/AmazonECR/latest/userguide/what-is-ecr.html
- Amazon ECS task definition registration: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definitions.html