Problem Description
Stack: AWS
Services: Cloud formation
What am I trying to achieve: Trying to form a VPC using Cloud formation
More Details :
1.Trying my hands with Cloud formation.
2.Having a step by step approach in building a VPC using cloud formation[JSON].
- Built a vpc alone
- Updating the existing stack by adding more components to the JSON template
- Components like Subnets, Internet gateway, NAT, Route table ...etc
- I want to append one component at a time.So every time when I am doing an update I am adding only one component and I am being mindful of the sequence too.
Problem Faced : With the first template, VPC alone got created successfully.When I tried to update the stack with Internet gateway and attach into the VPC, started getting the error " Template validation error: Invalid template resource property 'VPCID'.
JSON Template is as follows
{
"Parameters": {
"CIDRRange": {
"Description": "VPCCIDR Range (will be a /16 block)",
"Type": "String",
"Default": "10.251.0.0",
"AllowedValues": ["10.250.0.0","10.251.0.0"]
}
},
"Resources": {
"VPCBase": {
"Type": "AWS::EC2::VPC",
"Properties": {
"CidrBlock": { "Fn::Join" : ["", [{ "Ref" : "CIDRRange" }, "/16"]] },
"EnableDnsSupport": "True",
"EnableDnsHostnames": "True",
"Tags": [{ "Key": "Name", "Value": { "Fn::Join" : ["", [{ "Ref" : "AWS::StackName" }, "-VPC"]] } }]
}
},
"IGWBase" : {
"Type" : "AWS::EC2::InternetGateway",
"Properties" : {
"Tags" : [{ "Key": "Name", "Value": { "Fn::Join" : ["", [{ "Ref" : "AWS::StackName" }, "-IGW"]] } }]
}
},
"VGAIGWBase" : {
"Type" : "AWS::EC2::VPCGatewayAttachment",
"Properties" : {
"InternetGatewayId" : { "Ref" : "IGWBase" },
"VpcId" : { "Ref" : "VPCBase" }}
},
"Outputs": {
"VPCID" : { "Value" : { "Ref" : "VPCBase" } },
"DefaultSG" : { "Value" : { "Fn::GetAtt" : ["VPCBase", "DefaultSecurityGroup"] }}
}
}
}