NetworkLoadBalancer

class aws_cdk.aws_elasticloadbalancingv2.NetworkLoadBalancer(scope, id, *, cross_zone_enabled=None, vpc, deletion_protection=None, internet_facing=None, load_balancer_name=None, vpc_subnets=None)

Bases: aws_cdk.aws_elasticloadbalancingv2.BaseLoadBalancer

Define a new network load balancer.

resource: :resource:: AWS::ElasticLoadBalancingV2::LoadBalancer

__init__(scope, id, *, cross_zone_enabled=None, vpc, deletion_protection=None, internet_facing=None, load_balancer_name=None, vpc_subnets=None)
Parameters
  • scope (Construct) –

  • id (str) –

  • props

  • cross_zone_enabled (Optional[bool]) – Indicates whether cross-zone load balancing is enabled. Default: false

  • 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 (Optional[SubnetSelection]) – Where in the VPC to place the load balancer. Default: - Public subnets if internetFacing, otherwise private subnets.

Return type

None

Methods

add_listener(id, *, port, certificates=None, default_target_groups=None, protocol=None, ssl_policy=None)

Add a listener to this load balancer.

Parameters
  • id (str) –

  • props

  • port (Union[int, float]) – The port on which the listener listens for requests.

  • certificates (Optional[List[INetworkListenerCertificateProps]]) – Certificate list of ACM cert ARNs. Default: - No certificates.

  • default_target_groups (Optional[List[INetworkTargetGroup]]) – Default target groups to load balance to. Default: - None.

  • protocol (Optional[Protocol]) – Protocol for listener, expects TCP or TLS. Default: - TLS if certificates are provided. TCP otherwise.

  • ssl_policy (Optional[SslPolicy]) – SSL Policy. Default: - Current predefined security policy.

return :rtype: NetworkListener :return: The newly created listener

metric(metric_name, *, color=None, dimensions=None, label=None, period=None, statistic=None, unit=None)

Return the given named metric for this Network Load Balancer.

Parameters
  • metric_name (str) –

  • props

  • color (Optional[str]) – Color for this metric when added to a Graph in a Dashboard.

  • dimensions (Optional[Mapping[str, Any]]) – Dimensions of the metric. Default: - No dimensions.

  • label (Optional[str]) – Label for this metric when added to a Graph in a Dashboard.

  • period (Optional[Duration]) – The period over which the specified statistic is applied. Default: Duration.minutes(5)

  • statistic (Optional[str]) – What function to use for aggregating. Can be one of the following: - “Minimum” | “min” - “Maximum” | “max” - “Average” | “avg” - “Sum” | “sum” - “SampleCount | “n” - “pNN.NN” Default: Average

  • unit (Optional[Unit]) – Unit for the metric that is associated with the alarm.

default :default: Average over 5 minutes

Return type

Metric

metric_active_flow_count(*, color=None, dimensions=None, label=None, period=None, statistic=None, unit=None)

The total number of concurrent TCP flows (or connections) from clients to targets.

This metric includes connections in the SYN_SENT and ESTABLISHED states. TCP connections are not terminated at the load balancer, so a client opening a TCP connection to a target counts as a single flow.

Parameters
  • props

  • color (Optional[str]) – Color for this metric when added to a Graph in a Dashboard.

  • dimensions (Optional[Mapping[str, Any]]) – Dimensions of the metric. Default: - No dimensions.

  • label (Optional[str]) – Label for this metric when added to a Graph in a Dashboard.

  • period (Optional[Duration]) – The period over which the specified statistic is applied. Default: Duration.minutes(5)

  • statistic (Optional[str]) – What function to use for aggregating. Can be one of the following: - “Minimum” | “min” - “Maximum” | “max” - “Average” | “avg” - “Sum” | “sum” - “SampleCount | “n” - “pNN.NN” Default: Average

  • unit (Optional[Unit]) – Unit for the metric that is associated with the alarm.

default :default: Average over 5 minutes

Return type

Metric

metric_consumed_lc_us(*, color=None, dimensions=None, label=None, period=None, statistic=None, unit=None)

The number of load balancer capacity units (LCU) used by your load balancer.

Parameters
  • props

  • color (Optional[str]) – Color for this metric when added to a Graph in a Dashboard.

  • dimensions (Optional[Mapping[str, Any]]) – Dimensions of the metric. Default: - No dimensions.

  • label (Optional[str]) – Label for this metric when added to a Graph in a Dashboard.

  • period (Optional[Duration]) – The period over which the specified statistic is applied. Default: Duration.minutes(5)

  • statistic (Optional[str]) – What function to use for aggregating. Can be one of the following: - “Minimum” | “min” - “Maximum” | “max” - “Average” | “avg” - “Sum” | “sum” - “SampleCount | “n” - “pNN.NN” Default: Average

  • unit (Optional[Unit]) – Unit for the metric that is associated with the alarm.

