I have a problem and I expect that someone help me.
I'm working with AWS and I have 2 VPC. The default VPC an another VPC created by me. Each VPC has 3 subnets in differents AZ (eu-west-1a, eu-west-1b and eu-west-1c).
I detected that, in default VPC, I can create/run a EC2 instance without specify which subnet.
But, with non-default VPC i have to specify which subnet I will use.
In non-default VPC, is it possible create a EC2 without specify a subnet?
I'm interested create a CloudFormation template that create Ec2 instance in differents subnets for redundancy.
Best Answer
I think you can leverage the new Parameter support in Cloudformation to do this.
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html
Get a list of all subnets in your VPC like this:
Then pick the first (or Nth) ID, store that in a variable, and pass it to create instance.
See also:
https://blogs.aws.amazon.com/application-management/post/Tx3DV2UYG9SC38G/Using-the-New-CloudFormation-Parameter-Types