Your team uses a CloudFormation stack for an application.
There are a large amount of AWS resources created in the stack, including Auto Scaling groups, Lambda functions, Security groups and Route 53 domain names, which make the CloudFormation template hard to maintain.
You want to divide the template into several parts and inherit the resources.
In the meantime, you still want to manage all resources in a single stack.
Which of the following options is the most appropriate?
Click on the arrows to vote for the correct answer
A. B. C. D.Correct Answer: B.
Option A is incorrect because the option does not mention how to share resources between different parts, and all resources are still placed into a single template as before.
Option B is CORRECT because, with nested stacks, the whole stack is divided into different stacks.
And the outputs from one stack in the nested stack group can be used as inputs to another stack.
Option C is incorrect because the description is wrong as there is no “AWS::CloudFormation::SubStack” resource.
Nested stacks should be used instead.
Option D is incorrect because StackSet is used to create stacks across multiple accounts and regions with a single operation.
StackSet is not required in this scenario.
Reference:
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-stack-exports.html#output-vs-nestedThe most appropriate option for dividing a CloudFormation stack into several parts and inheriting resources while managing all resources in a single stack is to use the "AWS::CloudFormation::Stack" resource to divide the stack into several nested stacks (option B).
Option A is not a valid method for dividing a CloudFormation stack into multiple parts since YAML partitions are not supported by CloudFormation. The "---" symbol is only used for separating multiple YAML documents in a single file.
Option C involves creating sub-stacks and exporting values in the sub-stacks for other stacks to import. This option is not suitable for managing all resources in a single stack since it requires exporting values to other stacks.
Option D is used for creating stack sets, which allow you to deploy stacks across multiple accounts and regions. While this option can be useful for managing multiple stacks across different environments, it is not appropriate for managing all resources in a single stack.
The "AWS::CloudFormation::Stack" resource allows you to divide a CloudFormation stack into several nested stacks. This method allows you to organize your resources into smaller, more manageable stacks while still managing all resources in a single stack. Each nested stack can inherit resources from the parent stack, and changes to the parent stack will automatically propagate to the nested stacks.
To use this method, you would define a "AWS::CloudFormation::Stack" resource in your CloudFormation template for each nested stack. You can then define the resources for each nested stack in a separate CloudFormation template file and use the "TemplateURL" property of the "AWS::CloudFormation::Stack" resource to specify the location of the template file.
Overall, using nested stacks is a best practice for managing complex CloudFormation stacks with a large number of resources. It allows for better organization and easier maintenance of the stack over time.