From f5a1bd6e0aa6560ff1f9fcc77024c79e2513be33 Mon Sep 17 00:00:00 2001 From: Romain Marcadier Date: Mon, 17 Jan 2022 18:21:53 +0100 Subject: [PATCH] fix(elbv2): BaseLoadBalancer.vpc is not optional The `BaseLoadBalancer.vpc` property fulfills the `IApplicationLoadBalancer.vpc` and `INetworkLoadBalancer.vpc` properties, both of which are optional. A bug in `jsii` (see aws/jsii#3342) makes this pass type system consistency checks, when it should not be allowed. --- .../lib/shared/base-load-balancer.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/shared/base-load-balancer.ts b/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/shared/base-load-balancer.ts index 85ae9d143f0e2..345583bf9e5f8 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/shared/base-load-balancer.ts +++ b/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/shared/base-load-balancer.ts @@ -192,8 +192,11 @@ export abstract class BaseLoadBalancer extends Resource { /** * The VPC this load balancer has been created in. + * + * This property is always defined (not `null` or `undefined`) for sub-classes of `BaseLoadBalancer`. */ - public readonly vpc: ec2.IVpc; + public readonly vpc?: ec2.IVpc; + /** * Attributes set on this load balancer */