

This is the new *CloudFormation Template Reference Guide*. Please update your bookmarks and links. For help getting started with CloudFormation, see the [AWS CloudFormation User Guide](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Welcome.html).

# AWS::ElasticLoadBalancingV2::TargetGroup
<a name="aws-resource-elasticloadbalancingv2-targetgroup"></a>

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.

## Syntax
<a name="aws-resource-elasticloadbalancingv2-targetgroup-syntax"></a>

To declare this entity in your CloudFormation template, use the following syntax:

### JSON
<a name="aws-resource-elasticloadbalancingv2-targetgroup-syntax.json"></a>

```
{
  "Type" : "AWS::ElasticLoadBalancingV2::TargetGroup",
  "Properties" : {
      "[HealthCheckEnabled](#cfn-elasticloadbalancingv2-targetgroup-healthcheckenabled)" : Boolean,
      "[HealthCheckIntervalSeconds](#cfn-elasticloadbalancingv2-targetgroup-healthcheckintervalseconds)" : Integer,
      "[HealthCheckPath](#cfn-elasticloadbalancingv2-targetgroup-healthcheckpath)" : String,
      "[HealthCheckPort](#cfn-elasticloadbalancingv2-targetgroup-healthcheckport)" : String,
      "[HealthCheckProtocol](#cfn-elasticloadbalancingv2-targetgroup-healthcheckprotocol)" : String,
      "[HealthCheckTimeoutSeconds](#cfn-elasticloadbalancingv2-targetgroup-healthchecktimeoutseconds)" : Integer,
      "[HealthyThresholdCount](#cfn-elasticloadbalancingv2-targetgroup-healthythresholdcount)" : Integer,
      "[IpAddressType](#cfn-elasticloadbalancingv2-targetgroup-ipaddresstype)" : String,
      "[Matcher](#cfn-elasticloadbalancingv2-targetgroup-matcher)" : Matcher,
      "[Name](#cfn-elasticloadbalancingv2-targetgroup-name)" : String,
      "[Port](#cfn-elasticloadbalancingv2-targetgroup-port)" : Integer,
      "[Protocol](#cfn-elasticloadbalancingv2-targetgroup-protocol)" : String,
      "[ProtocolVersion](#cfn-elasticloadbalancingv2-targetgroup-protocolversion)" : String,
      "[Tags](#cfn-elasticloadbalancingv2-targetgroup-tags)" : [ Tag, ... ],
      "[TargetControlPort](#cfn-elasticloadbalancingv2-targetgroup-targetcontrolport)" : Integer,
      "[TargetGroupAttributes](#cfn-elasticloadbalancingv2-targetgroup-targetgroupattributes)" : [ TargetGroupAttribute, ... ],
      "[Targets](#cfn-elasticloadbalancingv2-targetgroup-targets)" : [ TargetDescription, ... ],
      "[TargetType](#cfn-elasticloadbalancingv2-targetgroup-targettype)" : String,
      "[UnhealthyThresholdCount](#cfn-elasticloadbalancingv2-targetgroup-unhealthythresholdcount)" : Integer,
      "[VpcId](#cfn-elasticloadbalancingv2-targetgroup-vpcid)" : String
    }
}
```

### YAML
<a name="aws-resource-elasticloadbalancingv2-targetgroup-syntax.yaml"></a>

```
Type: AWS::ElasticLoadBalancingV2::TargetGroup
Properties:
  [HealthCheckEnabled](#cfn-elasticloadbalancingv2-targetgroup-healthcheckenabled): Boolean
  [HealthCheckIntervalSeconds](#cfn-elasticloadbalancingv2-targetgroup-healthcheckintervalseconds): Integer
  [HealthCheckPath](#cfn-elasticloadbalancingv2-targetgroup-healthcheckpath): String
  [HealthCheckPort](#cfn-elasticloadbalancingv2-targetgroup-healthcheckport): String
  [HealthCheckProtocol](#cfn-elasticloadbalancingv2-targetgroup-healthcheckprotocol): String
  [HealthCheckTimeoutSeconds](#cfn-elasticloadbalancingv2-targetgroup-healthchecktimeoutseconds): Integer
  [HealthyThresholdCount](#cfn-elasticloadbalancingv2-targetgroup-healthythresholdcount): Integer
  [IpAddressType](#cfn-elasticloadbalancingv2-targetgroup-ipaddresstype): String
  [Matcher](#cfn-elasticloadbalancingv2-targetgroup-matcher): 
    Matcher
  [Name](#cfn-elasticloadbalancingv2-targetgroup-name): String
  [Port](#cfn-elasticloadbalancingv2-targetgroup-port): Integer
  [Protocol](#cfn-elasticloadbalancingv2-targetgroup-protocol): String
  [ProtocolVersion](#cfn-elasticloadbalancingv2-targetgroup-protocolversion): String
  [Tags](#cfn-elasticloadbalancingv2-targetgroup-tags): 
    - Tag
  [TargetControlPort](#cfn-elasticloadbalancingv2-targetgroup-targetcontrolport): Integer
  [TargetGroupAttributes](#cfn-elasticloadbalancingv2-targetgroup-targetgroupattributes): 
    - TargetGroupAttribute
  [Targets](#cfn-elasticloadbalancingv2-targetgroup-targets): 
    - TargetDescription
  [TargetType](#cfn-elasticloadbalancingv2-targetgroup-targettype): String
  [UnhealthyThresholdCount](#cfn-elasticloadbalancingv2-targetgroup-unhealthythresholdcount): Integer
  [VpcId](#cfn-elasticloadbalancingv2-targetgroup-vpcid): String
```

