ApplicationTargetGroup

class aws_cdk.aws_elasticloadbalancingv2.ApplicationTargetGroup(scope, id, *, port=None, protocol=None, slow_start=None, stickiness_cookie_duration=None, targets=None, deregistration_delay=None, health_check=None, target_group_name=None, target_type=None, vpc=None)

Bases: aws_cdk.aws_elasticloadbalancingv2.TargetGroupBase

Define an Application Target Group.

__init__(scope, id, *, port=None, protocol=None, slow_start=None, stickiness_cookie_duration=None, targets=None, deregistration_delay=None, health_check=None, target_group_name=None, target_type=None, vpc=None)
Parameters
  • scope (Construct) –

  • id (str) –

  • props

  • port (Union[int, float, None]) – The port on which the listener listens for requests. Default: - Determined from protocol if known, optional for Lambda targets.

  • protocol (Optional[ApplicationProtocol]) – The protocol to use. Default: - Determined from port if known, optional for Lambda targets.

  • slow_start (Optional[Duration]) – The time period during which the load balancer sends a newly registered target a linearly increasing share of the traffic to the target group. The range is 30-900 seconds (15 minutes). Default: 0

  • stickiness_cookie_duration (Optional[Duration]) – The stickiness cookie expiration period. Setting this value enables load balancer stickiness. After this period, the cookie is considered stale. The minimum value is 1 second and the maximum value is 7 days (604800 seconds). Default: Duration.days(1)

  • targets (Optional[List[IApplicationLoadBalancerTarget]]) – The targets to add to this target group. Can be Instance, IPAddress, or any self-registering load balancing target. If you use either Instance or IPAddress as targets, all target must be of the same type. Default: - No targets.

  • deregistration_delay (Optional[Duration]) – The amount of time for Elastic Load Balancing to wait before deregistering a target. The range is 0-3600 seconds. Default: 300

  • health_check (Optional[HealthCheck]) – Health check configuration. Default: - None.

  • target_group_name (Optional[str]) – The name of the target group. This name must be unique per region per account, can have a maximum of 32 characters, must contain only alphanumeric characters or hyphens, and must not begin or end with a hyphen. Default: - Automatically generated.

  • target_type (Optional[TargetType]) – The type of targets registered to this TargetGroup, either IP or Instance. All targets registered into the group must be of this type. If you register targets to the TargetGroup in the CDK app, the TargetType is determined automatically. Default: - Determined automatically.

  • vpc (Optional[IVpc]) – The virtual private cloud (VPC). only if TargetType is Ip or InstanceId Default: - undefined

Return type

None

Methods

add_target(*targets)

Add a load balancing target to this target group.

Parameters

targets (IApplicationLoadBalancerTarget) –

Return type

None

configure_health_check(*, healthy_http_codes=None, healthy_threshold_count=None, interval=None, path=None, port=None, protocol=None, timeout=None, unhealthy_threshold_count=None)

Set/replace the target group’s health check.

Parameters
  • health_check

  • healthy_http_codes (Optional[str]) – HTTP code to use when checking for a successful response from a target. For Application Load Balancers, you can specify values between 200 and 499, and the default value is 200. You can specify multiple values (for example, “200,202”) or a range of values (for example, “200-299”).

  • healthy_threshold_count (Union[int, float, None]) – The number of consecutive health checks successes required before considering an unhealthy target healthy. For Application Load Balancers, the default is 5. For Network Load Balancers, the default is 3. Default: 5 for ALBs, 3 for NLBs

  • interval (Optional[Duration]) – The approximate number of seconds between health checks for an individual target. Default: Duration.seconds(30)

  • path (Optional[str]) – The ping path destination where Elastic Load Balancing sends health check requests. Default: /

  • port (Optional[str]) – The port that the load balancer uses when performing health checks on the targets. Default: ‘traffic-port’

  • protocol (Optional[Protocol]) – The protocol the load balancer uses when performing health checks on targets. The TCP protocol is supported for health checks only if the protocol of the target group is TCP, TLS, UDP, or TCP_UDP. The TLS, UDP, and TCP_UDP protocols are not supported for health checks. Default: HTTP for ALBs, TCP for NLBs

  • timeout (Optional[Duration]) – The amount of time, in seconds, during which no response from a target means a failed health check. For Application Load Balancers, the range is 2-60 seconds and the default is 5 seconds. For Network Load Balancers, this is 10 seconds for TCP and HTTPS health checks and 6 seconds for HTTP health checks. Default: Duration.seconds(5) for ALBs, Duration.seconds(10) or Duration.seconds(6) for NLBs

  • unhealthy_threshold_count (Union[int, float, None]) – The number of consecutive health check failures required before considering a target unhealthy. For Application Load Balancers, the default is 2. For Network Load Balancers, this value must be the same as the healthy threshold count. Default: 2

