DOP-C02 domain - 17% of the exam

Configuration Management and Infrastructure as Code

Configuration Management and Infrastructure as Code is 17% of the DOP-C02 exam. These are the objectives it covers, each with practice questions, with every answer explained.

The domain in numbers

50
Practice questions
6
Objectives
40
Medium
10
Hard

Where people go wrong

  • Applying the wrong protection to the lifecycle event

    The wrong answers reach for a protection that guards a different event. Termination protection blocks deleting the whole stack, and DeletionPolicy only governs a resource removed from the template or a deleted stack, so neither stops an in-place modification. Stack policies govern updates, not stack deletion. UpdateReplacePolicy decides the fate of the old resource during a replacement. Retain on DeletionPolicy keeps a database when the stack is deleted, Retain on UpdateReplacePolicy keeps it through a replacement, and a stack policy locks one logical ID.

    See it in a sample question
  • Confusing drift detection with a change set

    Drift detection and change sets look in different directions, and the wrong options swap them. Drift detection compares live resources to the configuration CloudFormation last provisioned, so it surfaces console edits made outside the pipeline but says nothing about a pending update. A change set compares a proposed template to the deployed stack and flags each resource that would be added, modified or replaced, through its Replacement field, before execution. A change set cannot find out-of-band edits, and linting or template validation never sees the deployed stack.

    See it in a sample question
  • Choosing the wrong reusable building block

    Nested stacks, CloudFormation modules, Service Catalog products and StackSets all sound like shared building blocks, and the wrong answers substitute one for another. Nested stacks fit one parent template composing child templates, referenced by URL through AWS::CloudFormation::Stack resources, into a single deployment. A module registered as a private type in the CloudFormation registry is declared like a native resource, and publishing a new version updates it centrally. A Service Catalog product is launched from a catalogue, and a StackSet pushes whole stacks across accounts.

    See it in a sample question
  • Treating StackSets and Service Catalog as interchangeable

    StackSets and Service Catalog both reach many accounts, and the wrong answers swap their jobs. A service-managed StackSet targeting an organisational unit with automatic deployment pushes a stack into every member account, including accounts that join later. Service Catalog provides governed self-service: a portfolio shared to the unit, versioned products, and a launch constraint supplying an IAM role. Its launches start per account, while StackSets are started by a central operator, so neither replaces the other.

    See it in a sample question
  • Using a one-off command where desired state is needed

    Run Command and State Manager are swapped in the wrong answers. Run Command performs a one-off action on the instances chosen at invocation time, so it cannot reapply a configuration after drift or reach instances launched later, and it gives no native per-instance compliance status. A State Manager association reapplies a document on a schedule to tag-matched instances and records compliance. The reverse mistake applies State Manager to an incident restart, where Run Command supplies a concurrency of 10 and an error threshold of 5.

    See it in a sample question

Objectives in this domain

What to study

The official documents this domain's practice questions cite most.

Sample questions from this domain

Free sampleConfiguration Management and Infrastructure as Codemedium

An engineer manages a stateful "Amazon RDS" database inside an "AWS CloudFormation" stack that also defines networking and compute. The business requires that if the entire stack is ever deleted, the database must survive so a final snapshot and the data are not lost, while every other resource should be removed normally. The engineer wants this behaviour expressed in the template itself rather than relying on a manual pre-delete step. Which configuration BEST achieves this?

  • AEnable termination protection on the stack so that an accidental stack deletion is blocked and the database along with all other resources is preserved.
  • BAdd a stack policy that denies the "Delete" action on the database logical ID so the resource cannot be removed when the stack is deleted.
  • CSet an "UpdateReplacePolicy" of "Retain" on the database so the resource is preserved whenever the stack is deleted by an operator.
  • DSet a "DeletionPolicy" of "Retain" on the database resource so it is kept when the stack is deleted while the remaining resources are removed normally. Correct
Apply DeletionPolicy Retain to keep a specific stateful resource when its CloudFormation stack is deleted. DeletionPolicy is a resource-level attribute that controls the fate of a resource when it is removed from a stack or the stack is deleted; setting it to Retain leaves the resource intact and outside CloudFormation management, while resources without the attribute are deleted as normal, giving the selective survival the business demands without any manual pre-delete action.

