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.

Example:

# Example automatically generated from non-compiling source. May contain errors.
import aws_cdk.aws_globalaccelerator as globalaccelerator
import aws_cdk.aws_globalaccelerator_endpoints as ga_endpoints
import aws_cdk.aws_elasticloadbalancingv2 as elbv2

# Create an Accelerator
accelerator = globalaccelerator.Accelerator(stack, "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(stack, "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(stack, "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.

Return type

str

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.

Return type

Optional[str]

load_balancer_dns_name

The DNS name of this load balancer.

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

Return type

Optional[str]

vpc

The VPC to associate with the load balancer.

Default

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

balancers.

Return type

Optional[IVpc]