Q67 — AWS SOA-C02 Ch.1
Question 67 of 100 | ← Chapter 1
A company uses an AWS CloudFormation template to provision an Amazon EC2 instance and an Amazon RDS DB instance. A SysOps administrator must update the template to ensure that the DB instance is created before the EC2 instance is launched. What should the SysOps administrator do to meet this requirement?
- A. Add a wait condition to the template. Update the EC2 instance user data script to send a signal after the EC2 instance is started.
- B. Add the DependsOn attribute to the EC2 instance resource, and provide the logical name of the RDS resource. ✓
- C. Changethe order of the resources in the template so that the RDS resource is listed before the EC2 instance resource.
- D. Create multiple templates. Use AWS CloudFormation StackSets to wait for one stack to complete before the second stack is created.
Correct Answer: B. Add the DependsOn attribute to the EC2 instance resource, and provide the logical name of the RDS resource.
Explanation
AWS CloudFormation通过资源的依赖关系控制创建顺序。DependsOn属性可显式声明资源依赖,确保目标资源完成后才创建当前资源。AWS官方文档指出,DependsOn用于覆盖默认依赖逻辑,直接指定资源顺序。选项B通过向EC2实例添加DependsOn属性并指向RDS资源,强制RDS实例优先创建。选项A的等待条件适用于外部信号场景,与资源间顺序无关;选项C的模板顺序不影响实际部署逻辑;选项D的StackSets引入不必要的复杂度。