Return type

None

Enable sticky routing via a cookie to members of this target group.

Parameters

duration (Duration) –

Return type

None

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

Return the given named metric for this Application Load Balancer Target Group.

Returns the metric for this target group from the point of view of the first load balancer load balancing to it. If you have multiple load balancers load sending traffic to the same target group, you will have to override the dimensions on this metric.

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_healthy_host_count(*, color=None, dimensions=None, label=None, period=None, statistic=None, unit=None)

The number of healthy hosts in the target group.

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_http_code_target(code, *, color=None, dimensions=None, label=None, period=None, statistic=None, unit=None)

The number of HTTP 2xx/3xx/4xx/5xx response codes generated by all targets in this target group.

This does not include any response codes generated by the load balancer.

Parameters
  • code (HttpCodeTarget) –

  • 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_ipv6_request_count(*, color=None, dimensions=None, label=None, period=None, statistic=None, unit=None)

The number of IPv6 requests received by the target group.

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_request_count(*, color=None, dimensions=None, label=None, period=None, statistic=None, unit=None)

The number of requests processed over IPv4 and IPv6.

This count includes only the requests with a response generated by a target of 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_request_count_per_target(*, color=None, dimensions=None, label=None, period=None, statistic=None, unit=None)

The average number of requests received by each target in a target group.

The only valid statistic is Sum. Note that this represents the average not the sum.

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_target_connection_error_count(*, color=None, dimensions=None, label=None, period=None, statistic=None, unit=None)

The number of connections that were not successfully established between the load balancer and target.

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_target_response_time(*, color=None, dimensions=None, label=None, period=None, statistic=None, unit=None)

The time elapsed, in seconds, after the request leaves the load balancer until a response from the target is received.

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_target_tls_negotiation_error_count(*, color=None, dimensions=None, label=None, period=None, statistic=None, unit=None)

The number of TLS connections initiated by the load balancer that did not establish a session with the target.

Possible causes include a mismatch of ciphers or protocols.

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_unhealthy_host_count(*, color=None, dimensions=None, label=None, period=None, statistic=None, unit=None)

The number of unhealthy hosts in the target group.

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

register_connectable(connectable, port_range=None)

Register a connectable as a member of this target group.

Don’t call this directly. It will be called by load balancing targets.

Parameters
Return type

None

register_listener(listener, associating_construct=None)

Register a listener that is load balancing to this target group.

Don’t call this directly. It will be called by listeners.

Parameters
Return type

None

set_attribute(key, value=None)

Set a non-standard attribute on the target group.

Parameters
  • key (str) –

  • value (Optional[str]) –

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

Return type

None

to_string()

Returns a string representation of this construct.

Return type

str

Attributes

first_load_balancer_full_name

Full name of first load balancer.

Return type

str

health_check
Return type

HealthCheck

load_balancer_arns

A token representing a list of ARNs of the load balancers that route traffic to this target group.

Return type

str

load_balancer_attached

List of constructs that need to be depended on to ensure the TargetGroup is associated to a load balancer.

Return type

IDependable

node

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

Return type

ConstructNode

target_group_arn

The ARN of the target group.

Return type

str

target_group_full_name

The full name of the target group.

Return type

str

target_group_load_balancer_arns

ARNs of load balancers load balancing to this TargetGroup.

Return type

List[str]

target_group_name

The name of the target group.

Return type

str

Static Methods

classmethod from_target_group_attributes(scope, id, *, target_group_arn, default_port=None, load_balancer_arns=None)

Import an existing target group.

Parameters
  • scope (Construct) –

  • id (str) –

  • attrs

  • target_group_arn (str) – ARN of the target group.

  • default_port (Optional[str]) – Port target group is listening on.

  • load_balancer_arns (Optional[str]) – A Token representing the list of ARNs for the load balancer routing to this target group.

Return type

IApplicationTargetGroup

classmethod import_(scope, id, *, target_group_arn, default_port=None, load_balancer_arns=None)

Import an existing target group.

Parameters
  • scope (Construct) –

  • id (str) –

  • props

  • target_group_arn (str) – ARN of the target group.

  • default_port (Optional[str]) – Port target group is listening on.

  • load_balancer_arns (Optional[str]) – A Token representing the list of ARNs for the load balancer routing to this target group.

deprecated :deprecated: Use fromTargetGroupAttributes instead

stability :stability: deprecated

Return type

IApplicationTargetGroup

classmethod is_construct(x)

Return whether the given object is a Construct.

Parameters

x (Any) –

Return type

bool