CfnTargetGroupPropsMixin

class aws_cdk.mixins_preview.aws_elasticloadbalancingv2.mixins.CfnTargetGroupPropsMixin(props, *, strategy=None)

Bases: Mixin

Specifies a target group for an Application Load Balancer, a Network Load Balancer, or a Gateway Load Balancer.

Before you register a Lambda function as a target, you must create a AWS::Lambda::Permission resource that grants the Elastic Load Balancing service principal permission to invoke the Lambda function.

See:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticloadbalancingv2-targetgroup.html

CloudformationResource:

AWS::ElasticLoadBalancingV2::TargetGroup

Mixin:

true

ExampleMetadata:

fixture=_generated

Example:

# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk.mixins_preview import mixins
from aws_cdk.mixins_preview.aws_elasticloadbalancingv2 import mixins as elasticloadbalancingv2_mixins

cfn_target_group_props_mixin = elasticloadbalancingv2_mixins.CfnTargetGroupPropsMixin(elasticloadbalancingv2_mixins.CfnTargetGroupMixinProps(
    health_check_enabled=False,
    health_check_interval_seconds=123,
    health_check_path="healthCheckPath",
    health_check_port="healthCheckPort",
    health_check_protocol="healthCheckProtocol",
    health_check_timeout_seconds=123,
    healthy_threshold_count=123,
    ip_address_type="ipAddressType",
    matcher=elasticloadbalancingv2_mixins.CfnTargetGroupPropsMixin.MatcherProperty(
        grpc_code="grpcCode",
        http_code="httpCode"
    ),
    name="name",
    port=123,
    protocol="protocol",
    protocol_version="protocolVersion",
    tags=[CfnTag(
        key="key",
        value="value"
    )],
    target_control_port=123,
    target_group_attributes=[elasticloadbalancingv2_mixins.CfnTargetGroupPropsMixin.TargetGroupAttributeProperty(
        key="key",
        value="value"
    )],
    targets=[elasticloadbalancingv2_mixins.CfnTargetGroupPropsMixin.TargetDescriptionProperty(
        availability_zone="availabilityZone",
        id="id",
        port=123,
        quic_server_id="quicServerId"
    )],
    target_type="targetType",
    unhealthy_threshold_count=123,
    vpc_id="vpcId"
),
    strategy=mixins.PropertyMergeStrategy.OVERRIDE
)

Create a mixin to apply properties to AWS::ElasticLoadBalancingV2::TargetGroup.

Parameters:
  • props (Union[CfnTargetGroupMixinProps, Dict[str, Any]]) – L1 properties to apply.

  • strategy (Optional[PropertyMergeStrategy]) – (experimental) Strategy for merging nested properties. Default: - PropertyMergeStrategy.MERGE

Methods

apply_to(construct)

Apply the mixin properties to the construct.

Parameters:

construct (IConstruct)

Return type:

IConstruct

supports(construct)

Check if this mixin supports the given construct.

Parameters:

construct (IConstruct)

Return type:

bool

Attributes

CFN_PROPERTY_KEYS = ['healthCheckEnabled', 'healthCheckIntervalSeconds', 'healthCheckPath', 'healthCheckPort', 'healthCheckProtocol', 'healthCheckTimeoutSeconds', 'healthyThresholdCount', 'ipAddressType', 'matcher', 'name', 'port', 'protocol', 'protocolVersion', 'tags', 'targetControlPort', 'targetGroupAttributes', 'targets', 'targetType', 'unhealthyThresholdCount', 'vpcId']

Static Methods

classmethod is_mixin(x)

(experimental) Checks if x is a Mixin.

Parameters:

x (Any) – Any object.

Return type:

bool

Returns:

true if x is an object created from a class which extends Mixin.

Stability:

experimental

MatcherProperty

class CfnTargetGroupPropsMixin.MatcherProperty(*, grpc_code=None, http_code=None)

Bases: object

