DOP-C02 Configuration Management and IaC Practice Question
A company uses AWS OpsWorks to manage a set of EC2 instances. They need to ensure that a custom recipe runs on all instances during the 'Configure' lifecycle event. What is the correct way to achieve this?
⚠ Common exam trap
Candidates often confuse the one-time execution of user data scripts (Option C) with the recurring, event-driven nature of OpsWorks lifecycle events, or mistakenly think CloudFormation (Option A) or CodeDeploy (Option D) can directly manage OpsWorks recipe execution.
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
✓
Upload the recipe to a custom cookbook repository and assign it to the 'Configure' lifecycle event in the stack settings.
In AWS OpsWorks, lifecycle events (such as Configure) are tied to layers, not individual instances. To run a custom recipe on all instances during the Configure event, you must upload the recipe to a custom cookbook repository (e.g., S3 or Git) and then assign that recipe to the Configure lifecycle event in the stack's layer settings. This ensures OpsWorks Chef runs the recipe on every instance in that layer whenever the Configure event fires (e.g., after scaling or instance state changes).
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Modify the stack's CloudFormation template to include the recipe.
Why it's wrong here
An OpsWorks stack is not itself defined by a CloudFormation template; it is a service-managed resource configured through the OpsWorks console, CLI, or API. While CloudFormation can provision some OpsWorks resources, modifying a template does not attach a custom Chef recipe to an existing stack's Configure lifecycle event—you must configure the custom cookbook source and recipe assignments in the OpsWorks stack or layer settings.
- ✓
Upload the recipe to a custom cookbook repository and assign it to the 'Configure' lifecycle event in the stack settings.
Why this is correct
Upload the cookbook containing the recipe to a repository (S3, Git, or HTTP), then in the OpsWorks stack settings enable 'Use custom Chef cookbooks' and add the recipe name to the Configure lifecycle event. The OpsWorks agent then executes that recipe on every Configure event, which fires when any instance enters the online state or when instances are added to or removed from the stack. This is the documented, supported method for attaching custom configuration logic to OpsWorks lifecycle events.
- ✗
Add the recipe commands to the instance's user data script.
Why it's wrong here
EC2 user data runs only once at initial instance launch, during the first boot; it cannot be re-executed when a Configure lifecycle event occurs later. Configure events repeat throughout an instance's lifetime, so any recipe commands placed in user data will not run on subsequent stack topology changes. OpsWorks lifecycle recipes are executed by the OpsWorks agent independently of user data, so this approach does not satisfy the requirement.
- ✗
Use AWS CodeDeploy to trigger the recipe during the Configure event.
Why it's wrong here
AWS CodeDeploy is a separate application-deployment service that uses an AppSpec file with lifecycle hooks such as BeforeInstall and AfterInstall, and it targets EC2 instances, on-premises servers, or Lambda functions. It has no concept of OpsWorks lifecycle events and cannot invoke a Chef recipe during the Configure event. The correct integration point is OpsWorks custom cookbooks assigned to the Configure lifecycle event in the stack or layer settings.
Quick reference
AWS S3 Storage Class Comparison
| Storage Class | Min Duration | Retrieval | Use Case |
|---|---|---|---|
| S3 Standard | None | Immediate | Frequently accessed data |
| S3 Standard-IA | 30 days | Immediate | Infrequent access, rapid retrieval |
| S3 One Zone-IA | 30 days | Immediate | Non-critical infrequent data |
| S3 Intelligent-Tiering | None | Immediate–hours | Unknown or changing access patterns |
| S3 Glacier Instant | 90 days | Milliseconds | Archive with instant retrieval |
| S3 Glacier Flexible | 90 days | Minutes–hours | Archive, flexible retrieval |
| S3 Glacier Deep Archive | 180 days | Hours | Long-term compliance archive |
Go deeper
Related to this question
About these practice questions
One of 1,298 original DOP-C02 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. 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.