Skip to content

Commit

Permalink
fix(aws-cdk): fix VpcNetwork.importFromContext() (#2008)
Browse files Browse the repository at this point in the history
Check VpnGateways length in VPC provider, which would lead to failure to import VPCs 
without VPN gateways.

Fixes #1998
  • Loading branch information
jogold authored and rix0rrr committed Mar 13, 2019
1 parent 1187366 commit e1a1a7b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/aws-cdk/lib/context-providers/vpcs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit e1a1a7b

Please sign in to comment.