Skip to main content
Welcome back. This lesson demonstrates what happens when a rolling deployment in Amazon ECS fails and how that failure can leave your service unhealthy or stuck. We’ll simulate a faulty build artifact, push it through the CI/CD pipeline, and observe ECS behavior so you can learn how to guard against and recover from such failures. Environment: AWS Cloud9 (you may also use VS Code in similar labs). What we’ll do
  • Introduce a deliberately broken application build.
  • Push the change to the repository and trigger a CodeBuild run that produces a new container image.
  • Update an ECS service to use the new task revision and observe the failed rolling deployment.
  • Cover why ECS does not automatically rollback by default and outline mitigations.
Application (fixed, simplified Flask app) The app shown below is the simplified Flask application used in the demo. In the lab, a developer intentionally removes or comments out critical code (for example, a route or import) to create a broken image that will fail at runtime or fail health checks.
Commit and push the faulty change After deliberately introducing the fault, the source changes are committed and pushed from the Cloud9 environment:
Trigger CodeBuild to create a new image A push to the repository triggers a CodeBuild project which builds a new container image and pushes it to Amazon ECR. Wait for the build to complete and then verify the new image in your repository.
The image shows an AWS CodeBuild project management interface for a project named "aws-microservice-project," displaying build configuration details and a history of successful build runs.
Verify the image in ECR Once CodeBuild finishes successfully, it pushes the image to ECR. Confirm the new image and its tag in your repository before updating ECS.
The image shows the Amazon Elastic Container Registry interface, displaying a list of images under the "cryptoproject" repository with details like image tags, artifact types, and sizes.
Update the ECS service Update the ECS service to point to the latest task definition revision (the one that references the newly built image). In the demo, we also reduce the desired task count to 1 so the effect of the broken deployment is easier to observe.
The image shows the AWS Elastic Container Service interface with settings to update the "crypto-app" service, including options for deployment configuration such as task definition, revision, service type, and desired tasks.
Observed failure behavior When the new task launches, the container image contains the intentional fault, so the task either crashes or fails load-balancer/container health checks. ECS will keep attempting to start replacement tasks, which results in a repeating failure cycle. Common symptoms:
  • New tasks never reach RUNNING + healthy state.
  • Service desired count is not satisfied (for example, shows 0/1 or 0/N).
  • Continuous restart attempts that consume compute and increase cost.
  • End-user impact due to unavailable application.
Why ECS does not auto-rollback By default, ECS persistently tries to deploy the requested task definition revision. ECS will not automatically revert to the previous working task definition unless you configure automatic rollback using the deployment circuit breaker or orchestrate rollback via external automation (CI/CD, CloudWatch alarms, or CodeDeploy). Mitigation and best practices Use one or more of the following features and practices to prevent or reduce the impact of failed rolling deployments:
Enable the ECS deployment circuit breaker and configure container and load-balancer health checks to automatically abort failed rolling updates and roll back to a previously stable task revision.
Next steps We will next examine ECS deployment circuit breaker settings in detail and demonstrate an automatic rollback during a failed deployment. For further reading and to implement the suggestions above, see the links below. Links and references

Watch Video