Cloud Formation
- Generally to create an application architecture in AWS we use
- Console
- CLI
- To create infrastructure, we have infrastructure as code (IAC)
- Using IAC we express the infrastructure as a desired state to create a template
- When we execute this template a Stack gets created which ensures the resources are in desired state.
- We have different Infra Provisioing tools
- Terraform
- ARM Templates (Azure)
- CloudFormation (AWS)
- AWS CloudFormation Template can be describe in
- JSON
- YAML
- Cloud formation Stack creates all resources or no resources.
- For the Changes which we want, we can update the desired in the template and further update the stack.
- When we delete the stack, it deletes all resources.
AWS Cloud Formation Template Structure
- Refer Here
- Install an Extension in Visual Studio Code for AWS Cloudformation

- Lets understand resource Refer Here
- Basic Skeleton
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description": "This is skeleton",
"Resources": {
"resource-1": {
"Type": "",
"Properties": {
}
}
}
}
Activity 1:
- Create a VPC with cidr range 192.168.0.0/16
- Refer Here for the changes done to create a ntier vpc
- Now we have a template, lets create stack









Activity 2: Add 4 subnets to existing template and update the stack
- Refer Here for the changes.
- Now lets update the stack.



Activity 3: Lets Make this template reusable with dynamic AZ
- Refer Here for parameters


- Refer Here for the changes
Activity 4: Lets make cidr ranges also parametrized
- Refer Here for the changes

Activity 5: Lets add internet gateway and route tables
- Refer Here for the changes
Activity 6: Lets create a security group with 22 and 80 port open and create ec2 instance in public subnet
- Refer Here for functions in cloud formation
- Refer Here for the changes
- Refer Here for the yaml template.
