'Getting "Template validation error: Invalid template resource property 'VPCID' "

I am trying to create a VPC using AWS CloudFormation.

I built a VPC on its own, then I updated the existing stack by adding more components to the JSON template (components like subnets, internet gateways, NATs, route tables, etc.) - one component at a time.

My VPC created successfully but when I tried to update the stack with an internet gateway and attach to the VPC, I started getting the error Template validation error: Invalid template resource property 'VPCID'.

My 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"] }}
              }
}
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source