AWS Fundamentals Logo
AWS Fundamentals
L2 Construct

LoadBalancer

A load balancer with a single listener. Routes to a fleet of instances in a VPC.

Import

import { LoadBalancer } from 'aws-cdk-lib/aws-elasticloadbalancing';

Or use the module namespace:

import * as elasticloadbalancing from 'aws-cdk-lib/aws-elasticloadbalancing';
// elasticloadbalancing.LoadBalancer

Properties

Configuration passed to the constructor as LoadBalancerProps.

vpcRequired
IVpc

VPC network of the fleet instances.

accessLoggingPolicyOptional
AccessLoggingPolicyProperty

Enable Loadbalancer access logs Can be used to avoid manual work as aws console Required S3 bucket name , enabled flag Can add interval for pushing log Can set bucket prefix in order to provide folder name inside bucket.

Default: - disabled

crossZoneOptional
boolean

Whether cross zone load balancing is enabled. This controls whether the load balancer evenly distributes requests across each availability zone

Default: true

healthCheckOptional
HealthCheck

Health check settings for the load balancing targets. Not required but recommended.

Default: - None.

internetFacingOptional
boolean

Whether this is an internet-facing Load Balancer. This controls whether the LB has a public IP address assigned. It does not open up the Load Balancer's security groups to public internet access.

Default: false

listenersOptional
LoadBalancerListener[]

What listeners to set up for the load balancer. Can also be added by .addListener()

Default: -

subnetSelectionOptional
SubnetSelection

Which subnets to deploy the load balancer. Can be used to define a specific set of subnets to deploy the load balancer to. Useful multiple public or private subnets are covering the same availability zone.

Default: - Public subnets if internetFacing, Private subnets otherwise

targetsOptional
ILoadBalancerTarget[]

What targets to load balance to. Can also be added by .addTarget()

Default: - None.

Learn AWS the Practical Way

Our bi-weekly newsletter teaches hands-on AWS fundamentals. No certification fluff - just practical knowledge.

Subscribe to Newsletter

Quick Facts

LevelL2 (Higher-level)
Moduleaws-elasticloadbalancing
Properties8

Related Constructs

External Links