DOP-C02 练习题

DOP-C02 题目讲解:保护数据库要挡住替换操作

DOP-C02 练习题讲解。答案 A。DBInstanceIdentifier 的变化可能触发资源替换,重点是阻止 Update:Replace,而不是提高数据库可用性。

DOP-C02 免费试练题 · 考证匠讲解

题目

A company manages its infrastructure using AWS CloudFormation. The company has a stack that provisions an Amazon RDS Multi-AZ database instance. During a routine stack update, a developer accidentally changes the DB instance identifier, which would cause CloudFormation to replace the database instance and result in data loss. Which preventive measure should a DevOps engineer implement to protect the database from accidental replacement?

A. Add a DeletionPolicy of Retain and enable termination protection on the CloudFormation stack. Additionally, configure a stack policy that denies Update:Replace actions on the RDS resource.
B. Enable Multi-AZ deployment for the RDS instance and create automated snapshots. Configure CloudFormation drift detection to alert on changes.
C. Move the RDS instance to a separate nested stack with termination protection enabled. This prevents the parent stack from modifying the database.
D. Create an IAM policy that denies cloudformation:UpdateStack permissions for all users. Require all changes to go through an approval pipeline.

答案

答案 A。DBInstanceIdentifier 的变化可能触发资源替换,重点是阻止 Update:Replace,而不是提高数据库可用性。

拆题

  • DBInstanceIdentifier 的变化可能触发资源替换,重点是阻止 Update:Replace,而不是提高数据库可用性。
  • 栈策略可以针对数据库逻辑资源拒绝替换,其他资源仍能正常更新。
  • DeletionPolicy 与终止保护分别管删除资源、删除栈;替换保留旧资源还应核对 UpdateReplacePolicy,不能混为一谈。

每个选项为什么对、为什么错

  • A(正确):栈策略明确拒绝数据库替换,命中事故的触发点。Retain 和终止保护增加删除防线,但两者单独不能阻止更新替换。
  • B:Multi-AZ 应对基础设施故障,快照帮助恢复,漂移检测发现差异;都没有拦住这次合法的模板更新。
  • C:嵌套栈仍可更新,终止保护不是更新保护,也不能保证父栈不修改其资源。
  • D:禁止所有用户更新栈会阻断正常工作;审批有价值,但题目要的是针对数据库替换的技术保护。

放到具体场景里

教学例子:模板把 billing-db 改成 billing-db-v2。先生成 change set,发现 RDS 的 Replacement 为 True;数据库逻辑资源上的 Deny Update:Replace 使执行失败,应用服务器的常规更新仍可进行。真正需要迁移时,应走受审查的例外流程并验证备份。

检查对象本例条件或动作结果与边界
DB 标识变更查看 change set发现替换风险
栈策略拒绝 Update:Replace阻止本次替换
Retain 策略分别核对删除与替换保留不是自动迁移数据

遇到同类题的判断顺序

  1. 检查变更:识别 RDS 是否需要替换。
  2. 限定资源:策略只保护数据库逻辑资源。
  3. 阻断执行:替换请求被拒绝,定位失败原因。
  4. 受控迁移:备份、恢复测试和批准后再执行必要迁移。
结论:可用性、备份和防误操作是三层不同保护,不能用 Multi-AZ 代替更新保护。

参考资料

继续练这门考试

同一门考试的免费试练题都附这样的完整讲解,做完再看讲解。