MLA-C01 Practice Question 47: Cross Stack References
AWS Certified Machine Learning Engineer – Associate (MLA-C01) · Test 5 · question 7 of 10
A platform team manages a CloudFormation stack called ml-network that creates the VPC, private subnets, and security groups for machine learning workloads. Several product teams deploy their own stacks, each creating a SageMaker AI model, endpoint configuration, and endpoint that must be placed in those subnets. Product teams have been copying subnet and security group IDs from the console into their templates by hand, and twice a mistyped ID, or an ID from the wrong VPC, broke a deployment. All stacks are in the same account and Region.
How should the teams share the network values between stacks?
Show answer and explanation
Answer:
CloudFormation cross-stack references are built for this situation. The platform stack lists the values in its Outputs section with an Export name, which makes them available to any stack in the same account and Region. Each product stack reads them with Fn::ImportValue, so the endpoint configurations take their IDs straight from the stack that created the network, and nobody copies them by hand. CloudFormation also refuses to delete the exporting stack or modify an exported value while another stack imports it, so the network cannot be pulled out from under a running endpoint (option D).
- A is wrong because it is the current manual process with the IDs moved to a different spot in the template. Someone still copies values by hand, and a review catches only some of the typos. - B is wrong because a nested stack creates its own resources. Each product team would deploy a *separate* VPC instead of sharing the platform network, which is the opposite of the goal. AWS says to use exports, not nested stacks, when sharing values with other stacks. - C is wrong because it rebuilds exports by hand with extra code to maintain, and CloudFormation cannot protect a value in an S3 file from being changed while stacks still depend on it.
Reference: Get exported outputs from a deployed CloudFormation stack