default :default: Sum over 5 minutes

Return type

Metric

metric_healthy_host_count(*, color=None, dimensions=None, label=None, period=None, statistic=None, unit=None)

The number of targets that are considered healthy.

Parameters
  • props

  • color (Optional[str]) – Color for this metric when added to a Graph in a Dashboard.

  • dimensions (Optional[Mapping[str, Any]]) – Dimensions of the metric. Default: - No dimensions.

  • label (Optional[str]) – Label for this metric when added to a Graph in a Dashboard.

  • period (Optional[Duration]) – The period over which the specified statistic is applied. Default: Duration.minutes(5)

  • statistic (Optional[str]) – What function to use for aggregating. Can be one of the following: - “Minimum” | “min” - “Maximum” | “max” - “Average” | “avg” - “Sum” | “sum” - “SampleCount | “n” - “pNN.NN” Default: Average

  • unit (Optional[Unit]) – Unit for the metric that is associated with the alarm.

default :default: Average over 5 minutes

Return type

Metric

metric_new_flow_count(*, color=None, dimensions=None, label=None, period=None, statistic=None, unit=None)

The total number of new TCP flows (or connections) established from clients to targets in the time period.

Parameters
  • props

  • color (Optional[str]) – Color for this metric when added to a Graph in a Dashboard.

  • dimensions (Optional[Mapping[str, Any]]) – Dimensions of the metric. Default: - No dimensions.

  • label (Optional[str]) – Label for this metric when added to a Graph in a Dashboard.

  • period (Optional[Duration]) – The period over which the specified statistic is applied. Default: Duration.minutes(5)

  • statistic (Optional[str]) – What function to use for aggregating. Can be one of the following: - “Minimum” | “min” - “Maximum” | “max” - “Average” | “avg” - “Sum” | “sum” - “SampleCount | “n” - “pNN.NN” Default: Average

  • unit (Optional[Unit]) – Unit for the metric that is associated with the alarm.

default :default: Sum over 5 minutes

Return type

Metric

metric_processed_bytes(*, color=None, dimensions=None, label=None, period=None, statistic=None, unit=None)

The total number of bytes processed by the load balancer, including TCP/IP headers.

Parameters
  • props

  • color (Optional[str]) – Color for this metric when added to a Graph in a Dashboard.

  • dimensions (Optional[Mapping[str, Any]]) – Dimensions of the metric. Default: - No dimensions.

  • label (Optional[str]) – Label for this metric when added to a Graph in a Dashboard.

  • period (Optional[Duration]) – The period over which the specified statistic is applied. Default: Duration.minutes(5)

  • statistic (Optional[str]) – What function to use for aggregating. Can be one of the following: - “Minimum” | “min” - “Maximum” | “max” - “Average” | “avg” - “Sum” | “sum” - “SampleCount | “n” - “pNN.NN” Default: Average

  • unit (Optional[Unit]) – Unit for the metric that is associated with the alarm.

default :default: Sum over 5 minutes

Return type

Metric

metric_tcp_client_reset_count(*, color=None, dimensions=None, label=None, period=None, statistic=None, unit=None)

The total number of reset (RST) packets sent from a client to a target.

These resets are generated by the client and forwarded by the load balancer.

Parameters
  • props

  • color (Optional[str]) – Color for this metric when added to a Graph in a Dashboard.

  • dimensions (Optional[Mapping[str, Any]]) – Dimensions of the metric. Default: - No dimensions.

  • label (Optional[str]) – Label for this metric when added to a Graph in a Dashboard.

  • period (Optional[Duration]) – The period over which the specified statistic is applied. Default: Duration.minutes(5)

  • statistic (Optional[str]) – What function to use for aggregating. Can be one of the following: - “Minimum” | “min” - “Maximum” | “max” - “Average” | “avg” - “Sum” | “sum” - “SampleCount | “n” - “pNN.NN” Default: Average

  • unit (Optional[Unit]) – Unit for the metric that is associated with the alarm.

default :default: Sum over 5 minutes

Return type

Metric

metric_tcp_elb_reset_count(*, color=None, dimensions=None, label=None, period=None, statistic=None, unit=None)

The total number of reset (RST) packets generated by the load balancer.

Parameters
  • props

  • color (Optional[str]) – Color for this metric when added to a Graph in a Dashboard.

  • dimensions (Optional[Mapping[str, Any]]) – Dimensions of the metric. Default: - No dimensions.

  • label (Optional[str]) – Label for this metric when added to a Graph in a Dashboard.

  • period (Optional[Duration]) – The period over which the specified statistic is applied. Default: Duration.minutes(5)

  • statistic (Optional[str]) – What function to use for aggregating. Can be one of the following: - “Minimum” | “min” - “Maximum” | “max” - “Average” | “avg” - “Sum” | “sum” - “SampleCount | “n” - “pNN.NN” Default: Average

  • unit (Optional[Unit]) – Unit for the metric that is associated with the alarm.

