From e1a1a7ba5d37db6e6694a24979e6138961924ed6 Mon Sep 17 00:00:00 2001 From: Jonathan Goldwasser Date: Wed, 13 Mar 2019 13:38:41 +0100 Subject: [PATCH] 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 --- packages/aws-cdk/lib/context-providers/vpcs.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/aws-cdk/lib/context-providers/vpcs.ts b/packages/aws-cdk/lib/context-providers/vpcs.ts index dd4cd7bdda45d..7ed8c6955d4cf 100644 --- a/packages/aws-cdk/lib/context-providers/vpcs.ts +++ b/packages/aws-cdk/lib/context-providers/vpcs.ts @@ -85,7 +85,9 @@ export class VpcNetworkContextProviderPlugin implements ContextProviderPlugin { } ] }).promise(); - const vpnGatewayId = vpnGatewayResponse.VpnGateways ? vpnGatewayResponse.VpnGateways[0].VpnGatewayId : undefined; + const vpnGatewayId = vpnGatewayResponse.VpnGateways && vpnGatewayResponse.VpnGateways.length === 1 + ? vpnGatewayResponse.VpnGateways[0].VpnGatewayId + : undefined; return { vpcId,