5

I'm launching an EC2 instance via a CloudFormation template, however, the specified instance t2.micro requires a VPC.

How do I specify a VPC in the CloudFormation template?

Here's my template:

{ "Description" : "Single Instance", "Resources" : { "EC2Instance" : { "Type" : "AWS::EC2::Instance", "Properties" : { "ImageId" : "ami-b73b63a0", "InstanceType" : "t2.micro", "KeyName" : "my-key", "Tags" : [ { "Key" : "Name", "Value" : "test" } ] } } } } 

1 Answer 1

8

For EC2 Instances, you get to skip specifying the VPC ID and instead, just specify the subnet you want the instance in. From there, the VPC is assumed.

Inside of your "Properties" array, add the following:

"SubnetId" : "subnet-XXXXXXXX" 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.