default :default: Sum over 5 minutes

Return type

Metric

metric_tcp_target_reset_count(*, color=None, dimensions=None, label=None, period=None, statistic=None, unit=None)

The total number of reset (RST) packets sent from a target to a client.

These resets are generated by the target and forwarded by the load balancer.

Parameters
  • props

  • color (Optional[str]) – Color for this metric when added to a Graph in a Dashboard.

  • dimensions (Optional[Mapping[str, Any]]) – Dimensions of the metric. Default: - No dimensions.

  • label (Optional[str]) – Label for this metric when added to a Graph in a Dashboard.

  • period (Optional[Duration]) – The period over which the specified statistic is applied. Default: Duration.minutes(5)

  • statistic (Optional[str]) – What function to use for aggregating. Can be one of the following: - “Minimum” | “min” - “Maximum” | “max” - “Average” | “avg” - “Sum” | “sum” - “SampleCount | “n” - “pNN.NN” Default: Average

  • unit (Optional[Unit]) – Unit for the metric that is associated with the alarm.

default :default: Sum over 5 minutes

Return type

Metric

metric_un_healthy_host_count(*, color=None, dimensions=None, label=None, period=None, statistic=None, unit=None)

The number of targets that are considered unhealthy.

Parameters
  • props

  • color (Optional[str]) – Color for this metric when added to a Graph in a Dashboard.

  • dimensions (Optional[Mapping[str, Any]]) – Dimensions of the metric. Default: - No dimensions.

  • label (Optional[str]) – Label for this metric when added to a Graph in a Dashboard.

  • period (Optional[Duration]) – The period over which the specified statistic is applied. Default: Duration.minutes(5)

  • statistic (Optional[str]) – What function to use for aggregating. Can be one of the following: - “Minimum” | “min” - “Maximum” | “max” - “Average” | “avg” - “Sum” | “sum” - “SampleCount | “n” - “pNN.NN” Default: Average

  • unit (Optional[Unit]) – Unit for the metric that is associated with the alarm.

default :default: Average over 5 minutes

Return type

Metric

remove_attribute(key)

Remove an attribute from the load balancer.

Parameters

key (str) –

Return type

None

set_attribute(key, value=None)

Set a non-standard attribute on the load balancer.

Parameters
  • key (str) –

  • value (Optional[str]) –

see :see: https://docs.aws.amazon.com/elasticloadbalancing/latest/application/application-load-balancers.html#load-balancer-attributes

Return type

None

to_string()

Returns a string representation of this construct.

Return type

str

Attributes

load_balancer_arn

The ARN of this load balancer.

attribute: :attribute:: true

Example::

# Example automatically generated. See https://github.com/aws/jsii/issues/826 arn:aws:elasticloadbalancing:us-west-2123456789012loadbalancer / app / my - internal - load - balancer / 50dc6c495c0c9188

Return type

str

load_balancer_canonical_hosted_zone_id

The canonical hosted zone ID of this load balancer.

attribute: :attribute:: true

Example::

# Example automatically generated. See https://github.com/aws/jsii/issues/826 Z2P70J7EXAMPLE

Return type

str

load_balancer_dns_name

The DNS name of this load balancer.

attribute: :attribute:: true

Example::

# Example automatically generated. See https://github.com/aws/jsii/issues/826 my - load - balancer - 424835706.us - west - 2.elb.amazonaws.com

Return type

str

load_balancer_full_name

The full name of this load balancer.

attribute: :attribute:: true

Example::

# Example automatically generated. See https://github.com/aws/jsii/issues/826 app / my - load - balancer / 50dc6c495c0c9188

Return type

str

load_balancer_name

The name of this load balancer.

attribute: :attribute:: true

Example::

# Example automatically generated. See https://github.com/aws/jsii/issues/826 my - load - balancer

Return type

str

load_balancer_security_groups

attribute: :attribute:: true

Return type

List[str]

node

Construct tree node which offers APIs for interacting with the construct tree.

Return type

ConstructNode

stack

The stack in which this resource is defined.

Return type

Stack

vpc

The VPC this load balancer has been created in, if available.

If the Load Balancer was imported, the VPC is not available.

Return type

Optional[IVpc]

Static Methods

classmethod from_network_load_balancer_attributes(scope, id, *, load_balancer_arn, load_balancer_canonical_hosted_zone_id=None, load_balancer_dns_name=None)
Parameters
  • scope (Construct) –

  • id (str) –

  • attrs

  • 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.

Return type

INetworkLoadBalancer

classmethod is_construct(x)

Return whether the given object is a Construct.

Parameters

x (Any) –

Return type

bool