NetworkLoadBalancerAttributes

class aws_cdk.aws_elasticloadbalancingv2.NetworkLoadBalancerAttributes(*, load_balancer_arn, load_balancer_canonical_hosted_zone_id=None, load_balancer_dns_name=None, vpc=None)

Bases: object

Properties to reference an existing load balancer.

Parameters:
  • load_balancer_arn (str) – ARN of the load balancer.

  • load_balancer_canonical_hosted_zone_id (Optional[str]) – The canonical hosted zone ID of this load balancer. Default: - When not provided, LB cannot be used as Route53 Alias target.

  • load_balancer_dns_name (Optional[str]) – The DNS name of this load balancer. Default: - When not provided, LB cannot be used as Route53 Alias target.

  • vpc (Optional[IVpc]) – The VPC to associate with the load balancer. Default: - When not provided, listeners cannot be created on imported load balancers.

ExampleMetadata:

infused

Example:

# Create an Accelerator
accelerator = globalaccelerator.Accelerator(self, "Accelerator")

# Create a Listener
listener = accelerator.add_listener("Listener",
    port_ranges=[globalaccelerator.PortRange(from_port=80), globalaccelerator.PortRange(from_port=443)
    ]
)

# Import the Load Balancers
nlb1 = elbv2.NetworkLoadBalancer.from_network_load_balancer_attributes(self, "NLB1",
    load_balancer_arn="arn:aws:elasticloadbalancing:us-west-2:111111111111:loadbalancer/app/my-load-balancer1/e16bef66805b"
)
nlb2 = elbv2.NetworkLoadBalancer.from_network_load_balancer_attributes(self, "NLB2",
    load_balancer_arn="arn:aws:elasticloadbalancing:ap-south-1:111111111111:loadbalancer/app/my-load-balancer2/5513dc2ea8a1"
)

# Add one EndpointGroup for each Region we are targeting
listener.add_endpoint_group("Group1",
    endpoints=[ga_endpoints.NetworkLoadBalancerEndpoint(nlb1)]
)
listener.add_endpoint_group("Group2",
    # Imported load balancers automatically calculate their Region from the ARN.
    # If you are load balancing to other resources, you must also pass a `region`
    # parameter here.
    endpoints=[ga_endpoints.NetworkLoadBalancerEndpoint(nlb2)]
)

Attributes

load_balancer_arn

ARN of the load balancer.

load_balancer_canonical_hosted_zone_id

The canonical hosted zone ID of this load balancer.

Default:
  • When not provided, LB cannot be used as Route53 Alias target.

load_balancer_dns_name

The DNS name of this load balancer.

Default:
  • When not provided, LB cannot be used as Route53 Alias target.

vpc

The VPC to associate with the load balancer.

Default:

  • When not provided, listeners cannot be created on imported load

balancers.