Q29 — AWS SOA-C02 Ch.1
Question 29 of 100 | ← Chapter 1
A company creates custom AMI images by launching new Amazon EC2 instances from an AWS CloudFormation template. It installs and configures necessary software through AWS OpsWorks, and takes images of each EC2 instance. The process of installing and configuring software can take between 2 to 3 hours, but at times, the process stalls due to installation errors. The SysOps administrator must modify the CloudFormation template so if the process stalls, the entire stack will fail and roll back. Based on these requirements, what should be added to the template?
- A. Conditions with a timeout set to 4 hours.
- B. CreationPolicy with a timeout set to 4 hours. ✓
- C. DependsOn with a timeout set to 4 hours.
- D. Metadata with a timeout set to 4 hours.
Correct Answer: B. CreationPolicy with a timeout set to 4 hours.
Explanation
AWS CloudFormation模板中,CreationPolicy用于指定资源创建成功的条件。当需要确保资源(如EC2实例)在特定时间内完成配置并发送成功信号时,CreationPolicy可配置超时时间。若超时未收到成功信号,资源创建失败并触发堆栈回滚。AWS文档指出,CreationPolicy适用于需要等待资源信号的情况,例如等待用户数据脚本执行完毕。选项B的CreationPolicy设置4小时超时,符合题意的故障回滚要求。其他选项如Conditions用于条件判断,DependsOn处理依赖顺序,Metadata提供额外信息,均不直接控制资源创建超时与回滚逻辑。