0

I have created a second VPC in AWS which it is not a default VPC which we know it. I have three subnets in that second VPC. The issue is that, when I try to launch a ec2 with the second VPC I am not getting "No preference (defualt subnet in any Availability Zone)" option at the Subnet select column. I have to chose any of the three subnets in the VPC. I not sure if I missed anything while creating the secondary VPC or subnets. As I am getting the "No preference (defualt subnet in any Availability Zone)" option when I choose the default subnet.


Thanks,

Sreekanth

1 Answer 1

4

TL;DR

The "No preference (default subnet in any Availability Zone)" is only available for the Default VPC (and only for AWS accounts that do not support EC2-Classic). This option is not available for non-Default VPCs.

The reason is for legacy compatibility with EC2-Classic (even if your AWS account does not support it).

Detailed Explanation:

When you launch an EC2 instance (whether by command line, SDK, or GUI), the ec2:RunInstances command takes as input a subnet ID (and not a VPC ID). In the AWS Management Console, you do select a VPC, but that's only to filter the subnet selection control. The VPC selected does not make its way to the ec2:RunInstances command.

In the past, the subnet ID was optional, and if omitted, would launch the new EC2 instance in EC2-Classic (ie. outside of any VPC). So in the past, if you wanted the instance launched in a VPC, you must specify a subnet ID.

With newer AWS accounts, AWS has removed support for EC2-Classic and replaced it with the "Default" VPC. To keep software/scripts/etc. backward-compatible with EC2-Classic accounts, omitting the subnet ID is still permitted in newer AWS accounts and would launch the EC2 instance in the Default VPC in a default subnet.

But aside from all that, they want you to specify a subnet ID when launching in an VPC.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .