How to Reference Cross-Stack Resources in AWS CloudFormation?
Short answer
BD The developer's template does not use the ImportValue intrinsic function to refer to the subnets. The network team's template does not export the subnets in the Outputs section.
Question
Key Takeaways
The question evaluates cross-stack referencing mechanics, where test-takers commonly miss that resources must be explicitly exported in Outputs before they can be imported elsewhere.
This scenario tests cross-stack resource sharing in AWS CloudFormation. Community consensus confirms that combining Fn::ImportValue with exported stack outputs is mandatory for successful deployments.
Common mistake: Candidates often incorrectly choose Option A, assuming the Ref intrinsic function works across stacks. Ref only resolves values within the same stack, making it incapable of bridging separate templates.
Expert Analysis
Why the Answer Is Correct
Cross-stack references require explicit configuration on both templates. The source stack must publish values in its Outputs section using Export names, while the consumer stack must call Fn::ImportValue to retrieve them. Omitting either step breaks the dependency chain and halts the stack launch.
Why the Other Options Are Wrong
Option A fails because Ref is strictly scoped to the current stack context. Options C and E misapply Mappings, which store static key-value pairs and cannot dynamically link live infrastructure resources. CloudFormation simply does not support cross-stack lookups through Mappings or direct Ref calls.
Community Comment Notes
Verified discussion threads consistently validate that Fn::ImportValue pairs exclusively with exported Outputs for cross-stack communication. Comment [1] accurately explains that skipping the export or import mechanism guarantees deployment failure. Comment [3] further emphasizes that Fn::ImportValue remains the standard intrinsic function for this exact architectural pattern.
Official Reference
- https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference.html
- https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-crossstack-export.html
These links open the official vendor documentation in a new tab.
Exam Strategy
When reviewing cross-stack questions, always trace the data flow from export to import. Remember that Ref never crosses stack boundaries, allowing you to instantly discard similar distractors and focus on Fn::ImportValue paired with Outputs.
Community Votes
100% of anonymous learners picked answer BD. Votes are pick records left by other test-takers — they are not the verified answer.
Discussion 5 contributions
Compiled from public community threads and reader submissions, lightly edited for clarity. Handles and vote tallies are shown as recorded, and comments reflect the views of individual contributors.
From public community threads 5
-
KennethNg923 👍 3B. When referencing resources from another stack, the ImportValue function should be used. If the developer didn't use this, it would cause a failure when trying to reference the subnets. D. For a resource to be imported by another stack, it needs to be exported in the Outputs section of the original stack. If the network team didn't export the subnets, they can't be imported by the developer's stack.
-
Lucky4Life 👍 3https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference.html
-
preachr 👍 2The intrinsic function Fn::ImportValue returns the value of an output exported by another stack. You typically use this function to create cross-stack references.
-
mehanizator 👍 2ChatGPT: BD
-
65703c1 👍 1BD is the correct answer.
Reader comments & corrections
No reader corrections yet — spotted an error or have a note? Share it below.
Related Analysis
Practice All DVA-C02 Questions
Access 100 questions with complete answers and detailed explanations.
View Full DVA-C02 Practice Test →