Specifies the HTTP codes that healthy targets must use when responding to an HTTP health check.

Parameters:
  • grpc_code (Optional[str]) – You can specify values between 0 and 99. You can specify multiple values (for example, “0,1”) or a range of values (for example, “0-5”). The default value is 12.

  • http_code (Optional[str]) – For Application Load Balancers, you can specify values between 200 and 499, with the default value being 200. You can specify multiple values (for example, “200,202”) or a range of values (for example, “200-299”). For Network Load Balancers, you can specify values between 200 and 599, with the default value being 200-399. You can specify multiple values (for example, “200,202”) or a range of values (for example, “200-299”). For Gateway Load Balancers, this must be “200–399”. Note that when using shorthand syntax, some values such as commas need to be escaped.

See:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-elasticloadbalancingv2-targetgroup-matcher.html

ExampleMetadata:

fixture=_generated

Example:

# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk.mixins_preview.aws_elasticloadbalancingv2 import mixins as elasticloadbalancingv2_mixins

matcher_property = elasticloadbalancingv2_mixins.CfnTargetGroupPropsMixin.MatcherProperty(
    grpc_code="grpcCode",
    http_code="httpCode"
)

Attributes

grpc_code

You can specify values between 0 and 99.

You can specify multiple values (for example, “0,1”) or a range of values (for example, “0-5”). The default value is 12.

See:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-elasticloadbalancingv2-targetgroup-matcher.html#cfn-elasticloadbalancingv2-targetgroup-matcher-grpccode

http_code

For Application Load Balancers, you can specify values between 200 and 499, with the default value being 200.

You can specify multiple values (for example, “200,202”) or a range of values (for example, “200-299”).

For Network Load Balancers, you can specify values between 200 and 599, with the default value being 200-399. You can specify multiple values (for example, “200,202”) or a range of values (for example, “200-299”).

For Gateway Load Balancers, this must be “200–399”.

Note that when using shorthand syntax, some values such as commas need to be escaped.

See:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-elasticloadbalancingv2-targetgroup-matcher.html#cfn-elasticloadbalancingv2-targetgroup-matcher-httpcode

TargetDescriptionProperty

class CfnTargetGroupPropsMixin.TargetDescriptionProperty(*, availability_zone=None, id=None, port=None, quic_server_id=None)

Bases: object

Specifies a target to add to a target group.

Parameters:
  • availability_zone (Optional[str]) – An Availability Zone or all . This determines whether the target receives traffic from the load balancer nodes in the specified Availability Zone or from all enabled Availability Zones for the load balancer. For Application Load Balancer target groups, the specified Availability Zone value is only applicable when cross-zone load balancing is off. Otherwise the parameter is ignored and treated as all . This parameter is not supported if the target type of the target group is instance or alb . If the target type is ip and the IP address is in a subnet of the VPC for the target group, the Availability Zone is automatically detected and this parameter is optional. If the IP address is outside the VPC, this parameter is required. For Application Load Balancer target groups with cross-zone load balancing off, if the target type is ip and the IP address is outside of the VPC for the target group, this should be an Availability Zone inside the VPC for the target group. If the target type is lambda , this parameter is optional and the only supported value is all .

  • id (Optional[str]) – The ID of the target. If the target type of the target group is instance , specify an instance ID. If the target type is ip , specify an IP address. If the target type is lambda , specify the ARN of the Lambda function. If the target type is alb , specify the ARN of the Application Load Balancer target.

  • port (Union[int, float, None]) – The port on which the target is listening. If the target group protocol is GENEVE, the supported port is 6081. If the target type is alb , the targeted Application Load Balancer must have at least one listener whose port matches the target group port. This parameter is not used if the target is a Lambda function.

  • quic_server_id (Optional[str]) – The server ID for the targets. This value is required if the protocol is QUIC or TCP_QUIC and can’t be used with other protocols. The ID consists of the 0x prefix followed by 16 hexadecimal characters. Any letters must be lowercase. The value must be unique at the listener level. You can’t modify the server ID for a registered target. You must deregister the target and then provide a new server ID when you register the target again.

See:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-elasticloadbalancingv2-targetgroup-targetdescription.html

ExampleMetadata:

fixture=_generated

Example:

# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk.mixins_preview.aws_elasticloadbalancingv2 import mixins as elasticloadbalancingv2_mixins

target_description_property = elasticloadbalancingv2_mixins.CfnTargetGroupPropsMixin.TargetDescriptionProperty(
    availability_zone="availabilityZone",
    id="id",
    port=123,
    quic_server_id="quicServerId"
)

Attributes

availability_zone

An Availability Zone or all .

This determines whether the target receives traffic from the load balancer nodes in the specified Availability Zone or from all enabled Availability Zones for the load balancer.

For Application Load Balancer target groups, the specified Availability Zone value is only applicable when cross-zone load balancing is off. Otherwise the parameter is ignored and treated as all .

This parameter is not supported if the target type of the target group is instance or alb .

If the target type is ip and the IP address is in a subnet of the VPC for the target group, the Availability Zone is automatically detected and this parameter is optional. If the IP address is outside the VPC, this parameter is required.

For Application Load Balancer target groups with cross-zone load balancing off, if the target type is ip and the IP address is outside of the VPC for the target group, this should be an Availability Zone inside the VPC for the target group.

If the target type is lambda , this parameter is optional and the only supported value is all .

See:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-elasticloadbalancingv2-targetgroup-targetdescription.html#cfn-elasticloadbalancingv2-targetgroup-targetdescription-availabilityzone

id

The ID of the target.

If the target type of the target group is instance , specify an instance ID. If the target type is ip , specify an IP address. If the target type is lambda , specify the ARN of the Lambda function. If the target type is alb , specify the ARN of the Application Load Balancer target.

See:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-elasticloadbalancingv2-targetgroup-targetdescription.html#cfn-elasticloadbalancingv2-targetgroup-targetdescription-id

port

The port on which the target is listening.

If the target group protocol is GENEVE, the supported port is 6081. If the target type is alb , the targeted Application Load Balancer must have at least one listener whose port matches the target group port. This parameter is not used if the target is a Lambda function.

See:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-elasticloadbalancingv2-targetgroup-targetdescription.html#cfn-elasticloadbalancingv2-targetgroup-targetdescription-port

quic_server_id

The server ID for the targets.

This value is required if the protocol is QUIC or TCP_QUIC and can’t be used with other protocols.

The ID consists of the 0x prefix followed by 16 hexadecimal characters. Any letters must be lowercase. The value must be unique at the listener level. You can’t modify the server ID for a registered target. You must deregister the target and then provide a new server ID when you register the target again.

See:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-elasticloadbalancingv2-targetgroup-targetdescription.html#cfn-elasticloadbalancingv2-targetgroup-targetdescription-quicserverid

TargetGroupAttributeProperty

class CfnTargetGroupPropsMixin.TargetGroupAttributeProperty(*, key=None, value=None)

Bases: object

Specifies a target group attribute.

