Cloudformation (Contd)
- The template which we have helps you in creating the vpc with 3 subnets
{
"Resources": {
"ntiervpc": {
"Type": "AWS::EC2::VPC",
"Properties": {
"CidrBlock": "10.10.0.0/16",
"Tags": [
{
"Key": "Name",
"Value": "primaryvnet"
}
]
}
},
"websubnet": {
"Type": "AWS::EC2::Subnet",
"Properties": {
"AvailabilityZone": "ap-south-1a",
"VpcId": {
"Ref": "ntiervpc"
},
"CidrBlock": "10.10.0.0/24",
"Tags": [
{
"Key": "Name",
"Value": "web"
}
]
}
},
"appsubnet": {
"Type": "AWS::EC2::Subnet",
"Properties": {
"AvailabilityZone": "ap-south-1a",
"VpcId": {
"Ref": "ntiervpc"
},
"CidrBlock": "10.10.1.0/24",
"Tags": [
{
"Key": "Name",
"Value": "app"
}
]
}
},
"dbsubnet": {
"Type": "AWS::EC2::Subnet",
"Properties": {
"AvailabilityZone": "ap-south-1a",
"VpcId": {
"Ref": "ntiervpc"
},
"CidrBlock": "10.10.2.0/24",
"Tags": [
{
"Key": "Name",
"Value": "db"
}
]
}
}
}
}
Change 1: Parametrize cidr ranges
- As of now the template always creates a network with range 10.10.0.0/16 and subnets with ranges
- 10.10.0.0/24
- 10.10.1.0/24
- 10.10.2.0/24
- Lets give option to the user to pass values dynamically
- Refer Here for the changes done


- Refer Here for the fix in cloud formation list
Change 2: Attach internet gateway
- Create an internet gateway and attach it to the vpc
- Refer Here for the cf resource of internet gateway and Refer Here for attachment
- Refer Here for the changes


Change 3: Create a route table
- For manual steps refer class room video
- Refer Here for resource
- Create a route table with tag key = Name and value = Public
- Refer Here for the changes and Refer Here for the changeset to rename logical name


Exercise
- Create a route table with tag key = Name and value = Private
Concepts
- Refer Here for Cloudformation docs on parameters
- AWS allows us to pass values by using Cloudformation paramters,
- There are two types on paramters
- Supported types in paramters Refer Here