## Properties
<a name="aws-resource-elasticloadbalancingv2-targetgroup-properties"></a>

`HealthCheckEnabled`  <a name="cfn-elasticloadbalancingv2-targetgroup-healthcheckenabled"></a>
Indicates whether health checks are enabled. If the target type is `lambda`, health checks are disabled by default but can be enabled. If the target type is `instance`, `ip`, or `alb`, health checks are always enabled and can't be disabled.  
*Required*: No  
*Type*: Boolean  
*Update requires*: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

`HealthCheckIntervalSeconds`  <a name="cfn-elasticloadbalancingv2-targetgroup-healthcheckintervalseconds"></a>
The approximate amount of time, in seconds, between health checks of an individual target. The range is 5-300. If the target group protocol is TCP, TLS, UDP, TCP\$1UDP, QUIC, TCP\$1QUIC, HTTP or HTTPS, the default is 30 seconds. If the target group protocol is GENEVE, the default is 10 seconds. If the target type is `lambda`, the default is 35 seconds.  
*Required*: No  
*Type*: Integer  
*Minimum*: `5`  
*Maximum*: `300`  
*Update requires*: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

`HealthCheckPath`  <a name="cfn-elasticloadbalancingv2-targetgroup-healthcheckpath"></a>
[HTTP/HTTPS health checks] The destination for health checks on the targets.  
[HTTP1 or HTTP2 protocol version] The ping path. The default is /.  
[GRPC protocol version] The path of a custom health check method with the format /package.service/method. The default is /AWS.ALB/healthcheck.  
*Required*: No  
*Type*: String  
*Minimum*: `1`  
*Maximum*: `1024`  
*Update requires*: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

`HealthCheckPort`  <a name="cfn-elasticloadbalancingv2-targetgroup-healthcheckport"></a>
The port the load balancer uses when performing health checks on targets. If the protocol is HTTP, HTTPS, TCP, TLS, UDP, TCP\$1UDP, QUIC, or TCP\$1QUIC the default is `traffic-port`, which is the port on which each target receives traffic from the load balancer. If the protocol is GENEVE, the default is port 80.  
*Required*: No  
*Type*: String  
*Update requires*: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

`HealthCheckProtocol`  <a name="cfn-elasticloadbalancingv2-targetgroup-healthcheckprotocol"></a>
The protocol the load balancer uses when performing health checks on targets. For Application Load Balancers, the default is HTTP. For Network Load Balancers and Gateway Load Balancers, the default is TCP. The TCP protocol is not supported for health checks if the protocol of the target group is HTTP or HTTPS. The GENEVE, TLS, UDP, TCP\$1UDP, QUIC, and TCP\$1QUIC protocols are not supported for health checks.  
*Required*: No  
*Type*: String  
*Allowed values*: `HTTP | HTTPS | TCP | TLS | UDP | TCP_UDP | GENEVE | QUIC | TCP_QUIC`  
*Update requires*: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

`HealthCheckTimeoutSeconds`  <a name="cfn-elasticloadbalancingv2-targetgroup-healthchecktimeoutseconds"></a>
The amount of time, in seconds, during which no response from a target means a failed health check. The range is 2–120 seconds. For target groups with a protocol of HTTP, the default is 6 seconds. For target groups with a protocol of TCP, TLS or HTTPS, the default is 10 seconds. For target groups with a protocol of GENEVE, the default is 5 seconds. If the target type is `lambda`, the default is 30 seconds.  
*Required*: No  
*Type*: Integer  
*Minimum*: `2`  
*Maximum*: `120`  
*Update requires*: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

`HealthyThresholdCount`  <a name="cfn-elasticloadbalancingv2-targetgroup-healthythresholdcount"></a>
The number of consecutive health check successes required before considering a target healthy. The range is 2-10. If the target group protocol is TCP, TCP\$1UDP, UDP, TLS, HTTP or HTTPS, the default is 5. For target groups with a protocol of GENEVE, the default is 5. If the target type is `lambda`, the default is 5.  
*Required*: No  
*Type*: Integer  
*Minimum*: `2`  
*Maximum*: `10`  
*Update requires*: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

`IpAddressType`  <a name="cfn-elasticloadbalancingv2-targetgroup-ipaddresstype"></a>
The IP address type. The default value is `ipv4`.  
*Required*: No  
*Type*: String  
*Allowed values*: `ipv4 | ipv6`  
*Update requires*: [Replacement](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-replacement)