Why A is wrong: Termination protection blocks deletion of the whole stack rather than preserving one resource on an intended delete, and it keeps everything, not just the database, so it does not match the selective-retention requirement.

Why B is wrong: Stack policies govern updates to a running stack, not stack deletion, so a deny on Delete in a stack policy does not protect a resource when the whole stack is being torn down.

Why C is wrong: UpdateReplacePolicy controls what happens to the old resource when an update forces a replacement, not what happens on stack deletion, so it does not preserve the database when the stack is deleted.

Why D is correct: A DeletionPolicy of Retain on a single logical resource tells CloudFormation to leave that resource in place when the stack is deleted while still removing resources that lack the policy, which is precisely the selective behaviour required.

Free sampleConfiguration Management and Infrastructure as Codemedium

An engineer must apply a template change to a busy production database stack managed by "AWS CloudFormation". Leadership requires sign-off on exactly which resources will be added, modified or replaced before anything happens, because an unintended replacement of the database would cause downtime. The engineer wants the deployment pipeline to surface that impact for review and only proceed once approved. Which mechanism MOST directly provides this preview-then-approve workflow?

  • ARun "cfn-lint" against the template in the pipeline so that static validation reports any resource that would be replaced before the update is applied.
  • BEnable drift detection on the stack before the update so that the pipeline reports differences between the template and the deployed resources for review.
  • CCreate a change set for the update, have the pipeline pause for approval after the change set lists the affected resources, then execute the change set once approved. Correct
  • DDeploy the change directly with a stack policy that denies replacement on the database, relying on the failed update to reveal whether a replacement was attempted.
Use a CloudFormation change set to preview the resource-level impact of an update and gate execution behind manual approval. A change set is a description of the changes CloudFormation would make, including which resources are added, modified or replaced, computed without touching the live stack; pausing the pipeline between change set creation and execution gives reviewers the exact impact and a controlled approval gate.

Why A is wrong: Linting catches template syntax and best-practice issues but cannot compute the live resource-level difference against the deployed stack, so it cannot tell reviewers which resources will be replaced.

Why B is wrong: Drift detection compares deployed resources to the last known template, not a proposed new template, so it shows existing drift rather than the impact of the pending update.

Why C is correct: A change set computes the exact resource-level diff including replacements before any change is applied, and execution is a separate step, which is precisely the preview-then-approve flow leadership requires.

Why D is wrong: A stack policy can block a replacement but only at apply time as a failure, which gives no advance preview for human sign-off and risks a disruptive rolled-back update.

Free sampleConfiguration Management and Infrastructure as Codemedium

A large "AWS CloudFormation" template has grown past 600 resources and repeatedly fails to update because it exceeds template and resource limits, and several teams need to own discrete layers such as networking, security and application tiers independently. The platform team wants reusable, versioned building blocks that a single parent template can compose and update together as one deployment. Which design BEST meets these goals?

  • ASplit the layers into separate independent stacks and wire them together at deploy time using exported output values consumed through "Fn::ImportValue".
  • BConvert the template into a "StackSet" and deploy each layer as a separate stack instance across the target account so the resource count per stack drops.
  • CPublish each layer as a product in "AWS Service Catalog" and let teams launch the products on demand to assemble the overall environment.
  • DRefactor the layers into nested stacks referenced by "AWS::CloudFormation::Stack" resources in a parent template, with child templates stored in "Amazon S3". Correct
Use nested stacks to decompose a large template into reusable child templates composed and deployed by one parent stack. Nested stacks are created by declaring AWS::CloudFormation::Stack resources whose TemplateURL points at child templates in Amazon S3; the parent treats each child as a single resource, so layers can be owned and versioned separately yet provisioned and updated together, while staying under per-template resource limits.

Why A is wrong: Cross-stack exports do decouple layers, but exported values become locked and hard to change, and the stacks are deployed separately rather than as one composed unit, missing the single-deployment requirement.

Why B is wrong: StackSets replicate a stack across many accounts or Regions; they solve multi-account roll-out, not composing layered building blocks into one parent deployment in a single account.

Why C is wrong: Service Catalog governs self-service provisioning of approved products, which is tempting for team ownership but does not give a parent template that composes and updates the layers as one coordinated deployment.

