aws-cdk-lib.aws_elasticloadbalancing.LoadBalancerProps

interface LoadBalancerProps

LanguageType name
.NETAmazon.CDK.AWS.ElasticLoadBalancing.LoadBalancerProps
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awselasticloadbalancing#LoadBalancerProps
Javasoftware.amazon.awscdk.services.elasticloadbalancing.LoadBalancerProps
Pythonaws_cdk.aws_elasticloadbalancing.LoadBalancerProps
TypeScript (source)aws-cdk-lib » aws_elasticloadbalancing » LoadBalancerProps

Construction properties for a LoadBalancer.

Example

declare const cluster: ecs.Cluster;
declare const taskDefinition: ecs.TaskDefinition;
declare const vpc: ec2.Vpc;
const service = new ecs.Ec2Service(this, 'Service', { cluster, taskDefinition });

const lb = new elb.LoadBalancer(this, 'LB', { vpc });
lb.addListener({ externalPort: 80 });
lb.addTarget(service.loadBalancerTarget({
  containerName: 'MyContainer',
  containerPort: 80,
}));

Properties

NameTypeDescription
vpcIVpcVPC network of the fleet instances.
accessLoggingPolicy?AccessLoggingPolicyPropertyEnable 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.
crossZone?booleanWhether cross zone load balancing is enabled.
healthCheck?HealthCheckHealth check settings for the load balancing targets.
internetFacing?booleanWhether this is an internet-facing Load Balancer.
listeners?LoadBalancerListener[]What listeners to set up for the load balancer.
subnetSelection?SubnetSelectionWhich subnets to deploy the load balancer.
targets?ILoadBalancerTarget[]What targets to load balance to.

vpc

Type: IVpc

VPC network of the fleet instances.


accessLoggingPolicy?

Type: AccessLoggingPolicyProperty (optional, default: disabled)

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.


crossZone?

Type: boolean (optional, default: true)

Whether cross zone load balancing is enabled.

This controls whether the load balancer evenly distributes requests across each availability zone


healthCheck?

Type: HealthCheck (optional, default: None.)

Health check settings for the load balancing targets.

Not required but recommended.


internetFacing?

Type: boolean (optional, default: false)

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.


listeners?

Type: LoadBalancerListener[] (optional, default: -)

What listeners to set up for the load balancer.

Can also be added by .addListener()


subnetSelection?

Type: SubnetSelection (optional, default: Public subnets if internetFacing, Private subnets otherwise)

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.


targets?

Type: ILoadBalancerTarget[] (optional, default: None.)

What targets to load balance to.

Can also be added by .addTarget()