DOP-C02 Configuration Management and IaC Practice Question
A company uses AWS CloudFormation to manage infrastructure. They have a template that creates an Amazon RDS DB instance. The template includes a 'DeletionPolicy' attribute set to 'Retain' on the DB instance resource. The DevOps team deletes the stack. Later, they notice that the DB instance still exists and is incurring costs. What is the MOST cost-effective way to remove the DB instance?
⚠ Common exam trap
A common mix-up: candidates assume CloudFormation can still manage or modify a resource after the stack is deleted, but once the stack is gone, CloudFormation has no control, and the only way to remove the resource is through direct manual deletion.
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
✓
Manually delete the DB instance using the AWS Management Console or AWS CLI.
The DB instance was created with a DeletionPolicy of 'Retain', which explicitly instructs CloudFormation to preserve the resource when the stack is deleted. Once the stack is deleted, CloudFormation no longer manages the DB instance, so the only way to remove it and stop costs is to manually delete it via the AWS Management Console or AWS CLI. This is the most cost-effective approach as it directly addresses the orphaned resource without unnecessary overhead.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Create a new CloudFormation stack that includes the same DB instance but with a DeletionPolicy of 'Delete', then delete that stack.
Why it's wrong here
Creating a new stack that references the same DB instance is invalid because CloudFormation cannot manage a resource that is already owned by another stack unless you first import it. Even if you imported it, setting DeletionPolicy to Delete would only apply when that new stack is deleted, and this approach is far more complex than simply deleting the retained resource directly.
- ✓
Manually delete the DB instance using the AWS Management Console or AWS CLI.
Why this is correct
Because the original stack was deleted with a DeletionPolicy that did not delete the DB instance, the database was left as an unmanaged, orphaned resource outside CloudFormation. Manually deleting it through the AWS Management Console or with the aws rds delete-db-instance CLI command is the simplest and most cost-effective way to remove it, since no stack resources or templates remain to account for.
- ✗
Use the 'aws cloudformation delete-change-set' command to remove the resource.
Why it's wrong here
The aws cloudformation delete-change-set command only removes an existing change set, which is a preview of stack changes; it has no ability to delete stack resources. Change sets are used to review the impact of an update before executing it, so running this command would have no effect on any live resource, including the orphaned DB instance.
- ✗
Update the stack: change the DeletionPolicy to 'Delete' and then delete the stack again.
Why it's wrong here
Updating the stack to change DeletionPolicy to Delete and then deleting the stack again would eventually remove the DB instance, but this requires an extra update operation and assumes the stack still exists. That approach is not the most cost-effective because it incurs additional API calls and orchestration time, whereas a direct manual deletion achieves the same result with a single action and no intermediate stack state.
Go deeper
Related to this question
About these practice questions
This DOP-C02 question is part of Courseiva's 1,298-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.