0
votes

After review of many stack's, Im still stumped. Trying to create a cloudformation script that will reference an existing VPC ID and add a new subnet and keep getting syntax error. Any thoughts?

{
"AWSTemplateFormatVersion" : "2010-09-09",
"Resources" : {
   "mySubnet" : {
     "Type" : "AWS::EC2::Subnet",
     "Properties" : {
        "VpcId" : { "Ref" : "VPC" },
        "CidrBlock" : "10.0.0.0/24",
        "AvailabilityZone" : "us-east-1a",
     }
  }
 }
}    
1

1 Answers

2
votes

Ref would be for a parameter or some of the aws pseudo parameters like account, region, etc (http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/pseudo-parameter-reference.html)

If you put a parameter into the file and call it VPC, than it would work for you. Make sure to use the parameter type AWS::EC2::VPC::Id (http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html) to ensure that the value the person creating the stack provides is a valid VPC id.

If you are just working on a first template and trying to figure out how to make it work, you can just put the VPC Id that you want to use in that field and load it out.