You have two AWS CloudFormation stacks: the first creates a VPC and its networking components (subnets, route tables, internet gateway), and the second deploys application resources into that VPC. The second template must reference the resources created by the first with minimal manual effort. How should this be done?
Choose an answer
Tap an option to check your answer.
Correct answer: Add an export field to the outputs of the first template and import the values in the second template..
Why this is the answer
The correct approach is to add an Export field to the outputs of the first CloudFormation template and then use the Fn::ImportValue function in the second template to reference those exported values. This allows for clean, cross-stack referencing of resources, ensuring that the second stack can automatically retrieve the necessary VPC IDs, subnet IDs, etc., without manual intervention. Creating a custom resource to query the stack is overly complex and unnecessary for this common task. CloudFormation provides built-in mechanisms for this. Creating a mapping in the first template is not designed for cross-stack resource referencing; mappings are for conditional parameter values within a single template. Inputting resource names as parameters would require manual updates to the second template every time the first stack is deployed or changed, defeating the goal of minimal manual effort.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed