DEV Community

Cover image for Learning AWS Day by Day — Day 35 — CloudFormation — Part 2
Saloni Singh
Saloni Singh

Posted on

Learning AWS Day by Day — Day 35 — CloudFormation — Part 2

Exploring AWS !!

Day 35:

CloudFormation — Part 2

Stacks: A stack is a group of related AWS resources that we manage as a single unit. A stack for instance, can include al resources required to run a web application, such as web server, database, networking rule. If we no longer require a web application, we can delete the stack and all of its related resources will be deleted. If a resource cannot be created, AWS CloudFormation rolls back and automatically deletes any resources that were created.
We can use AWS CLI, or management console to create it.

Nested Stacks: created as part of other stacks. We can create a nested stack within another stack by using AWS::CloudFormation::Stack-resource.

For first level of nested stack, the root stack is also the parent stack. So lets say, A is the parent and root for B, for C the B is parent stack.

Image description

CloudFormation Stack Sets: extends the functionality of stacks by enabling us to create, update or delete stacks across multiple accounts and regions with single operation. an administrator account is AWS account in which we can create stack sets. A target account is AWS account in which we can create, update or delete one or more stacks in our stack set. A stack instance is a reference to a stack in target account within a region. A stack instance can exist without a stack, example if stack cannot be created for some reason, the stack instance shows the reason for stack creation failure.

CloudFormation Template Anatomy:
Format version → “AWSTemplateFormatVersion”:”2010–9–9"
Description → “Description”:”AWSCloudFormationTemplate”
Metadata → Object to provide details of template
Parameter → Input parameters to pass user values in template.
Mappings → To map a name to its corresponding value
Conditions → The condition under which resources should be created
Transform → User macros to process our templates
Resources → resources which will be in the stack to be launched
Outputs → declares output values, which can be later used

Parameters: they enable us to input custom values to our template each time we create or update a stack.

Syntax:
“Parameters”: {
“Type”: “DataType”,
“ParameterType”: “value”
}

Top comments (0)