DOP-C02 Configuration Management and IaC Practice Question
A team is using AWS CodeDeploy to deploy an application to EC2 instances. They want to ensure that if a deployment fails, the instances are automatically rolled back to the previous version. What should they configure?
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
✓
Enable automatic rollback in the deployment group settings.
CodeDeploy supports automatic rollback configuration. When enabled, if a deployment fails, CodeDeploy automatically redeploys the last successful revision. Option A is wrong because a hook is a lifecycle event, not a rollback mechanism. Option B is wrong because a deployment group contains instances but does not have a rollback setting. Option C is wrong because a deployment configuration specifies traffic routing and failure thresholds, not automatic rollback.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Add a BeforeBlockTraffic hook to the AppSpec file to run a rollback script.
Why it's wrong here
Adding a BeforeBlockTraffic hook to the AppSpec file only registers a script to run during a deployment lifecycle event, specifically just before traffic is blocked. This hook is part of the current deployment's sequencing and cannot monitor the deployment for failures or trigger a redeployment of a prior revision. Automatic rollback is a deployment group setting that redeploys the previous successful revision when a deployment fails—running a script at a lifecycle event does not implement this behavior.
- ✗
Set the deployment configuration to 'CodeDeployDefault.OneAtATime' for a gradual deployment.
Why it's wrong here
CodeDeployDefault.OneAtATime is a deployment configuration that controls the pace of traffic shifting by deploying to one instance at a time and waiting for health checks to pass before continuing. This only affects the rollout strategy during a deployment; it has no effect on post-failure behavior. Even with gradual traffic shifting, a failed deployment will not automatically revert to a previous version unless automatic rollback is explicitly enabled in the deployment group's settings.
- ✗
Configure the deployment group to use the same Auto Scaling group for rollback.
Why it's wrong here
Configuring the deployment group to use the same Auto Scaling group for rollback is a misapplication of concepts: the deployment group already targets the Auto Scaling group, and rollback is not a separate scaling operation. Automatic rollback in CodeDeploy does not rely on Auto Scaling group configuration; it redeploys the last successful revision to the same target fleet. There is no 'same Auto Scaling group' rollback option because rollback is a deployment action, not an infrastructure change.
- ✓
Enable automatic rollback in the deployment group settings.
Why this is correct
Enabling automatic rollback in the deployment group settings is the correct native mechanism for requiring CodeDeploy to redeploy the last successful revision when a deployment fails. This feature can also be configured to roll back when a deployment hits a limit or when a CloudWatch alarm triggers, making it flexible for various failure scenarios. It is precisely what the team needs to achieve automatic recovery without manual intervention.
Go deeper
Related to this question
About these practice questions
Courseiva writes every DOP-C02 question from scratch — 1,298 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
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.