Courseiva

DOP-C02 Configuration Management and IaC Practice Question

A DevOps engineer is using AWS OpsWorks for configuration management. They need to ensure that custom recipes are applied to all instances in a layer in a specific order. What should the engineer do?

⚠ Common exam trap

Watch out — candidates often confuse OpsWorks lifecycle events with Chef's include_recipe directive, assuming that ordering within a wrapper recipe is sufficient, when OpsWorks actually enforces order through lifecycle event assignments.

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

✓

Assign the recipes to the appropriate lifecycle events in the layer configuration.

AWS OpsWorks uses lifecycle events (Setup, Configure, Deploy, Undeploy, Shutdown) to control when custom recipes run on instances within a layer. By assigning recipes to the appropriate lifecycle events in the layer configuration, the engineer ensures they execute in the defined order for that event across all instances in the layer, which is the native mechanism for ordering in OpsWorks.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✓

    Assign the recipes to the appropriate lifecycle events in the layer configuration.

    Why this is correct

    Assigning recipes to lifecycle events is the native OpsWorks Stacks mechanism for ordered configuration. Each layer exposes five lifecycle events (Setup, Configure, Deploy, Undeploy, Shutdown), and recipes attached to an event execute in the order listed within that event's configuration. This provides a predictable, sequential run across all instances in the layer, ensuring that prerequisites and dependencies are satisfied. Because OpsWorks orchestrates these events centrally, this is the only option that reliably enforces both per-instance ordering and layer-wide sequencing.

  • ✗

    Use AWS CloudFormation Init with cfn-init to order the scripts.

    Why it's wrong here

    AWS CloudFormation Init with cfn-init operates within the CloudFormation resource lifecycle, not within the OpsWorks agent's orchestration. OpsWorks instances are managed by an agent that runs Chef recipes during its own lifecycle events, and cfn-init has no integration with those events. Introducing CloudFormation Init would require abandoning OpsWorks layer management and building a separate CloudFormation stack, which does not address the need to order recipes within OpsWorks. Therefore, this approach is architecturally disjointed and cannot control OpsWorks recipe execution order.

  • ✗

    Include all recipes in a single wrapper recipe and use include_recipe with the desired order.

    Why it's wrong here

    A wrapper recipe using include_recipe still executes each included recipe in the order written, but OpsWorks applies recipes per layer according to the layer's custom recipe slots and lifecycle events, so the wrapper's internal ordering does not override how the layer sequences setup, configure, deploy, undeploy and shutdown. It is tempting because Chef itself honours include_recipe order, yet the layer configuration is what governs execution order across instances.

  • ✗

    Add the recipes to the instance's user data script.

    Why it's wrong here

    User data scripts execute during instance boot, before the OpsWorks agent is installed or started, so they run far too early to order recipes. OpsWorks recipes are invoked later by the agent in response to lifecycle events, and user data has no knowledge of layer state or event progression. Adding recipes to user data bypasses OpsWorks management entirely, meaning the recipes would not be registered with the agent and their order relative to OpsWorks operations would be undefined. The supported way to control recipe order is through lifecycle event assignments, not boot-time user data.

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 →

How Courseiva writes practice questions · Editorial policy

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.