# ApplicationLoadBalancerProps

Properties for defining an Application Load Balancer.

Extends: [BaseLoadBalancerProps](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_elasticloadbalancingv2.BaseLoadBalancerProps.html)
Used as props by: [ApplicationLoadBalancer](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_elasticloadbalancingv2.ApplicationLoadBalancer.html)

- Source: [`aws-elasticloadbalancingv2/lib/alb/application-load-balancer.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-elasticloadbalancingv2/lib/alb/application-load-balancer.ts#L32)
- Type last changed: v2.137.0 · 11 Apr 2024

## Example

TypeScript:

```ts
import { AutoScalingGroup } from 'aws-cdk-lib/aws-autoscaling';
declare const asg: AutoScalingGroup;
declare const vpc: ec2.Vpc;

// Create the load balancer in a VPC. 'internetFacing' is 'false'
// by default, which creates an internal load balancer.
const lb = new elbv2.ApplicationLoadBalancer(this, 'LB', {
  vpc,
  internetFacing: true
});

// Add a listener and open up the load balancer's security group
// to the world.
const listener = lb.addListener('Listener', {
  port: 80,

  // 'open: true' is the default, you can leave it out if you want. Set it
  // to 'false' and use `listener.connections` if you want to be selective
  // about who can access the load balancer.
  open: true,
});

// Create an AutoScaling group and add it as a load balancing
// target to the listener.
listener.addTargets('ApplicationFleet', {
  port: 8080,
  targets: [asg]
});
```

Python:

```python
from aws_cdk.aws_autoscaling import AutoScalingGroup
# asg: AutoScalingGroup
# vpc: ec2.Vpc

# Create the load balancer in a VPC. 'internetFacing' is 'false'
# by default, which creates an internal load balancer.
lb = elbv2.ApplicationLoadBalancer(self, "LB",
    vpc=vpc,
    internet_facing=True
)

# Add a listener and open up the load balancer's security group
# to the world.
listener = lb.add_listener("Listener",
    port=80,

    # 'open: true' is the default, you can leave it out if you want. Set it
    # to 'false' and use `listener.connections` if you want to be selective
    # about who can access the load balancer.
    open=True
)

# Create an AutoScaling group and add it as a load balancing
# target to the listener.
listener.add_targets("ApplicationFleet",
    port=8080,
    targets=[asg]
)
```

Java:

```java
import software.amazon.awscdk.services.autoscaling.AutoScalingGroup;
AutoScalingGroup asg;
Vpc vpc;

// Create the load balancer in a VPC. 'internetFacing' is 'false'
// by default, which creates an internal load balancer.
ApplicationLoadBalancer lb = ApplicationLoadBalancer.Builder.create(this, "LB")
        .vpc(vpc)
        .internetFacing(true)
        .build();

// Add a listener and open up the load balancer's security group
// to the world.
ApplicationListener listener = lb.addListener("Listener", BaseApplicationListenerProps.builder()
        .port(80)

        // 'open: true' is the default, you can leave it out if you want. Set it
        // to 'false' and use `listener.connections` if you want to be selective
        // about who can access the load balancer.
        .open(true)
        .build());

// Create an AutoScaling group and add it as a load balancing
// target to the listener.
listener.addTargets("ApplicationFleet", AddApplicationTargetsProps.builder()
        .port(8080)
        .targets(List.of(asg))
        .build());
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AWS.AutoScaling;
AutoScalingGroup asg;
Vpc vpc;

// Create the load balancer in a VPC. 'internetFacing' is 'false'
// by default, which creates an internal load balancer.
var lb = new ApplicationLoadBalancer(this, "LB", new ApplicationLoadBalancerProps {
    Vpc = vpc,
    InternetFacing = true
});

// Add a listener and open up the load balancer's security group
// to the world.
var listener = lb.AddListener("Listener", new BaseApplicationListenerProps {
    Port = 80,

    // 'open: true' is the default, you can leave it out if you want. Set it
    // to 'false' and use `listener.connections` if you want to be selective
    // about who can access the load balancer.
    Open = true
});

// Create an AutoScaling group and add it as a load balancing
// target to the listener.
listener.AddTargets("ApplicationFleet", new AddApplicationTargetsProps {
    Port = 8080,
    Targets = new [] { asg }
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import "github.com/aws/aws-cdk-go/awscdk"
var asg AutoScalingGroup
var vpc Vpc

// Create the load balancer in a VPC. 'internetFacing' is 'false'
// by default, which creates an internal load balancer.
lb := elbv2.NewApplicationLoadBalancer(this, jsii.String("LB"), &ApplicationLoadBalancerProps{
	Vpc: Vpc,
	InternetFacing: jsii.Boolean(true),
})

// Add a listener and open up the load balancer's security group
// to the world.
listener := lb.AddListener(jsii.String("Listener"), &BaseApplicationListenerProps{
	Port: jsii.Number(80),

	// 'open: true' is the default, you can leave it out if you want. Set it
	// to 'false' and use `listener.connections` if you want to be selective
	// about who can access the load balancer.
	Open: jsii.Boolean(true),
})

// Create an AutoScaling group and add it as a load balancing
// target to the listener.
listener.AddTargets(jsii.String("ApplicationFleet"), &AddApplicationTargetsProps{
	Port: jsii.Number(8080),
	Targets: []IApplicationLoadBalancerTarget{
		asg,
	},
})
```

## Properties

- `clientKeepAlive`: [Duration](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.Duration.html) = Duration.seconds(3600) — The client keep alive duration.

  The valid range is 60 to 604800 seconds (1 minute to 7 days).

- `crossZoneEnabled`: boolean — Indicates whether cross-zone load balancing is enabled.

  **Default:** false for Network Load Balancers and true for Application Load Balancers. This can not be `false` for Application Load Balancers.

- `deletionProtection`: boolean = false — Indicates whether deletion protection is enabled.

- `denyAllIgwTraffic`: boolean — Indicates whether the load balancer blocks traffic through the Internet Gateway (IGW).

  **Default:** false for internet-facing load balancers and true for internal load balancers

- `desyncMitigationMode`: [DesyncMitigationMode](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_elasticloadbalancingv2.DesyncMitigationMode.html) = DesyncMitigationMode.DEFENSIVE — Determines how the load balancer handles requests that might pose a security risk to your application.

- `dropInvalidHeaderFields`: boolean = false — Indicates whether HTTP headers with invalid header fields are removed by the load balancer (true) or routed to targets (false).

- `http2Enabled`: boolean = true — Indicates whether HTTP/2 is enabled.

- `idleTimeout`: [Duration](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.Duration.html) = 60 — The load balancer idle timeout, in seconds.

- `internetFacing`: boolean = false — Whether the load balancer has an internet-routable address.

- `ipAddressType`: [IpAddressType](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_elasticloadbalancingv2.IpAddressType.html) = IpAddressType.IPV4 — The type of IP addresses to use.

- `loadBalancerName`: string — Name of the load balancer.

  **Default:** Automatically generated name.

- `minimumCapacityUnit`: number — The minimum capacity (LCU) for a load balancer.

  **Default:** undefined - ELB default is 0 LCU

- `preserveHostHeader`: boolean = false — Indicates whether the Application Load Balancer should preserve the host header in the HTTP request and send it to the target without any change.

- `preserveXffClientPort`: boolean = false — Indicates whether the X-Forwarded-For header should preserve the source port that the client used to connect to the load balancer.

- `securityGroup`: [ISecurityGroup](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.ISecurityGroup.html) — Security group to associate with this load balancer.

  **Default:** A security group is created

- `vpc`: [IVpc](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.IVpc.html) (required) — The VPC network to place the load balancer in.

- `vpcSubnets`: [SubnetSelection](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.SubnetSelection.html) — Which subnets place the load balancer in.

  **Default:** the Vpc default strategy.

- `wafFailOpen`: boolean = false — Indicates whether to allow a WAF-enabled load balancer to route requests to targets if it is unable to forward the request to AWS WAF.

- `xAmznTlsVersionAndCipherSuiteHeaders`: boolean = false — Indicates whether the two headers (x-amzn-tls-version and x-amzn-tls-cipher-suite), which contain information about the negotiated TLS version and cipher suite, are added to the client request before sending it to the target.

  The x-amzn-tls-version header has information about the TLS protocol version negotiated with the client,
  and the x-amzn-tls-cipher-suite header has information about the cipher suite negotiated with the client.

  Both headers are in OpenSSL format.

- `xffHeaderProcessingMode`: [XffHeaderProcessingMode](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_elasticloadbalancingv2.XffHeaderProcessingMode.html) = XffHeaderProcessingMode.APPEND — Enables you to modify, preserve, or remove the X-Forwarded-For header in the HTTP request before the Application Load Balancer sends the request to the target.
