Is it possible to define VPCId for an EC2 instance template as a property?
I am trying to do is something like,
"Resources" : {
"Ec2Instance" : {
"Type" : "AWS::EC2::Instance",
"Properties" : {
"SecurityGroups": [ { "Ref": "AWSSecurityGroups" } ],
"KeyName" : { "Ref" : "KeyName" },
"InstanceType" : { "Ref" : "InstanceType" },
"Tags" : [ { "Key" : "Name", "Value" : "Softnas-CF" }],
"ImageId" : { "Fn::FindInMap" : [ "RegionMap", { "Ref" : "AWS::Region" }, "AMI" ]},
"VpcId" : { "Ref" : "VPCId" },
.....some other stuff...
},
In my parameters I define VPCId,
"Parameters" : {
....
"VPCId": {
"Description": "Name of an existing VPC ID",
"Type": "AWS::EC2::VPC::Id",
"ConstraintDescription": "must be the name of an existing VPC Id."
},
...
},
But when I creating the stack (via the .net api), it Rollback with the error
Encountered unsupported property VpcId
Isn't this allowed, I couldn't find any documentation to do this. Doing this as an experiment. Is the EC2 instance always gets created in the default VPC if created using templates?
VpcId
is not supported in Ec2Instance:Properties
Use SubnetId
.
"Ec2Instance" : {
"Type" : "AWS::EC2::Instance",
"Properties" : {
"SecurityGroupIds" : [ { "Ref" : "xxxxx" } ],
"Tags" : [ { "Key" : "Name", "Value" : "xxx" } ],
"ImageId" : { "Fn::FindInMap" : [ "RegionMap", { "Ref" : "AWS::Region" }, "AMI" ]},
"SubnetId" : { "Ref" : "VpcSubnet" },
"InstanceType" : { "Ref" : "InstanceType" },
....
"VpcSubnet": {
"Description" : "Enter the VPC subnet",
"Type" : "AWS::EC2::Subnet::Id",
"Default" : ""
},
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With