ApplicationLoadBalancerProps Struct
Properties for defining an Application Load Balancer.
Example
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]
});
Properties
clientKeepAliveoptionalDurationclient_keep_aliveoptionalDurationclientKeepAliveoptionalDurationClientKeepAliveoptionalDurationClientKeepAliveoptionalDuration= Duration.seconds(3600)#The client keep alive duration.
The valid range is 60 to 604800 seconds (1 minute to 7 days).
crossZoneEnabledoptionalbooleancross_zone_enabledoptionalboolcrossZoneEnabledoptionalBooleanCrossZoneEnabledoptionalboolCrossZoneEnabledoptional*bool#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.
deletionProtectionoptionalbooleandeletion_protectionoptionalbooldeletionProtectionoptionalBooleanDeletionProtectionoptionalboolDeletionProtectionoptional*bool= false#Indicates whether deletion protection is enabled.
denyAllIgwTrafficoptionalbooleandeny_all_igw_trafficoptionalbooldenyAllIgwTrafficoptionalBooleanDenyAllIgwTrafficoptionalboolDenyAllIgwTrafficoptional*bool#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
desyncMitigationModeoptionalDesyncMitigationModedesync_mitigation_modeoptionalDesyncMitigationModedesyncMitigationModeoptionalDesyncMitigationModeDesyncMitigationModeoptionalDesyncMitigationModeDesyncMitigationModeoptionalDesyncMitigationMode= DesyncMitigationMode.DEFENSIVE#Determines how the load balancer handles requests that might pose a security risk to your application.
dropInvalidHeaderFieldsoptionalbooleandrop_invalid_header_fieldsoptionalbooldropInvalidHeaderFieldsoptionalBooleanDropInvalidHeaderFieldsoptionalboolDropInvalidHeaderFieldsoptional*bool= false#Indicates whether HTTP headers with invalid header fields are removed by the load balancer (true) or routed to targets (false).
http2Enabledoptionalbooleanhttp2_enabledoptionalboolhttp2EnabledoptionalBooleanHttp2EnabledoptionalboolHttp2Enabledoptional*bool= true#Indicates whether HTTP/2 is enabled.
idleTimeoutoptionalDurationidle_timeoutoptionalDurationidleTimeoutoptionalDurationIdleTimeoutoptionalDurationIdleTimeoutoptionalDuration= 60#The load balancer idle timeout, in seconds.
internetFacingoptionalbooleaninternet_facingoptionalboolinternetFacingoptionalBooleanInternetFacingoptionalboolInternetFacingoptional*bool= false#Whether the load balancer has an internet-routable address.
ipAddressTypeoptionalIpAddressTypeip_address_typeoptionalIpAddressTypeipAddressTypeoptionalIpAddressTypeIpAddressTypeoptionalIpAddressTypeIpAddressTypeoptionalIpAddressType= IpAddressType.IPV4#The type of IP addresses to use.
loadBalancerNameoptionalstringload_balancer_nameoptionalstrloadBalancerNameoptionalStringLoadBalancerNameoptionalstringLoadBalancerNameoptional*string#Name of the load balancer.
Default: Automatically generated name.
minimumCapacityUnitoptionalnumberminimum_capacity_unitoptionalint | floatminimumCapacityUnitoptionalNumberMinimumCapacityUnitoptionaldoubleMinimumCapacityUnitoptional*float64#The minimum capacity (LCU) for a load balancer.
Default: undefined - ELB default is 0 LCU
preserveHostHeaderoptionalbooleanpreserve_host_headeroptionalboolpreserveHostHeaderoptionalBooleanPreserveHostHeaderoptionalboolPreserveHostHeaderoptional*bool= 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.
preserveXffClientPortoptionalbooleanpreserve_xff_client_portoptionalboolpreserveXffClientPortoptionalBooleanPreserveXffClientPortoptionalboolPreserveXffClientPortoptional*bool= false#Indicates whether the X-Forwarded-For header should preserve the source port that the client used to connect to the load balancer.
securityGroupoptionalISecurityGroupsecurity_groupoptionalISecurityGroupsecurityGroupoptionalISecurityGroupSecurityGroupoptionalISecurityGroupSecurityGroupoptionalISecurityGroup#Security group to associate with this load balancer.
Default: A security group is created
vpcSubnetsoptionalSubnetSelectionvpc_subnetsoptionalSubnetSelectionvpcSubnetsoptionalSubnetSelectionVpcSubnetsoptionalSubnetSelectionVpcSubnetsoptionalSubnetSelection#Which subnets place the load balancer in.
Default: the Vpc default strategy.
wafFailOpenoptionalbooleanwaf_fail_openoptionalboolwafFailOpenoptionalBooleanWafFailOpenoptionalboolWafFailOpenoptional*bool= 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.
xAmznTlsVersionAndCipherSuiteHeadersoptionalbooleanx_amzn_tls_version_and_cipher_suite_headersoptionalboolxAmznTlsVersionAndCipherSuiteHeadersoptionalBooleanXAmznTlsVersionAndCipherSuiteHeadersoptionalboolXAmznTlsVersionAndCipherSuiteHeadersoptional*bool= 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.
notes
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.
xffHeaderProcessingModeoptionalXffHeaderProcessingModexff_header_processing_modeoptionalXffHeaderProcessingModexffHeaderProcessingModeoptionalXffHeaderProcessingModeXffHeaderProcessingModeoptionalXffHeaderProcessingModeXffHeaderProcessingModeoptionalXffHeaderProcessingMode= 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.