How to Reference Cross-Stack Resources in AWS CloudFormation?

DVA-C02 By islever Editorial Last updated

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

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. Correct 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. Correct Answer
  5. The network team's template does not export the subnets in the Mappings section.

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

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

BD
100%

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

  1. KennethNg923 👍 3
    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.
  2. Lucky4Life 👍 3
    https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference.html
  3. preachr 👍 2
    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.
  4. mehanizator 👍 2
    ChatGPT: BD
  5. 65703c1 👍 1
    BD is the correct answer.

Reader comments & corrections

No reader corrections 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.

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