Q94 — AWS SOA-C02 Ch.1

Question 94 of 100 | ← Chapter 1

A SysOps administrator is creating two AWS CloudFormation templates. The first template will create a VPC with associated resources, such as subnets, route tables, and an internet gateway. The second template will deploy application resources within the VPC that was created by the first template. The second template should refer to the resources created by the first template. How can this be accomplished with the LEAST amount of administrative effort?

Correct Answer: A. Add an export field to the outputs of the first template and import the values in the second template.

Explanation

AWS CloudFormation模板间引用资源时,使用输出导出和导入功能是实现跨堆栈引用的推荐做法。根据AWS文档,当需要共享资源ID(如VPC、子网)时,在源模板中使用`Outputs`并添加`Export`字段,允许其他模板通过`Fn::ImportValue`函数直接导入这些值。该方法无需手动输入或自定义代码,简化了资源依赖管理。选项B涉及自定义资源会增加复杂性,选项C的映射无法动态获取资源ID,选项D需要手动传递参数,均不符合最小管理代价的要求。正确答案基于AWS官方跨堆栈引用机制。