DOP-C02 Configuration Management and IaC Practice Question
A company uses AWS OpsWorks for configuration management. They want to automate the installation of a custom agent on new EC2 instances. Which OpsWorks feature should they use?
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
✓
Use a custom Chef recipe in the layer's configuration to run the installation.
AWS OpsWorks allows you to define custom Chef recipes that run during specific lifecycle events (e.g., Setup) on new instances. By adding a custom recipe to the layer's configuration, you can automate the installation of a custom agent. Option B is incorrect because the layer's built-in configuration is for default OpsWorks settings, not custom agent installation. Option C is incorrect because custom JSON passes attribute data to recipes but does not execute installation commands directly. Option D is incorrect because storing scripts in a cookbook repository does not automatically run them; you must assign the recipe to the layer's lifecycle events.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
Use a custom Chef recipe in the layer's configuration to run the installation.
Why this is correct
A custom Chef recipe assigned to a layer's Setup lifecycle event is the correct way to run arbitrary installation steps. AWS OpsWorks automatically executes the Setup event on every instance as it finishes bootstrapping, and any recipe you attach to that event runs at that point. This allows you to invoke an `execute` resource or package installer for a third-party agent, beyond the built-in packages OpsWorks configures.
- ✗
Define the agent installation in the layer's built-in configuration.
Why it's wrong here
The built-in configuration of an OpsWorks layer only controls which AWS-managed packages and system services are installed for that layer's type (e.g., Apache for a PHP web layer). It does not provide a hook to run arbitrary commands or install third-party agents, because those built-in parameters map to recognized Chef attributes used by OpsWorks' own setup recipes. Custom actions like installing a monitoring agent require a custom recipe assigned to a lifecycle event.
- ✗
Use custom JSON to pass the installation commands.
Why it's wrong here
Custom JSON in OpsWorks supplies Chef node attributes to the stack's cookbooks; it is data consumed by recipes, not an execution engine. Passing commands as JSON would only make those strings available as attributes, and unless a recipe explicitly reads them and runs them via `execute`, they have no effect. This option conflates configuration data with imperative action, so it cannot trigger an installation by itself.
- ✗
Create a cookbook repository and upload the agent installation script.
Why it's wrong here
Creating a cookbook repository and uploading an installation script is only the first step; cookbooks in that repository must be associated with the stack and their recipes must be explicitly assigned to lifecycle events on a layer. Without that assignment, the script remains inert source code—the Chef client never runs it. A repository alone never executes anything; you need a recipe with an `execute` resource and a lifecycle hook to invoke that recipe on instance setup.
Go deeper
Related to this question
About these practice questions
This DOP-C02 question is part of Courseiva's 1,013-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 →
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.