AWS Developer DVA-C02 · Deployment · medium
In an AWS CloudFormation template, Stack A (NetworkStack) creates a production VPC and wants to export the VpcId so that Stack B (AppStack, in the same AWS account and region) can reference that VpcId dynamically without hardcoding vpc-0abc12345. Which pair of CloudFormation intrinsic functions / sections should be used in Stack A and Stack B?
Published · Last updated · checked before publication — how we verify questions
Options
Answer: D. Export the value in Stack A's Outputs and call Fn::ImportValue in Stack B
To share values across CloudFormation stacks in the same account and region, Stack A declares an Outputs entry with an Export: Name (!Sub "${AWS::StackName}-VpcId"), and Stack B imports that exported value using the Fn::ImportValue (!ImportValue) intrinsic function.
Why the other options are wrong
- A. Use Fn::Base64 in Stack A's Parameters and Fn::GetAZs in Stack B across regions — Fn::Base64 encodes UserData strings and Fn::GetAZs lists Availability Zones; neither shares cross-stack outputs.
- B. Use DeletionPolicy: Retain in Stack A's Resources and CreationPolicy in Stack B — DeletionPolicy and CreationPolicy govern resource lifecycle behavior, not cross-stack variable references.
- C. Use Fn::Split in Stack A's Mappings and Fn::Cidr in Stack B for subnet IP parsing — Fn::Split and Fn::Cidr manipulate strings and IP blocks locally within a single template.
More Deployment questions
- An AWS CloudFormation stack provisions an Amazon RDS production database and an Amazon S3 audit bucket. If a junior…
- A developer is writing a buildspec.yml file for AWS CodeBuild that compiles a Node.js TypeScript service, runs unit…
- A serverless team uses AWS SAM (template.yaml) and AWS CodeDeploy to deploy a new version of an AWS Lambda function…
- An application runs on AWS Elastic Beanstalk across a fleet of 6 EC2 instances behind an Application Load Balancer…
AWS and Amazon Web Services are trademarks of Amazon.com, Inc. PrepIQ Hub is not affiliated with, endorsed by, or sponsored by Amazon Web Services.