aws-cdk icon indicating copy to clipboard operation
aws-cdk copied to clipboard

ec2.Vpc.from_lookup does not work when multiple private subnets are present

Open reeseyc opened this issue 7 years ago • 5 comments

I'm submitting a :beetle: bug report

When retrieving an exisiting VPC using the ec2.Vpc.from_lookup classmethod, the call will fail if there are multiple private subnets present

Error message:

Not all subnets in VPC have the same AZs: ap-southeast-2a,ap-southeast-2b,ap-southeast-2c vs ap-southeast-2a,ap-southeast-2a,ap-southeast-2b,ap-southeast-2b,ap-southeast-2c,ap-southeast-2c

C:\AWS\Code\s3_test> cdk --version 1.1.0 (build 1a11e96) C:\AWS\Code\s3_test> python --version Python 3.7.4 OS: Windows 10

reeseyc avatar Jul 25 '19 09:07 reeseyc

@RomainMuller @NGL321 seems like a dup

eladb avatar Jul 25 '19 12:07 eladb

@eladb is this the correct classmethod to retrieve an existing VPC? Or is this depreciated?

Thanks James

reeseyc avatar Jul 25 '19 12:07 reeseyc

Same problem here with Typescript and cdk version 1.1.0 yesterday and 1.2.0 today.

cdk diff ... results in "Not all subnets in VPC have the same AZs: eu-west-1a,eu-west-1b vs eu-west-1a,eu-west-1a,eu-west-1b,eu-west-1b"

since we use this._vpc = ec2.Vpc.fromLookup(this, 'global-**removed**-VPC', { vpcId: 'vpc-**removed**', });

Our subnet structure in that VPC: public in eu-west-1a / euw1-az3 public in eu-west-1b / euw1-az1 private in eu-west-1a / euw1-az3 private in eu-west-1b / euw1-az1 private in eu-west-1a / euw1-az3 private in eu-west-1b / euw1-az1

Best regards Oliver

OliverEspeter avatar Jul 26 '19 07:07 OliverEspeter

If I understand @RomainMuller 's comment in #3407 , it needs to be a match on subnet counts as well, that is 2 Public and 2 Private.

vaneek avatar Jul 26 '19 08:07 vaneek

this is not a bug; you can have public, private and isolated subnets. Make sure you have the account and region set in the variables or by o/s setting

reeseyc avatar Aug 09 '19 11:08 reeseyc