ApplicationLoadBalancerProps

class aws_cdk.aws_elasticloadbalancingv2.ApplicationLoadBalancerProps(*, vpc, deletion_protection=None, internet_facing=None, load_balancer_name=None, vpc_subnets=None, http2_enabled=None, idle_timeout=None, ip_address_type=None, security_group=None)

Bases: BaseLoadBalancerProps

Properties for defining an Application Load Balancer.

Parameters:
  • vpc (IVpc) – The VPC network to place the load balancer in.

  • deletion_protection (Optional[bool]) – Indicates whether deletion protection is enabled. Default: false

  • internet_facing (Optional[bool]) – Whether the load balancer has an internet-routable address. Default: false

  • load_balancer_name (Optional[str]) – Name of the load balancer. Default: - Automatically generated name.

  • vpc_subnets (Union[SubnetSelection, Dict[str, Any], None]) – Which subnets place the load balancer in. Default: - the Vpc default strategy.

  • http2_enabled (Optional[bool]) – Indicates whether HTTP/2 is enabled. Default: true

  • idle_timeout (Optional[Duration]) – The load balancer idle timeout, in seconds. Default: 60

  • ip_address_type (Optional[IpAddressType]) – The type of IP addresses to use. Only applies to application load balancers. Default: IpAddressType.Ipv4

  • security_group (Optional[ISecurityGroup]) – Security group to associate with this load balancer. Default: A security group is created

ExampleMetadata:

infused

Example:

# cluster: ecs.Cluster
# task_definition: ecs.TaskDefinition
# vpc: ec2.Vpc

service = ecs.FargateService(self, "Service", cluster=cluster, task_definition=task_definition)

lb = elbv2.ApplicationLoadBalancer(self, "LB", vpc=vpc, internet_facing=True)
listener = lb.add_listener("Listener", port=80)
service.register_load_balancer_targets(
    container_name="web",
    container_port=80,
    new_target_group_id="ECS",
    listener=ecs.ListenerConfig.application_listener(listener,
        protocol=elbv2.ApplicationProtocol.HTTPS
    )
)

Attributes

deletion_protection

Indicates whether deletion protection is enabled.

Default:

false

http2_enabled

Indicates whether HTTP/2 is enabled.

Default:

true

idle_timeout

The load balancer idle timeout, in seconds.

Default:

60

internet_facing

Whether the load balancer has an internet-routable address.

Default:

false

ip_address_type

The type of IP addresses to use.

Only applies to application load balancers.

Default:

IpAddressType.Ipv4

load_balancer_name

Name of the load balancer.

Default:
  • Automatically generated name.

security_group

Security group to associate with this load balancer.

Default:

A security group is created

vpc

The VPC network to place the load balancer in.

vpc_subnets

Which subnets place the load balancer in.

Default:
  • the Vpc default strategy.