Skip to content

Commit e1a1a7b

Browse files
jogoldrix0rrr
authored andcommitted
fix(aws-cdk): fix VpcNetwork.importFromContext() (#2008)
Check VpnGateways length in VPC provider, which would lead to failure to import VPCs without VPN gateways. Fixes #1998
1 parent 1187366 commit e1a1a7b

File tree

1 file changed

+3
-1
lines changed
  • packages/aws-cdk/lib/context-providers

1 file changed

+3
-1
lines changed

packages/aws-cdk/lib/context-providers/vpcs.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ export class VpcNetworkContextProviderPlugin implements ContextProviderPlugin {
8585
}
8686
]
8787
}).promise();
88-
const vpnGatewayId = vpnGatewayResponse.VpnGateways ? vpnGatewayResponse.VpnGateways[0].VpnGatewayId : undefined;
88+
const vpnGatewayId = vpnGatewayResponse.VpnGateways && vpnGatewayResponse.VpnGateways.length === 1
89+
? vpnGatewayResponse.VpnGateways[0].VpnGatewayId
90+
: undefined;
8991

9092
return {
9193
vpcId,

0 commit comments

Comments
 (0)