This lab walks you through the steps to create a Nested Stack using cloudFormation.
In this lab, you will create two separate stacks for Auto Scaling and Load Balancing and then attach the Autoscaling group to the Load balancer using a Nested Stack.
Duration: 1 hour
AWS Region: US East (N. Virginia) us-east-1
Before going into Nested Stack, we need to be familiar with a few concepts such as Cloudformation, Stack and Template.
CloudFormation is a service provided by AWS for designing our own infrastructure using code i.e infrastructure as code.
Currently, CloudFormation supports two languages JSON and YAML. You can write your code with one of the languages.
CloudFormation comes with great features being able to update your infrastructure whenever you want and also having the ability to delete the stack in case you don’t need it.
A fascinating feature of cloudFormation is that it saves more time in building infrastructure and helps in focusing on the development.
It is also possible to replicate our infrastructure in a short amount of time.
It eliminates human error and works according to the code you have written. It consists of two main components, Stack and Templates.
It consists of various sections like
AWS Template Format Version
It is not mandatory that the template requires all the above-mentioned sections. By using only the Resources section, we will be able to create a template.
The resources section plays an important role in the template creation.
For example, to create an EC2 instance, a template shall consist of various parameters such as key name, image id, instance type.
It is also possible to create two resources in the same template and refer to one from another i.e. attaching an elastic IP with an EC2 instance.
A stack consists of a collection of resources.
In other words, the stack consists of one or more templates.
The advantage of the stack is that it is easy to create, delete or update the collection of resources.
The advanced stacks have a nested stack which holds a collection of stacks.
As the name suggests, a Nested Stack consists of one or more stacks referencing each other.
As infrastructure scales, a particular CloudFormation template may need to be used multiple times.
In such cases, we isolate a common template and reference it as needed from a nested stack.
Nested stack itself consists of one or stacks in a reference hierarchy.
Nested Stack will have a parent stack that has one or more child stacks.
Log into the AWS Management Console.
Go through the Cloudformation template to understand all the terminologies.
Create the nested stack using the YAML file provided in the S3 bucket.
Finally, test the Environment created by CloudFormation Stack.