AWS CodeDeploy Automatic Rollback — Configure Deployment Group for Failures
A company uses AWS CodeDeploy to deploy applications to an Auto Scaling group. During a deployment, the new instances fail the health check and are terminated. The deployment fails. The team wants to automatically roll back to the previous working version. What should they do?
Quick Answer
The answer is to configure the deployment group to automatically roll back when a deployment fails. This is correct because AWS CodeDeploy’s built-in rollback mechanism monitors deployment events—such as failed health checks on new instances in an Auto Scaling group—and automatically redeploys the last known good revision, eliminating the need for manual intervention or custom scripts. On the AWS Certified DevOps Engineer Professional DOP-C02 exam, this concept tests your understanding of deployment group settings versus manual rollback or lifecycle hook approaches; a common trap is confusing automatic rollback with simply terminating failed instances, which does not restore the previous version. Remember the key distinction: automatic rollback is a deployment group configuration, not an instance-level action. A useful memory tip is “rollback is a group decision”—if the deployment fails, the group decides to revert, not the individual instance.
⚠ Common exam trap
Many exam-takers confuse Auto Scaling lifecycle hooks with CodeDeploy rollback mechanisms, or think that redeploying the same revision (option D) would fix the issue, when in fact it would just repeat the failure.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Configure the deployment group to automatically roll back when a deployment fails.
AWS CodeDeploy provides a built-in rollback configuration that can be triggered automatically when a deployment fails. By enabling automatic rollback in the deployment group settings, CodeDeploy will redeploy the last successful revision when the current deployment fails health checks, without requiring manual intervention or additional infrastructure.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Set up an Auto Scaling lifecycle hook to terminate instances and trigger a rollback.
Why it's wrong here
Auto Scaling hooks do not trigger rollbacks.
- ✓
Configure the deployment group to automatically roll back when a deployment fails.
Why this is correct
CodeDeploy can automatically roll back to the last known good revision.
- ✗
Manually redeploy the last successful deployment revision after investigating the failure.
Why it's wrong here
Manual rollback is not automatic.
- ✗
Configure the deployment group to automatically redeploy the same revision on failure.
Why it's wrong here
Redeploying the same revision will likely fail again.
Go deeper
Related to this question
About these practice questions
This DOP-C02 question is part of Courseiva's 251-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
Same concept, more angles
3 more ways this is tested on DOP-C02
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. A company uses AWS CodeDeploy to deploy applications to an Auto Scaling group. During a deployment, the deployment fails because the target instances are not passing the health checks. The DevOps engineer notices that the CodeDeploy agent logs show 'The overall deployment failed because too many individual instances failed deployment, too few healthy instances are available for deployment, or some instances in your deployment group are experiencing problems.' Which step should the engineer take to diagnose the issue?
medium- A.Increase the size of the Auto Scaling group to ensure more instances are available.
- ✓ B.Review the CodeDeploy deployment logs on a failed instance to identify script errors.
- C.Create a CloudWatch alarm to monitor the deployment health.
- D.Check AWS CloudTrail logs for the CodeDeploy API calls to see if permissions are missing.
Why B: The error message indicates that individual instances failed deployment, and the CodeDeploy agent logs on a failed instance contain detailed script output (e.g., AppSpec hooks like BeforeInstall, AfterInstall, ApplicationStart) that reveal the root cause, such as a missing dependency or incorrect file path. Reviewing these logs directly identifies script errors, which is the most targeted diagnostic step before considering infrastructure changes.
Variation 2. A company uses AWS CodeDeploy to deploy applications to an Auto Scaling group. The deployment fails because the new version of the application crashes the instances. The DevOps engineer needs the Auto Scaling group to automatically replace the unhealthy instances with the previous working version. Which deployment configuration should the engineer use?
easy- A.In-place deployment with a deployment group that has a failure threshold of 0.
- ✓ B.Blue/Green deployment with a load balancer to switch traffic only after health checks pass.
- C.Canary deployment that shifts 10% of traffic to the new version, then 100% after 10 minutes.
- D.Linear deployment that shifts 10% of traffic every 10 minutes.
Why B: A blue/green deployment with a load balancer health check ensures that the new (green) instances are validated before any traffic is routed to them. If the new version crashes, the health checks fail, the load balancer keeps traffic on the old (blue) instances, and the Auto Scaling group can automatically terminate the unhealthy green instances and replace them with the previous working version by reverting to the original launch configuration or template.
Variation 3. A DevOps engineer is designing a CI/CD pipeline for a microservices architecture on AWS. They want to use AWS CodeDeploy to deploy applications to an Auto Scaling group. The pipeline must ensure that only a small percentage of instances are updated at a time, and if health checks fail, the deployment is automatically rolled back. Which deployment configuration should be used?
hard- A.Blue/green deployment with a fixed number of instances.
- B.In-place deployment with 'CodeDeployDefault.AllAtOnce' configuration.
- C.In-place deployment with 'CodeDeployDefault.HalfAtATime' configuration.
- ✓ D.In-place deployment with 'CodeDeployDefault.OneAtATime' configuration and automatic rollback enabled.
Why D: The 'CodeDeployDefault.OneAtATime' configuration deploys to one instance at a time, ensuring only a small percentage of instances are updated simultaneously. Enabling automatic rollback triggers a rollback if health checks fail, meeting the requirement. Option D is correct. Option A (blue/green) is not in-place and typically updates all instances at once, not a small percentage. Option B (AllAtOnce) updates all instances simultaneously. Option C (HalfAtATime) updates half the instances, which is not as granular as OneAtATime and may not satisfy the 'small percentage' constraint.
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This DOP-C02 practice question is part of Courseiva's free Amazon Web Services certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the DOP-C02 exam.