Jeff’s Note #
Unlike generic exam dumps, ADH analyzes this scenario through the lens of a Real-World Lead Developer.
For AWS DVA-C02 candidates, the confusion often lies in how to properly reference resources created in another CloudFormation stack. In production, this is about knowing exactly when to use Export/ImportValue vs. Ref, and ensuring resource sharing is configured so stacks don’t fail to launch due to unresolved references. Let’s drill down.
The Certification Drill (Simulated Question) #
Scenario #
At NexGen Apps, the development team is building a new CloudFormation template to deploy an application stack. The networking team previously deployed a separate CloudFormation stack that created and manages VPC subnets. The developer tries to launch the application stack referencing these subnets from the network stack but the deployment fails on the first attempt.
The Requirement #
Identify which template coding mistakes could have caused the failure to launch the stack. (Choose two.)
The Options #
- A) The developer’s template does not use the Ref intrinsic function to refer to the subnets.
- B) The developer’s template does not use the ImportValue intrinsic function to refer to the subnets.
- C) The Mappings section of the developer’s template does not refer to the subnets.
- D) The network team’s template does not export the subnets in the Outputs section.
- E) The network team’s template does not export the subnets in the Mappings section.
Google adsense #
leave a comment:
Correct Answer #
B and D
Quick Insight: The Developer Imperative #
- CloudFormation cross-stack references require the network stack to explicitly export resources via the Outputs section using the
Exportkey, and the dependent stack must use theImportValueintrinsic function to pull those exported values.- Using
Refalone cannot reference resources from a separate stack. Mappings are unrelated to resource referencing. Without export declarations in the producing stack, imports will fail.
Content Locked: The Expert Analysis #
You’ve identified the answer. But do you know the implementation details that separate a Junior from a Senior?
The Expert’s Analysis #
Correct Answer #
B) The developer’s template does not use the ImportValue intrinsic function to refer to the subnets.
D) The network team’s template does not export the subnets in the Outputs section.
The Winning Logic #
In AWS CloudFormation, cross-stack references must be enabled through explicit export/import mechanisms—a value exported from one stack is consumed by another using the ImportValue intrinsic function. This means:
- The producer stack (network stack) needs to declare the subnet IDs as Outputs with the
Exportfield to make them accessible externally. - The consumer stack (developer’s app stack) must use
ImportValuereferencing the export name to retrieve the subnet IDs at deployment time.
Using just Ref will only work within the same stack or nested stacks and will not resolve values across independent stacks.
Mappings have nothing to do with dynamic cross-stack lookups—Mappings are static key-value data structures inside a single template, not dynamic resource references. Similarly, Export declarations belong in the Outputs section, not the Mappings section.
The Trap (Distractor Analysis): #
- Why not A?
Refworks only inside the same stack or nested stacks; it cannot resolve references across independently deployed stacks. - Why not C? The Mappings section is for YAML mapping data and does not connect to resources externally. Ignoring this causes confusion but is not a direct cause of failure.
- Why not E? Export declarations aren’t placed in the Mappings section, but in Outputs. This is a misunderstanding of CloudFormation template structure.
The Technical Blueprint #
Developer CLI snippet for Importing Exported Values: #
Resources:
AppSubnet:
Type: AWS::EC2::Subnet
Properties:
SubnetId: !ImportValue NexGenNetworkStack-PublicSubnetExports
To check exports in CLI:
aws cloudformation list-exports
To export a value in the network stack’s Outputs:
Outputs:
PublicSubnetExport:
Value: !Ref PublicSubnetId
Export:
Name: NexGenNetworkStack-PublicSubnetExports
The Comparative Analysis #
| Option | API Complexity | Performance Impact | Use Case |
|---|---|---|---|
| A | Incorrect Ref usage | Fails cross-stack reference | Works internally only |
| B (Correct) | Uses ImportValue API | Enables cross-stack share | Essential for cross-stack |
| C | Mapping misuse | No effect on runtime | Not related to resource ref |
| D (Correct) | Requires Output Export | Enables export/import chain | Mandatory for sharing |
| E | Misplaced Export | Template invalid structure | Export not in Mappings |
Real-World Application (Practitioner Insight) #
Exam Rule #
For the exam, always pick ImportValue when you see references to resources from another CloudFormation stack.
Real World #
In real deployments, teams often split network infrastructure and app stacks for flexibility and reuse. Correct use of Export/ImportValue ensures clean decoupling and safe resource sharing without hardcoding values or duplicating resources.
(CTA) Stop Guessing, Start Mastering #
Disclaimer
This is a study note based on simulated scenarios for the AWS DVA-C02 exam.