Why D is correct: Nested stacks let a parent template compose versioned child templates as reusable building blocks and update them as one deployment, which addresses both the size limits and independent layer ownership.

Free sampleConfiguration Management and Infrastructure as Codemedium

An organisation must deploy an identical security baseline stack, including config rules and an IAM role, into more than 80 accounts inside its "AWS Organizations" structure, and any new account that joins a target organisational unit must receive the baseline automatically without a manual step. The team wants the lowest ongoing operational overhead. Which "AWS CloudFormation" capability BEST satisfies this requirement?

  • AUse a "StackSet" with service-managed permissions targeting the organisational unit and enable automatic deployment to accounts that join the unit. Correct
  • BCreate a single template and run a pipeline that assumes a cross-account role to deploy a separate stack into each member account in turn.
  • CPublish the baseline as nested stacks and reference them from a parent template that each account administrator deploys into their own account.
  • DShare the template through "AWS Service Catalog" as a portfolio so each account team can launch the baseline product when their account is created.
Use a service-managed StackSet with automatic deployment to an organisational unit to roll out and auto-onboard a baseline across many accounts. StackSets extend a single template to many accounts and Regions; with service-managed permissions integrated with AWS Organizations and automatic deployment enabled on the target organisational unit, CloudFormation creates the stack instances everywhere and provisions the baseline into any account that later joins the unit, eliminating per-account manual work.

Why A is correct: A service-managed StackSet targeting an organisational unit with automatic deployment provisions the baseline across all member accounts and onboards new accounts automatically, giving the lowest ongoing overhead.

Why B is wrong: A loop of per-account stack deployments works but must be maintained and re-run for every new account, so it carries the manual and operational overhead the requirement rules out.

Why C is wrong: Nested stacks compose resources within a single account and still require each administrator to deploy manually, so they do not provide automatic multi-account roll-out for new accounts.

Why D is wrong: Service Catalog enables governed self-service launches, which is tempting for standardisation, but the launch is still initiated per account and is not triggered automatically when an account joins the unit.

Free sampleConfiguration Management and Infrastructure as Codemedium

A compliance team requires that a specific host firewall rule set stays present on every "Amazon EC2" instance in a tagged production group managed by "AWS Systems Manager". Auditors must be able to see, for each instance, whether it currently matches the approved rule set, and any instance that drifts must be corrected automatically. The team wants this handled natively by "Systems Manager". Which approach BEST satisfies both the reporting and the auto-correction?

  • ARun "Run Command" on a recurring "Amazon EventBridge" schedule to reapply the firewall rules and push the per-instance results to "Amazon CloudWatch Logs" for the auditors.
  • BCreate a "State Manager" association for the tagged group that applies the firewall configuration document on a schedule, then read the association compliance status per instance for the audit evidence. Correct
  • CUse "Patch Manager" to define the firewall rules as a patch baseline and report compliance, scanning the production group on a maintenance window each day.
  • DStore the approved firewall rules in "Parameter Store" and have a boot script on each instance read the parameter and apply the rules when the instance starts.
Use a State Manager association to both auto-remediate configuration drift and provide native per-instance compliance status for auditors. State Manager associations apply a configuration document on a recurring schedule and report each instance as compliant or non-compliant based on the last run; this single mechanism corrects drift by reapplying the approved firewall rules and surfaces the per-instance status auditors need without a separate reporting pipeline.

Why A is wrong: Scheduling Run Command can reapply the rules and log output, but it does not produce a native per-instance compliance status and requires building the reporting pipeline yourself, so it is more work than the association approach.

Why B is correct: A State Manager association reapplies the firewall document on schedule to correct drift automatically and records compliant or non-compliant status per instance, giving auditors native evidence and the auto-correction together.

Why C is wrong: Patch Manager and baselines are designed for operating-system and application patches, not arbitrary host firewall rules, so it is the wrong tool and would not express or remediate the firewall configuration.

Why D is wrong: A boot script applies the rules at start-up and Parameter Store centralises them, but nothing detects or corrects drift on a running instance, and there is no per-instance compliance view for auditors.

Other domains in this exam

See also the DOP-C02 cert hub, the study guide, and the cheat sheet.

Examworthy is not affiliated with or endorsed by Amazon Web Services. Original, blueprint-aligned practice material only.