`Matcher`  <a name="cfn-elasticloadbalancingv2-targetgroup-matcher"></a>
[HTTP/HTTPS health checks] The HTTP or gRPC codes to use when checking for a successful response from a target. For target groups with a protocol of TCP, TCP\$1UDP, UDP, QUIC, TCP\$1QUIC, or TLS the range is 200-599. For target groups with a protocol of HTTP or HTTPS, the range is 200-499. For target groups with a protocol of GENEVE, the range is 200-399.  
*Required*: No  
*Type*: [Matcher](aws-properties-elasticloadbalancingv2-targetgroup-matcher.md)  
*Update requires*: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

`Name`  <a name="cfn-elasticloadbalancingv2-targetgroup-name"></a>
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.  
*Required*: No  
*Type*: String  
*Update requires*: [Replacement](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-replacement)

`Port`  <a name="cfn-elasticloadbalancingv2-targetgroup-port"></a>
The port on which the targets receive traffic. This port is used unless you specify a port override when registering the target. If the target is a Lambda function, this parameter does not apply. If the protocol is GENEVE, the supported port is 6081.  
*Required*: Conditional  
*Type*: Integer  
*Minimum*: `1`  
*Maximum*: `65535`  
*Update requires*: [Replacement](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-replacement)

`Protocol`  <a name="cfn-elasticloadbalancingv2-targetgroup-protocol"></a>
The protocol to use for routing traffic to the targets. For Application Load Balancers, the supported protocols are HTTP and HTTPS. For Network Load Balancers, the supported protocols are TCP, TLS, UDP, TCP\$1UDP, QUIC, or TCP\$1QUIC. For Gateway Load Balancers, the supported protocol is GENEVE. A TCP\$1UDP listener must be associated with a TCP\$1UDP target group. A TCP\$1QUIC listener must be associated with a TCP\$1QUIC target group. If the target is a Lambda function, this parameter does not apply.  
*Required*: Conditional  
*Type*: String  
*Allowed values*: `HTTP | HTTPS | TCP | TLS | UDP | TCP_UDP | GENEVE | QUIC | TCP_QUIC`  
*Update requires*: [Replacement](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-replacement)

`ProtocolVersion`  <a name="cfn-elasticloadbalancingv2-targetgroup-protocolversion"></a>
[HTTP/HTTPS protocol] The protocol version. The possible values are `GRPC`, `HTTP1`, and `HTTP2`.  
*Required*: No  
*Type*: String  
*Update requires*: [Replacement](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-replacement)

`Tags`  <a name="cfn-elasticloadbalancingv2-targetgroup-tags"></a>
The tags.  
*Required*: No  
*Type*: Array of [Tag](aws-properties-elasticloadbalancingv2-targetgroup-tag.md)  
*Minimum*: `1`  
*Update requires*: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

`TargetControlPort`  <a name="cfn-elasticloadbalancingv2-targetgroup-targetcontrolport"></a>
The port on which the target control agent and application load balancer exchange management traffic for the target optimizer feature.  
*Required*: No  
*Type*: Integer  
*Minimum*: `1`  
*Maximum*: `65535`  
*Update requires*: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

`TargetGroupAttributes`  <a name="cfn-elasticloadbalancingv2-targetgroup-targetgroupattributes"></a>
The target group attributes. Attributes that you do not modify retain their current values.  
*Required*: No  
*Type*: Array of [TargetGroupAttribute](aws-properties-elasticloadbalancingv2-targetgroup-targetgroupattribute.md)  
*Update requires*: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

`Targets`  <a name="cfn-elasticloadbalancingv2-targetgroup-targets"></a>
The targets.  
*Required*: No  
*Type*: Array of [TargetDescription](aws-properties-elasticloadbalancingv2-targetgroup-targetdescription.md)  
*Update requires*: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

`TargetType`  <a name="cfn-elasticloadbalancingv2-targetgroup-targettype"></a>
The type of target that you must specify when registering targets with this target group. You can't specify targets for a target group using more than one target type.  
+ `instance` - Register targets by instance ID. This is the default value.
+ `ip` - Register targets by IP address. You can specify IP addresses from the subnets of the virtual private cloud (VPC) for the target group, the RFC 1918 range (10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16), and the RFC 6598 range (100.64.0.0/10). You can't specify publicly routable IP addresses.
+ `lambda` - Register a single Lambda function as a target.
+ `alb` - Register a single Application Load Balancer as a target.
*Required*: No  
*Type*: String  
*Allowed values*: `instance | ip | lambda | alb`  
*Update requires*: [Replacement](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-replacement)

`UnhealthyThresholdCount`  <a name="cfn-elasticloadbalancingv2-targetgroup-unhealthythresholdcount"></a>
The number of consecutive health check failures required before considering a target unhealthy. The range is 2-10. If the target group protocol is TCP, TCP\$1UDP, UDP, TLS, QUIC, TCP\$1QUIC, HTTP or HTTPS, the default is 2. For target groups with a protocol of GENEVE, the default is 2. If the target type is `lambda`, the default is 5.  
*Required*: No  
*Type*: Integer  
*Minimum*: `2`  
*Maximum*: `10`  
*Update requires*: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

