diff --git a/packages/aws-cdk-lib/aws-elasticloadbalancingv2/README.md b/packages/aws-cdk-lib/aws-elasticloadbalancingv2/README.md index 9704a114eb53b..7809f6f97dcfd 100644 --- a/packages/aws-cdk-lib/aws-elasticloadbalancingv2/README.md +++ b/packages/aws-cdk-lib/aws-elasticloadbalancingv2/README.md @@ -422,6 +422,23 @@ const listener = lb.addListener('Listener', { }); ``` +### Network Load Balancer and EC2 IConnectable interface +Network Load Balancer implements EC2 `IConnectable` and exposes `connections` property. EC2 Connections allows manage the allowed network connections for constructs with Security Groups. This class makes it easy to allow network connections to and from security groups, and between security groups individually. One thing to keep in mind is that network load balancers do not have security groups, and no automatic security group configuration is done for you. You will have to configure the security groups of the target yourself to allow traffic by clients and/or load balancer instances, depending on your target types. + +```ts +declare const vpc: ec2.Vpc; +declare const sg1: ec2.ISecurityGroup; +declare const sg2: ec2.ISecurityGroup; + +const lb = new elbv2.NetworkLoadBalancer(this, 'LB', { + vpc, + internetFacing: true, + securityGroups: [sg1], +}); +lb.addSecurityGroup(sg2); +lb.connections.allowFromAnyIpv4(ec2.Port.tcp(80)); +``` + ## Targets and Target Groups Application and Network Load Balancers organize load balancing targets in Target