Cloud-Formation Template for N-tier(JSON)
https://drive.google.com/open?id=14EyRo2opvvDfxGVJTRfeJEDZxLKc8LjU
Steps:
Create a Template for the following:
* Region => Mumbai
* CIDR => 192.168.0.0/16
* Subnets => 2 Subnets
* Web:
CIDR => 192.168.0.0/24
* Data:
CIDR => 192.168.1.0/24
* Internet Gateway
* Route Table => Should allow all incoming & outgoing traffic
* 2 Virtual Machines (EC2 Instances in each subnet)
Steps:
- Create a VPC
- Create a two subnets
- Create a internet gateway
- Attach it to your vpc
- create a route table
- In the routetable create a route destination : 0.0.0.0/0 target : igw
- Associate your subnets to route table
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Network vpc with subnet",
"Resources": {
"myVpc": {
"Description": "MYVPC details",
"Type": "AWS::EC2::VPC",
"Properties": {
"CidrBlock": "192.168.0.0/16",
"Tags": [
{
"Key": "Name",
"Value": "ntier-VPC"
}
]
}
},
"webSubnet": {
"Description": "MY WEB SUBNET details",
"Type": "AWS::EC2::Subnet",
"Properties": {
"AvailabilityZone": "ap-south-1a",
"CidrBlock": "192.168.0.0/24",
"VpcId": {
"Ref": "myVpc"
},
"Tags": [
{
"Key": "Name",
"Value": "web-subnet"
}
]
}
},
"dataSubnet": {
"Description": "MY DATA SUBNET details",
"Type": "AWS::EC2::Subnet",
"Properties": {
"AvailabilityZone": "ap-south-1b",
"CidrBlock": "192.168.1.0/24",
"VpcId": {
"Ref": "myVpc"
},
"Tags": [
{
"Key": "Name",
"Value": "date-subnet"
}
]
}
},
"myIGW": {
"Type": "AWS::EC2::InternetGateway",
"Properties": {
"Tags": [
{
"Key": "Name",
"Value": "ntier-igw"
}
]
}
},
"AttachGateway": {
"Type": "AWS::EC2::VPCGatewayAttachment",
"Properties": {
"VpcId": {
"Ref": "myVpc"
},
"InternetGatewayId": {
"Ref": "myIGW"
}
}
},
"myRouteTable1": {
"Type": "AWS::EC2::RouteTable",
"Properties": {
"VpcId": {
"Ref": "myVpc"
},
"Tags": [
{
"Key": "Name",
"Value": "ntier-rt-1"
}
]
}
},
"forwardToIGW": {
"Type": "AWS::EC2::Route",
"Properties": {
"RouteTableId": {
"Ref": "myRouteTable1"
},
"DestinationCidrBlock": "0.0.0.0/0",
"GatewayId": {
"Ref": "myIGW"
}
}
},
"webrtasc": {
"Type": "AWS::EC2::SubnetRouteTableAssociation",
"Properties": {
"RouteTableId": {
"Ref": "myRouteTable1"
},
"SubnetId": {
"Ref": "webSubnet"
}
}
},
"datrtasc": {
"Type": "AWS::EC2::SubnetRouteTableAssociation",
"Properties": {
"RouteTableId": {
"Ref": "myRouteTable1"
},
"SubnetId": {
"Ref": "dataSubnet"
}
}
}
}
}
Comments
Post a Comment