`VpcId`  <a name="cfn-elasticloadbalancingv2-targetgroup-vpcid"></a>
The identifier of the virtual private cloud (VPC). If the target is a Lambda function, this parameter does not apply. Otherwise, this parameter is required.  
*Required*: Conditional  
*Type*: String  
*Update requires*: [Replacement](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-replacement)

## Return values
<a name="aws-resource-elasticloadbalancingv2-targetgroup-return-values"></a>

### Ref
<a name="aws-resource-elasticloadbalancingv2-targetgroup-return-values-ref"></a>

When you pass the logical ID of this resource to the intrinsic `Ref` function, `Ref` returns the Amazon Resource Name (ARN) of the target group.

For more information about using the `Ref` function, see [https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/intrinsic-function-reference-ref.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/intrinsic-function-reference-ref.html).

### Fn::GetAtt
<a name="aws-resource-elasticloadbalancingv2-targetgroup-return-values-fn--getatt"></a>

The `Fn::GetAtt` intrinsic function returns a value for a specified attribute of this type. The following are the available attributes and sample return values.

For more information about using the `Fn::GetAtt` intrinsic function, see [https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/intrinsic-function-reference-getatt.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/intrinsic-function-reference-getatt.html).

#### 
<a name="aws-resource-elasticloadbalancingv2-targetgroup-return-values-fn--getatt-fn--getatt"></a>

`LoadBalancerArns`  <a name="LoadBalancerArns-fn::getatt"></a>
The Amazon Resource Name (ARN) of the load balancer that routes traffic to this target group.

`TargetGroupArn`  <a name="TargetGroupArn-fn::getatt"></a>
The Amazon Resource Name (ARN) of the target group.

`TargetGroupFullName`  <a name="TargetGroupFullName-fn::getatt"></a>
The full name of the target group. For example, `targetgroup/my-target-group/cbf133c568e0d028`.

`TargetGroupName`  <a name="TargetGroupName-fn::getatt"></a>
The name of the target group. For example, `my-target-group`.

## Examples
<a name="aws-resource-elasticloadbalancingv2-targetgroup--examples"></a>

You can create target groups for use with your listener rules. For more information, see [AWS::ElasticLoadBalancingV2::ListenerRule](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticloadbalancingv2-listenerrule.html).