Parameters:
  • key (Optional[str]) – The name of the attribute. The following attributes are supported by all load balancers: - deregistration_delay.timeout_seconds - The amount of time, in seconds, for Elastic Load Balancing to wait before changing the state of a deregistering target from draining to unused . The range is 0-3600 seconds. The default value is 300 seconds. If the target is a Lambda function, this attribute is not supported. - stickiness.enabled - Indicates whether target stickiness is enabled. The value is true or false . The default is false . - stickiness.type - Indicates the type of stickiness. The possible values are: - lb_cookie and app_cookie for Application Load Balancers. - source_ip for Network Load Balancers. - source_ip_dest_ip and source_ip_dest_ip_proto for Gateway Load Balancers. The following attributes are supported by Application Load Balancers and Network Load Balancers: - load_balancing.cross_zone.enabled - Indicates whether cross zone load balancing is enabled. The value is true , false or use_load_balancer_configuration . The default is use_load_balancer_configuration . - target_group_health.dns_failover.minimum_healthy_targets.count - The minimum number of targets that must be healthy. If the number of healthy targets is below this value, mark the zone as unhealthy in DNS, so that traffic is routed only to healthy zones. The possible values are off or an integer from 1 to the maximum number of targets. The default is 1. - target_group_health.dns_failover.minimum_healthy_targets.percentage - The minimum percentage of targets that must be healthy. If the percentage of healthy targets is below this value, mark the zone as unhealthy in DNS, so that traffic is routed only to healthy zones. The possible values are off or an integer from 1 to 100. The default is off . - target_group_health.unhealthy_state_routing.minimum_healthy_targets.count - The minimum number of targets that must be healthy. If the number of healthy targets is below this value, send traffic to all targets, including unhealthy targets. The possible values are 1 to the maximum number of targets. The default is 1. - target_group_health.unhealthy_state_routing.minimum_healthy_targets.percentage - The minimum percentage of targets that must be healthy. If the percentage of healthy targets is below this value, send traffic to all targets, including unhealthy targets. The possible values are off or an integer from 1 to 100. The default is off . The following attributes are supported only if the load balancer is an Application Load Balancer and the target is an instance or an IP address: - load_balancing.algorithm.type - The load balancing algorithm determines how the load balancer selects targets when routing requests. The value is round_robin , least_outstanding_requests , or weighted_random . The default is round_robin . - load_balancing.algorithm.anomaly_mitigation - Only available when load_balancing.algorithm.type is weighted_random . Indicates whether anomaly mitigation is enabled. The value is on or off . The default is off . - slow_start.duration_seconds - The time period, in seconds, during which a newly registered target receives an increasing share of the traffic to the target group. After this time period ends, the target receives its full share of traffic. The range is 30-900 seconds (15 minutes). The default is 0 seconds (disabled). - stickiness.app_cookie.cookie_name - Indicates the name of the application-based cookie. Names that start with the following prefixes are not allowed: AWSALB , AWSALBAPP , and AWSALBTG ; they’re reserved for use by the load balancer. - stickiness.app_cookie.duration_seconds - The time period, in seconds, during which requests from a client should be routed to the same target. After this time period expires, the application-based cookie is considered stale. The range is 1 second to 1 week (604800 seconds). The default value is 1 day (86400 seconds). - stickiness.lb_cookie.duration_seconds - The time period, in seconds, during which requests from a client should be routed to the same target. After this time period expires, the load balancer-generated cookie is considered stale. The range is 1 second to 1 week (604800 seconds). The default value is 1 day (86400 seconds). The following attribute is supported only if the load balancer is an Application Load Balancer and the target is a Lambda function: - lambda.multi_value_headers.enabled - Indicates whether the request and response headers that are exchanged between the load balancer and the Lambda function include arrays of values or strings. The value is true or false . The default is false . If the value is false and the request contains a duplicate header field name or query parameter key, the load balancer uses the last value sent by the client. The following attributes are supported only by Network Load Balancers: - deregistration_delay.connection_termination.enabled - Indicates whether the load balancer terminates connections at the end of the deregistration timeout. The value is true or false . For new UDP/TCP_UDP target groups the default is true . Otherwise, the default is false . - preserve_client_ip.enabled - Indicates whether client IP preservation is enabled. The value is true or false . The default is disabled if the target group type is IP address and the target group protocol is TCP or TLS. Otherwise, the default is enabled. Client IP preservation can’t be disabled for UDP and TCP_UDP target groups. - proxy_protocol_v2.enabled - Indicates whether Proxy Protocol version 2 is enabled. The value is true or false . The default is false . - target_health_state.unhealthy.connection_termination.enabled - Indicates whether the load balancer terminates connections to unhealthy targets. The value is true or false . The default is true . This attribute can’t be enabled for UDP and TCP_UDP target groups. - target_health_state.unhealthy.draining_interval_seconds - The amount of time for Elastic Load Balancing to wait before changing the state of an unhealthy target from unhealthy.draining to unhealthy . The range is 0-360000 seconds. The default value is 0 seconds. Note: This attribute can only be configured when target_health_state.unhealthy.connection_termination.enabled is false . The following attributes are supported only by Gateway Load Balancers: - target_failover.on_deregistration - Indicates how the Gateway Load Balancer handles existing flows when a target is deregistered. The possible values are rebalance and no_rebalance . The default is no_rebalance . The two attributes ( target_failover.on_deregistration and target_failover.on_unhealthy ) can’t be set independently. The value you set for both attributes must be the same. - target_failover.on_unhealthy - Indicates how the Gateway Load Balancer handles existing flows when a target is unhealthy. The possible values are rebalance and no_rebalance . The default is no_rebalance . The two attributes ( target_failover.on_deregistration and target_failover.on_unhealthy ) can’t be set independently. The value you set for both attributes must be the same.

  • value (Optional[str]) – The value of the attribute.

See:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-elasticloadbalancingv2-targetgroup-targetgroupattribute.html

ExampleMetadata:

fixture=_generated

Example:

# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk.mixins_preview.aws_elasticloadbalancingv2 import mixins as elasticloadbalancingv2_mixins

target_group_attribute_property = elasticloadbalancingv2_mixins.CfnTargetGroupPropsMixin.TargetGroupAttributeProperty(
    key="key",
    value="value"
)

Attributes

key

The name of the attribute.

The following attributes are supported by all load balancers:

  • deregistration_delay.timeout_seconds - The amount of time, in seconds, for Elastic Load Balancing to wait before changing the state of a deregistering target from draining to unused . The range is 0-3600 seconds. The default value is 300 seconds. If the target is a Lambda function, this attribute is not supported.

  • stickiness.enabled - Indicates whether target stickiness is enabled. The value is true or false . The default is false .

  • stickiness.type - Indicates the type of stickiness. The possible values are:

  • lb_cookie and app_cookie for Application Load Balancers.

  • source_ip for Network Load Balancers.

  • source_ip_dest_ip and source_ip_dest_ip_proto for Gateway Load Balancers.

The following attributes are supported by Application Load Balancers and Network Load Balancers:

  • load_balancing.cross_zone.enabled - Indicates whether cross zone load balancing is enabled. The value is true , false or use_load_balancer_configuration . The default is use_load_balancer_configuration .

  • target_group_health.dns_failover.minimum_healthy_targets.count - The minimum number of targets that must be healthy. If the number of healthy targets is below this value, mark the zone as unhealthy in DNS, so that traffic is routed only to healthy zones. The possible values are off or an integer from 1 to the maximum number of targets. The default is 1.

  • target_group_health.dns_failover.minimum_healthy_targets.percentage - The minimum percentage of targets that must be healthy. If the percentage of healthy targets is below this value, mark the zone as unhealthy in DNS, so that traffic is routed only to healthy zones. The possible values are off or an integer from 1 to 100. The default is off .

  • target_group_health.unhealthy_state_routing.minimum_healthy_targets.count - The minimum number of targets that must be healthy. If the number of healthy targets is below this value, send traffic to all targets, including unhealthy targets. The possible values are 1 to the maximum number of targets. The default is 1.

  • target_group_health.unhealthy_state_routing.minimum_healthy_targets.percentage - The minimum percentage of targets that must be healthy. If the percentage of healthy targets is below this value, send traffic to all targets, including unhealthy targets. The possible values are off or an integer from 1 to 100. The default is off .

