How to Reference Cross-Stack Resources in AWS CloudFormation?

A developer at a company writes an AWS CloudFormation template. The template refers to subnets that were created by a separate AWS CloudFormation template that the company's network team wrote. When the developer attempts to launch the stack for the first time, the launch fails. Which template coding mistakes could have caused this failure? (Choose two.)

  1. The developer's template does not use the Ref intrinsic function to refer to the subnets.
  2. The developer's template does not use the ImportValue intrinsic function to refer to the subnets. Source Reference Answer
  3. The Mappings section of the developer's template does not refer to the subnets.
  4. The network team's template does not export the subnets in the Outputs section. Source Reference Answer
  5. The network team's template does not export the subnets in the Mappings section.

Community Votes

BD
100%

100% of anonymous learners picked answer BD. Votes are pick records left by other test-takers — they are not the verified answer.

Community Insight

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.

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.

Community Discussion (5 comments)

preachr 👍 2 Selected: BD
The intrinsic function Fn::ImportValue returns the value of an output exported by another stack. You typically use this function to create cross-stack references.
KennethNg923 👍 3 Selected: BD
B. 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.
65703c1 👍 1 Selected: BD
BD is the correct answer.
Lucky4Life 👍 3 Selected: BD
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference.html
mehanizator 👍 2 Selected: BD
ChatGPT: BD

Comments & Corrections

No comments yet — spotted an error or have a note? Share it below.

Log in to comment, report an error, or add a note about this question.

Submitted for moderation before publishing. Keep it helpful and respectful.

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

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.

Related Analysis

Practice All DVA-C02 Questions

Access 100 questions with complete answers and detailed explanations.

View Full DVA-C02 Practice Test →

← Back to DVA-C02 Study Guide