**Topics**
+ [Target group with instance targets](#aws-resource-elasticloadbalancingv2-targetgroup--examples--Target_group_with_instance_targets)
+ [Target group with ip targets](#aws-resource-elasticloadbalancingv2-targetgroup--examples--Target_group_with_ip_targets)
+ [Target group with QUIC targets](#aws-resource-elasticloadbalancingv2-targetgroup--examples--Target_group_with_QUIC_targets)
+ [Target group with an Application Load Balancer target](#aws-resource-elasticloadbalancingv2-targetgroup--examples--Target_group_with_an_Application_Load_Balancer_target)
+ [Target group with a Lambda target](#aws-resource-elasticloadbalancingv2-targetgroup--examples--Target_group_with_a_Lambda_target)

### Target group with instance targets
<a name="aws-resource-elasticloadbalancingv2-targetgroup--examples--Target_group_with_instance_targets"></a>

The following example creates a target group where the targets are EC2 instances.

#### YAML
<a name="aws-resource-elasticloadbalancingv2-targetgroup--examples--Target_group_with_instance_targets--yaml"></a>

```
myTargetGroup:
    Type: AWS::ElasticLoadBalancingV2::TargetGroup
    Properties:
      Name: my-target-group
      Protocol: HTTP
      Port: 80
      TargetType: instance
      VpcId: !Ref myVPC
      Targets:
        - Id: !GetAtt Instance1.InstanceId
          Port: 80
        - Id: !GetAtt Instance2.InstanceId
          Port: 80
```

#### JSON
<a name="aws-resource-elasticloadbalancingv2-targetgroup--examples--Target_group_with_instance_targets--json"></a>

```
{
    "myTargetGroup": {
        "Type": "AWS::ElasticLoadBalancingV2::TargetGroup",
        "Properties": {
            "Name": "my-target-group",
            "Protocol": "HTTP",
            "Port": 80,
            "TargetType": "instance",
            "VpcId": {
                "Ref": "myVPC"
            },
            "Targets": [
                {
                    "Id": {
                        "Fn::GetAtt": [
                            "Instance1",
                            "InstanceId"
                        ]
                    },
                    "Port": 80
                },
                {
                    "Id": {
                        "Fn::GetAtt": [
                            "Instance2",
                            "InstanceId"
                        ]
                    },
                    "Port": 80
                }
            ]
        }
    }
}
```

### Target group with ip targets
<a name="aws-resource-elasticloadbalancingv2-targetgroup--examples--Target_group_with_ip_targets"></a>

The following example creates a target group where the targets are IP addresses.

#### YAML
<a name="aws-resource-elasticloadbalancingv2-targetgroup--examples--Target_group_with_ip_targets--yaml"></a>

```
myTargetGroup:
    Type: AWS::ElasticLoadBalancingV2::TargetGroup
    Properties:
      Name: my-target-group
      Protocol: TCP
      Port: 80
      TargetType: ip
      VpcId: !Ref myVPC
      Targets:
        - Id: !GetAtt Instance1.PrivateIp
          Port: 80
        - Id: !GetAtt Instance2.PrivateIp
          Port: 80
```

#### JSON
<a name="aws-resource-elasticloadbalancingv2-targetgroup--examples--Target_group_with_ip_targets--json"></a>

```
{
    "myTargetGroup": {
        "Type": "AWS::ElasticLoadBalancingV2::TargetGroup",
        "Properties": {
            "Name": "my-target-group",
            "Protocol": "TCP",
            "Port": 80,
            "TargetType": "ip",
            "VpcId": {
                "Ref": "myVPC"
            },
            "Targets": [
                {
                    "Id": {
                        "Fn::GetAtt": [
                            "Instance1",
                            "PrivateIp"
                        ]
                    },
                    "Port": 80
                },
                {
                    "Id": {
                        "Fn::GetAtt": [
                            "Instance2",
                            "PrivateIp"
                        ]
                    },
                    "Port": 80
                }
            ]
        }
    }
}
```

### Target group with QUIC targets
<a name="aws-resource-elasticloadbalancingv2-targetgroup--examples--Target_group_with_QUIC_targets"></a>

The following example creates a target group where the targets are configured for QUIC traffic.

#### YAML
<a name="aws-resource-elasticloadbalancingv2-targetgroup--examples--Target_group_with_QUIC_targets--yaml"></a>

```
myTargetGroup:
    Type: AWS::ElasticLoadBalancingV2::TargetGroup
    Properties:
      Name: my-target-group
      Protocol: QUIC
      Port: 443
      TargetType: ip
      VpcId: !Ref myVPC
      Targets:
        - Id: !GetAtt Instance1.PrivateIp
          Port: 80
          QuicServerId: 0xa1b2c3d4e5f65890
        - Id: !GetAtt Instance2.PrivateIp
          Port: 80
          QuicServerId: 0xa1b2c3d4e5f65899
```

#### JSON
<a name="aws-resource-elasticloadbalancingv2-targetgroup--examples--Target_group_with_QUIC_targets--json"></a>

```
{
    "myTargetGroup": {
        "Type": "AWS::ElasticLoadBalancingV2::TargetGroup",
        "Properties": {
            "Name": "my-target-group",
            "Protocol": "QUIC",
            "Port": 443,
            "TargetType": "ip",
            "VpcId": {
                "Ref": "myVPC"
            },
            "Targets": [
                {
                    "Id": {
                        "Fn::GetAtt": [
                            "Instance1",
                            "PrivateIp"
                        ]
                    },
                    "Port": 80,
                    "QuicServerId": "0xa1b2c3d4e5f65890"
                },
                {
                    "Id": {
                        "Fn::GetAtt": [
                            "Instance2",
                            "PrivateIp"
                        ]
                    },
                    "Port": 80,
                    "QuicServerId": "0xa1b2c3d4e5f65899"
                }
            ]
        }
    }
}
```

### Target group with an Application Load Balancer target
<a name="aws-resource-elasticloadbalancingv2-targetgroup--examples--Target_group_with_an_Application_Load_Balancer_target"></a>

The following example creates a target group where the target is an Application Load Balancer. This target group must be used by a Network Load Balancer.

#### YAML
<a name="aws-resource-elasticloadbalancingv2-targetgroup--examples--Target_group_with_an_Application_Load_Balancer_target--yaml"></a>

```
myTargetGroup:
    Type: AWS::ElasticLoadBalancingV2::TargetGroup
    Properties:
      Name: my-target-group
      Protocol: TCP
      Port: 80
      TargetType: alb
      VpcId: !Ref albVPC
      Targets:
        - Id: !Ref myALB
          Port: 80
```

#### JSON
<a name="aws-resource-elasticloadbalancingv2-targetgroup--examples--Target_group_with_an_Application_Load_Balancer_target--json"></a>

```
{
    "myTargetGroup": {
        "Type": "AWS::ElasticLoadBalancingV2::TargetGroup",
        "Properties": {
            "Name": "my-target-group",
            "Protocol": "TCP",
            "Port": 80,
            "TargetType": "alb",
            "VpcId": {
                "Ref": "albVPC"
            },
            "Targets": [
                {
                    "Id": {
                        "Ref": "myALB"
                    },
                    "Port": 80
                }
            ]
        }
    }
}
```

### Target group with a Lambda target
<a name="aws-resource-elasticloadbalancingv2-targetgroup--examples--Target_group_with_a_Lambda_target"></a>

The following example creates a target group where the target is a Lambda function. This target group must be used by an Application Load Balancer.

#### YAML
<a name="aws-resource-elasticloadbalancingv2-targetgroup--examples--Target_group_with_a_Lambda_target--yaml"></a>

```
Resources:
  MyLambdaInvokePermission:
    Type: AWS::Lambda::Permission
    Properties:
      FunctionName: !GetAtt 
        - MyLambdaFunction
        - Arn
      Action: 'lambda:InvokeFunction'
      Principal: elasticloadbalancing.amazonaws.com

  MyTargetGroup:
    Type: AWS::ElasticLoadBalancingV2::TargetGroup
    Properties:
      HealthCheckEnabled: false
      Name: MyTargets
      TargetType: lambda
      Targets:
      - Id: !GetAtt [ MyLambdaFunction, Arn ]

  MyLambdaFunction:
    Type: "AWS::Lambda::Function"
    Properties:
      Handler: "index.handler"
      Role: !GetAtt [ LambdaExecutionRole, Arn ]
      Code:
        ZipFile: !Sub |
          import json
          
          def handler(event, context):
            response = {
              "statusCode": 200,
              "statusDescription": "200 OK",
              "isBase64Encoded": False,
              "headers": {
                "Content-Type": "text/html; charset=utf-8"
              }
            }

            response['body'] = """<html>
            <head>
            <title>Hello World!</title>
            <style>
            html, body {
              margin: 0; padding: 0;
              font-family: arial; font-weight: 700; font-size: 3em;
              text-align: center;
            }
            </style>
            </head>
            <body>
            <p>Hello World from Lambda</p>
            </body>
            </html>"""
            return response      
      Runtime: "runtime.version"
      Timeout: "25"

  LambdaExecutionRole:
    Type: "AWS::IAM::Role"
    Properties:
      AssumeRolePolicyDocument:
        Version: "2012-10-17"
        Statement:
          - Effect: Allow
            Principal:
              Service: lambda.amazonaws.com
            Action: "sts:AssumeRole"
```

## See also
<a name="aws-resource-elasticloadbalancingv2-targetgroup--seealso"></a>
+ [CreateTargetGroup](https://docs.aws.amazon.com/elasticloadbalancing/latest/APIReference/API_CreateTargetGroup.html) in the *Elastic Load Balancing API Reference (version 2015-12-01)*
+ [Target groups](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-target-groups.html) in the *User Guide for Application Load Balancers*
+ [Target groups](https://docs.aws.amazon.com/elasticloadbalancing/latest/network/load-balancer-target-groups.html) in the *User Guide for Network Load Balancers*
+ [Target groups](https://docs.aws.amazon.com/elasticloadbalancing/latest/gateway/target-groups.html) in the *User Guide for Gateway Load Balancers*



# AWS::ElasticLoadBalancingV2::TargetGroup Matcher
<a name="aws-properties-elasticloadbalancingv2-targetgroup-matcher"></a>

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

## Syntax
<a name="aws-properties-elasticloadbalancingv2-targetgroup-matcher-syntax"></a>

To declare this entity in your CloudFormation template, use the following syntax:

### JSON
<a name="aws-properties-elasticloadbalancingv2-targetgroup-matcher-syntax.json"></a>

```
{
  "[GrpcCode](#cfn-elasticloadbalancingv2-targetgroup-matcher-grpccode)" : String,
  "[HttpCode](#cfn-elasticloadbalancingv2-targetgroup-matcher-httpcode)" : String
}
```

### YAML
<a name="aws-properties-elasticloadbalancingv2-targetgroup-matcher-syntax.yaml"></a>

```
  [GrpcCode](#cfn-elasticloadbalancingv2-targetgroup-matcher-grpccode): String
  [HttpCode](#cfn-elasticloadbalancingv2-targetgroup-matcher-httpcode): String
```

## Properties
<a name="aws-properties-elasticloadbalancingv2-targetgroup-matcher-properties"></a>

`GrpcCode`  <a name="cfn-elasticloadbalancingv2-targetgroup-matcher-grpccode"></a>
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.  
*Required*: No  
*Type*: String  
*Update requires*: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

`HttpCode`  <a name="cfn-elasticloadbalancingv2-targetgroup-matcher-httpcode"></a>
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.  
*Required*: No  
*Type*: String  
*Update requires*: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

# AWS::ElasticLoadBalancingV2::TargetGroup Tag
<a name="aws-properties-elasticloadbalancingv2-targetgroup-tag"></a>

Information about a tag.

## Syntax
<a name="aws-properties-elasticloadbalancingv2-targetgroup-tag-syntax"></a>

To declare this entity in your CloudFormation template, use the following syntax:

### JSON
<a name="aws-properties-elasticloadbalancingv2-targetgroup-tag-syntax.json"></a>

```
{
  "[Key](#cfn-elasticloadbalancingv2-targetgroup-tag-key)" : String,
  "[Value](#cfn-elasticloadbalancingv2-targetgroup-tag-value)" : String
}
```

### YAML
<a name="aws-properties-elasticloadbalancingv2-targetgroup-tag-syntax.yaml"></a>

```
  [Key](#cfn-elasticloadbalancingv2-targetgroup-tag-key): String
  [Value](#cfn-elasticloadbalancingv2-targetgroup-tag-value): String
```

## Properties
<a name="aws-properties-elasticloadbalancingv2-targetgroup-tag-properties"></a>

`Key`  <a name="cfn-elasticloadbalancingv2-targetgroup-tag-key"></a>
The key of the tag.  
*Required*: Yes  
*Type*: String  
*Pattern*: `^([\p{L}\p{Z}\p{N}_.:/=+\-@]*)$`  
*Minimum*: `1`  
*Maximum*: `128`  
*Update requires*: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

`Value`  <a name="cfn-elasticloadbalancingv2-targetgroup-tag-value"></a>
The value of the tag.  
*Required*: Yes  
*Type*: String  
*Pattern*: `^([\p{L}\p{Z}\p{N}_.:/=+\-@]*)$`  
*Minimum*: `0`  
*Maximum*: `256`  
*Update requires*: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

## Examples
<a name="aws-properties-elasticloadbalancingv2-targetgroup-tag--examples"></a>

### 
<a name="aws-properties-elasticloadbalancingv2-targetgroup-tag--examples--"></a>

The following example creates a target group with two tags.

#### YAML
<a name="aws-properties-elasticloadbalancingv2-targetgroup-tag--examples----yaml"></a>

```
myTargetGroup:
    Type: 'AWS::ElasticLoadBalancingV2::TargetGroup'
    Properties:
      Name: my-target-group
      Protocol: HTTP
      Port: 80
      TargetType: instance
      VpcId: !Ref myVPC
      Tags: 
        - Key: "department"
          Value: "123"
        - Key: "project"
          Value: "lima"
```

#### JSON
<a name="aws-properties-elasticloadbalancingv2-targetgroup-tag--examples----json"></a>

```
{
    "myTargetGroup": {
        "Type": "AWS::ElasticLoadBalancingV2::TargetGroup",
        "Properties": {
            "Name": "my-target-group",
            "Protocol": "HTTP",
            "Port": 80,
            "TargetType": "instance",
            "VpcId": {
                "Ref": "myVPC"
            },
            "Tags": [
                {
                    "Key": "department",
                    "Value": "123"
                },
                {
                    "Key": "project",
                    "Value": "lima"
                }
            ]
        }
    }
}
```

# AWS::ElasticLoadBalancingV2::TargetGroup TargetDescription
<a name="aws-properties-elasticloadbalancingv2-targetgroup-targetdescription"></a>

Specifies a target to add to a target group.

## Syntax
<a name="aws-properties-elasticloadbalancingv2-targetgroup-targetdescription-syntax"></a>

To declare this entity in your CloudFormation template, use the following syntax:

### JSON
<a name="aws-properties-elasticloadbalancingv2-targetgroup-targetdescription-syntax.json"></a>

```
{
  "[AvailabilityZone](#cfn-elasticloadbalancingv2-targetgroup-targetdescription-availabilityzone)" : String,
  "[Id](#cfn-elasticloadbalancingv2-targetgroup-targetdescription-id)" : String,
  "[Port](#cfn-elasticloadbalancingv2-targetgroup-targetdescription-port)" : Integer,
  "[QuicServerId](#cfn-elasticloadbalancingv2-targetgroup-targetdescription-quicserverid)" : String
}
```

### YAML
<a name="aws-properties-elasticloadbalancingv2-targetgroup-targetdescription-syntax.yaml"></a>

```
  [AvailabilityZone](#cfn-elasticloadbalancingv2-targetgroup-targetdescription-availabilityzone): String
  [Id](#cfn-elasticloadbalancingv2-targetgroup-targetdescription-id): String
  [Port](#cfn-elasticloadbalancingv2-targetgroup-targetdescription-port): Integer
  [QuicServerId](#cfn-elasticloadbalancingv2-targetgroup-targetdescription-quicserverid): String
```

## Properties
<a name="aws-properties-elasticloadbalancingv2-targetgroup-targetdescription-properties"></a>

`AvailabilityZone`  <a name="cfn-elasticloadbalancingv2-targetgroup-targetdescription-availabilityzone"></a>
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`.  
*Required*: No  
*Type*: String  
*Update requires*: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

`Id`  <a name="cfn-elasticloadbalancingv2-targetgroup-targetdescription-id"></a>
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.   
*Required*: Yes  
*Type*: String  
*Update requires*: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

`Port`  <a name="cfn-elasticloadbalancingv2-targetgroup-targetdescription-port"></a>
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.  
*Required*: No  
*Type*: Integer  
*Minimum*: `1`  
*Maximum*: `65535`  
*Update requires*: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

`QuicServerId`  <a name="cfn-elasticloadbalancingv2-targetgroup-targetdescription-quicserverid"></a>
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.  
*Required*: No  
*Type*: String  
*Minimum*: `1`  
*Maximum*: `256`  
*Update requires*: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

# AWS::ElasticLoadBalancingV2::TargetGroup TargetGroupAttribute
<a name="aws-properties-elasticloadbalancingv2-targetgroup-targetgroupattribute"></a>

Specifies a target group attribute.

## Syntax
<a name="aws-properties-elasticloadbalancingv2-targetgroup-targetgroupattribute-syntax"></a>

To declare this entity in your CloudFormation template, use the following syntax:

### JSON
<a name="aws-properties-elasticloadbalancingv2-targetgroup-targetgroupattribute-syntax.json"></a>

```
{
  "[Key](#cfn-elasticloadbalancingv2-targetgroup-targetgroupattribute-key)" : String,
  "[Value](#cfn-elasticloadbalancingv2-targetgroup-targetgroupattribute-value)" : String
}
```

### YAML
<a name="aws-properties-elasticloadbalancingv2-targetgroup-targetgroupattribute-syntax.yaml"></a>

```
  [Key](#cfn-elasticloadbalancingv2-targetgroup-targetgroupattribute-key): String
  [Value](#cfn-elasticloadbalancingv2-targetgroup-targetgroupattribute-value): String
```

## Properties
<a name="aws-properties-elasticloadbalancingv2-targetgroup-targetgroupattribute-properties"></a>

`Key`  <a name="cfn-elasticloadbalancingv2-targetgroup-targetgroupattribute-key"></a>
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\$1UDP 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\$1UDP 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\$1UDP 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. 
*Required*: No  
*Type*: String  
*Pattern*: `^[a-zA-Z0-9._]+$`  
*Maximum*: `256`  
*Update requires*: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

`Value`  <a name="cfn-elasticloadbalancingv2-targetgroup-targetgroupattribute-value"></a>
The value of the attribute.  
*Required*: No  
*Type*: String  
*Update requires*: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

## Examples
<a name="aws-properties-elasticloadbalancingv2-targetgroup-targetgroupattribute--examples"></a>

You can optionally configure attributes for your target group.

**Topics**
+ [Update the deregistration delay value](#aws-properties-elasticloadbalancingv2-targetgroup-targetgroupattribute--examples--Update_the_deregistration_delay_value)
+ [Enable client IP preservation](#aws-properties-elasticloadbalancingv2-targetgroup-targetgroupattribute--examples--Enable_client_IP_preservation)

### Update the deregistration delay value
<a name="aws-properties-elasticloadbalancingv2-targetgroup-targetgroupattribute--examples--Update_the_deregistration_delay_value"></a>

The following example updates the deregistraction delay value for an Application Load Balancer.

#### YAML
<a name="aws-properties-elasticloadbalancingv2-targetgroup-targetgroupattribute--examples--Update_the_deregistration_delay_value--yaml"></a>

```
myTargetGroup:
  Type: 'AWS::ElasticLoadBalancingV2::TargetGroup'
  Properties:
    Name: my-target-group
    Protocol: HTTP
    Port: 80
    TargetType: ip
    VpcId: !Ref myVPC
    TargetGroupAttributes: 
      - Key: "deregistration_delay.timeout_seconds"
        Value: "60"
```

#### JSON
<a name="aws-properties-elasticloadbalancingv2-targetgroup-targetgroupattribute--examples--Update_the_deregistration_delay_value--json"></a>

```
{
    "myTargetGroup": {
        "Type": "AWS::ElasticLoadBalancingV2::TargetGroup",
        "Properties": {
            "Name": "my-target-group",
            "Protocol": "HTTP",
            "Port": 80,
            "TargetType": "ip",
            "VpcId": {
                "Ref": "myVPC"
            },
            "TargetGroupAttributes": [
                {
                    "Key": "deregistration_delay.timeout_seconds",
                    "Value": "60"
                }
            ]
        }
    }
}
```

### Enable client IP preservation
<a name="aws-properties-elasticloadbalancingv2-targetgroup-targetgroupattribute--examples--Enable_client_IP_preservation"></a>

The following example enables client IP preservation for a Network Load Balancer.

#### YAML
<a name="aws-properties-elasticloadbalancingv2-targetgroup-targetgroupattribute--examples--Enable_client_IP_preservation--yaml"></a>

```
myTargetGroup:
  Type: 'AWS::ElasticLoadBalancingV2::TargetGroup'
  Properties:
    Name: my-target-group
    Protocol: TCP
    Port: 80
    TargetType: ip
    VpcId: !Ref myVPC
    TargetGroupAttributes: 
      - Key: "preserve_client_ip.enabled"
        Value: "true"
```

#### JSON
<a name="aws-properties-elasticloadbalancingv2-targetgroup-targetgroupattribute--examples--Enable_client_IP_preservation--json"></a>

```
{
    "myTargetGroup": {
        "Type": "AWS::ElasticLoadBalancingV2::TargetGroup",
        "Properties": {
            "Name": "my-target-group",
            "Protocol": "TCP",
            "Port": 80,
            "TargetType": "ip",
            "VpcId": {
                "Ref": "myVPC"
            },
            "TargetGroupAttributes": [
                {
                    "Key": "preserve_client_ip.enabled",
                    "Value": "true"
                }
            ]
        }
    }
}
```