The following attributes are supported only if the load balancer is an Application Load Balancer and the target is an instance or an IP address:

  • load_balancing.algorithm.type - The load balancing algorithm determines how the load balancer selects targets when routing requests. The value is round_robin , least_outstanding_requests , or weighted_random . The default is round_robin .

  • load_balancing.algorithm.anomaly_mitigation - Only available when load_balancing.algorithm.type is weighted_random . Indicates whether anomaly mitigation is enabled. The value is on or off . The default is off .

  • slow_start.duration_seconds - The time period, in seconds, during which a newly registered target receives an increasing share of the traffic to the target group. After this time period ends, the target receives its full share of traffic. The range is 30-900 seconds (15 minutes). The default is 0 seconds (disabled).

  • stickiness.app_cookie.cookie_name - Indicates the name of the application-based cookie. Names that start with the following prefixes are not allowed: AWSALB , AWSALBAPP , and AWSALBTG ; they’re reserved for use by the load balancer.

  • stickiness.app_cookie.duration_seconds - The time period, in seconds, during which requests from a client should be routed to the same target. After this time period expires, the application-based cookie is considered stale. The range is 1 second to 1 week (604800 seconds). The default value is 1 day (86400 seconds).

  • stickiness.lb_cookie.duration_seconds - The time period, in seconds, during which requests from a client should be routed to the same target. After this time period expires, the load balancer-generated cookie is considered stale. The range is 1 second to 1 week (604800 seconds). The default value is 1 day (86400 seconds).

The following attribute is supported only if the load balancer is an Application Load Balancer and the target is a Lambda function:

  • lambda.multi_value_headers.enabled - Indicates whether the request and response headers that are exchanged between the load balancer and the Lambda function include arrays of values or strings. The value is true or false . The default is false . If the value is false and the request contains a duplicate header field name or query parameter key, the load balancer uses the last value sent by the client.

The following attributes are supported only by Network Load Balancers:

  • deregistration_delay.connection_termination.enabled - Indicates whether the load balancer terminates connections at the end of the deregistration timeout. The value is true or false . For new UDP/TCP_UDP target groups the default is true . Otherwise, the default is false .

  • preserve_client_ip.enabled - Indicates whether client IP preservation is enabled. The value is true or false . The default is disabled if the target group type is IP address and the target group protocol is TCP or TLS. Otherwise, the default is enabled. Client IP preservation can’t be disabled for UDP and TCP_UDP target groups.

  • proxy_protocol_v2.enabled - Indicates whether Proxy Protocol version 2 is enabled. The value is true or false . The default is false .

  • target_health_state.unhealthy.connection_termination.enabled - Indicates whether the load balancer terminates connections to unhealthy targets. The value is true or false . The default is true . This attribute can’t be enabled for UDP and TCP_UDP target groups.

  • target_health_state.unhealthy.draining_interval_seconds - The amount of time for Elastic Load Balancing to wait before changing the state of an unhealthy target from unhealthy.draining to unhealthy . The range is 0-360000 seconds. The default value is 0 seconds.

Note: This attribute can only be configured when target_health_state.unhealthy.connection_termination.enabled is false .

The following attributes are supported only by Gateway Load Balancers:

  • target_failover.on_deregistration - Indicates how the Gateway Load Balancer handles existing flows when a target is deregistered. The possible values are rebalance and no_rebalance . The default is no_rebalance . The two attributes ( target_failover.on_deregistration and target_failover.on_unhealthy ) can’t be set independently. The value you set for both attributes must be the same.

  • target_failover.on_unhealthy - Indicates how the Gateway Load Balancer handles existing flows when a target is unhealthy. The possible values are rebalance and no_rebalance . The default is no_rebalance . The two attributes ( target_failover.on_deregistration and target_failover.on_unhealthy ) can’t be set independently. The value you set for both attributes must be the same.

See:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-elasticloadbalancingv2-targetgroup-targetgroupattribute.html#cfn-elasticloadbalancingv2-targetgroup-targetgroupattribute-key

value

The value of the attribute.

See:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-elasticloadbalancingv2-targetgroup-targetgroupattribute.html#cfn-elasticloadbalancingv2-targetgroup-targetgroupattribute-value