:doc:`VPCLattice <../../vpc-lattice>` / Client / create_target_group

*******************
create_target_group
*******************



.. py:method:: VPCLattice.Client.create_target_group(**kwargs)

  

  Creates a target group. A target group is a collection of targets, or compute resources, that run your application or service. A target group can only be used by a single service.

   

  For more information, see `Target groups <https://docs.aws.amazon.com/vpc-lattice/latest/ug/target-groups.html>`__ in the *Amazon VPC Lattice User Guide*.

  

  See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/vpc-lattice-2022-11-30/CreateTargetGroup>`_  


  **Request Syntax**
  ::

    response = client.create_target_group(
        name='string',
        type='IP'|'LAMBDA'|'INSTANCE'|'ALB',
        config={
            'port': 123,
            'protocol': 'HTTP'|'HTTPS'|'TCP',
            'protocolVersion': 'HTTP1'|'HTTP2'|'GRPC',
            'ipAddressType': 'IPV4'|'IPV6',
            'vpcIdentifier': 'string',
            'healthCheck': {
                'enabled': True|False,
                'protocol': 'HTTP'|'HTTPS'|'TCP',
                'protocolVersion': 'HTTP1'|'HTTP2',
                'port': 123,
                'path': 'string',
                'healthCheckIntervalSeconds': 123,
                'healthCheckTimeoutSeconds': 123,
                'healthyThresholdCount': 123,
                'unhealthyThresholdCount': 123,
                'matcher': {
                    'httpCode': 'string'
                }
            },
            'lambdaEventStructureVersion': 'V1'|'V2'
        },
        clientToken='string',
        tags={
            'string': 'string'
        }
    )
    
  :type name: string
  :param name: **[REQUIRED]** 

    The name of the target group. The name must be unique within the account. The valid characters are a-z, 0-9, and hyphens (-). You can't use a hyphen as the first or last character, or immediately after another hyphen.

    

  
  :type type: string
  :param type: **[REQUIRED]** 

    The type of target group.

    

  
  :type config: dict
  :param config: 

    The target group configuration.

    

  
    - **port** *(integer) --* 

      The port on which the targets are listening. For HTTP, the default is 80. For HTTPS, the default is 443. Not supported if the target group type is ``LAMBDA``.

      

    
    - **protocol** *(string) --* 

      The protocol to use for routing traffic to the targets. The default is the protocol of the target group. Not supported if the target group type is ``LAMBDA``.

      

    
    - **protocolVersion** *(string) --* 

      The protocol version. The default is ``HTTP1``. Not supported if the target group type is ``LAMBDA``.

      

    
    - **ipAddressType** *(string) --* 

      The type of IP address used for the target group. Supported only if the target group type is ``IP``. The default is ``IPV4``.

      

    
    - **vpcIdentifier** *(string) --* 

      The ID of the VPC. Not supported if the target group type is ``LAMBDA``.

      

    
    - **healthCheck** *(dict) --* 

      The health check configuration. Not supported if the target group type is ``LAMBDA`` or ``ALB``.

      

    
      - **enabled** *(boolean) --* 

        Indicates whether health checking is enabled.

        

      
      - **protocol** *(string) --* 

        The protocol used when performing health checks on targets. The possible protocols are ``HTTP`` and ``HTTPS``. The default is ``HTTP``.

        

      
      - **protocolVersion** *(string) --* 

        The protocol version used when performing health checks on targets. The possible protocol versions are ``HTTP1`` and ``HTTP2``.

        

      
      - **port** *(integer) --* 

        The port used when performing health checks on targets. The default setting is the port that a target receives traffic on.

        

      
      - **path** *(string) --* 

        The destination for health checks on the targets. If the protocol version is ``HTTP/1.1`` or ``HTTP/2``, specify a valid URI (for example, ``/path?query``). The default path is ``/``. Health checks are not supported if the protocol version is ``gRPC``, however, you can choose ``HTTP/1.1`` or ``HTTP/2`` and specify a valid URI.

        

      
      - **healthCheckIntervalSeconds** *(integer) --* 

        The approximate amount of time, in seconds, between health checks of an individual target. The range is 5–300 seconds. The default is 30 seconds.

        

      
      - **healthCheckTimeoutSeconds** *(integer) --* 

        The amount of time, in seconds, to wait before reporting a target as unhealthy. The range is 1–120 seconds. The default is 5 seconds.

        

      
      - **healthyThresholdCount** *(integer) --* 

        The number of consecutive successful health checks required before considering an unhealthy target healthy. The range is 2–10. The default is 5.

        

      
      - **unhealthyThresholdCount** *(integer) --* 

        The number of consecutive failed health checks required before considering a target unhealthy. The range is 2–10. The default is 2.

        

      
      - **matcher** *(dict) --* 

        The codes to use when checking for a successful response from a target.

        .. note::    This is a Tagged Union structure. Only one of the     following top level keys can be set: ``httpCode``. 

      
        - **httpCode** *(string) --* 

          The HTTP code to use when checking for a successful response from a target.

          

        
      
    
    - **lambdaEventStructureVersion** *(string) --* 

      The version of the event structure that your Lambda function receives. Supported only if the target group type is ``LAMBDA``. The default is ``V1``.

      

    
  
  :type clientToken: string
  :param clientToken: 

    A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. If you retry a request that completed successfully using the same client token and parameters, the retry succeeds without performing any actions. If the parameters aren't identical, the retry fails.

    This field is autopopulated if not provided.

  
  :type tags: dict
  :param tags: 

    The tags for the target group.

    

  
    - *(string) --* 

      The key of the tag.

       

      Constraints: Tag keys are case-sensitive and accept a maximum of 128 Unicode characters. Valid characters are Unicode letters, digits, white space, and any of the following symbols: _ . : / = + - @ May not begin with ``aws:``.

      

    
      - *(string) --* 

        The value of the tag.

         

        Constraints: Tag values are case-sensitive and accept a maximum of 256 Unicode characters. Valid characters are Unicode letters, digits, white space, and any of the following symbols: _ . : / = + - @

        

      


  
  :rtype: dict
  :returns: 
    
    **Response Syntax**

    
    ::

      {
          'id': 'string',
          'arn': 'string',
          'name': 'string',
          'type': 'IP'|'LAMBDA'|'INSTANCE'|'ALB',
          'config': {
              'port': 123,
              'protocol': 'HTTP'|'HTTPS'|'TCP',
              'protocolVersion': 'HTTP1'|'HTTP2'|'GRPC',
              'ipAddressType': 'IPV4'|'IPV6',
              'vpcIdentifier': 'string',
              'healthCheck': {
                  'enabled': True|False,
                  'protocol': 'HTTP'|'HTTPS'|'TCP',
                  'protocolVersion': 'HTTP1'|'HTTP2',
                  'port': 123,
                  'path': 'string',
                  'healthCheckIntervalSeconds': 123,
                  'healthCheckTimeoutSeconds': 123,
                  'healthyThresholdCount': 123,
                  'unhealthyThresholdCount': 123,
                  'matcher': {
                      'httpCode': 'string'
                  }
              },
              'lambdaEventStructureVersion': 'V1'|'V2'
          },
          'status': 'CREATE_IN_PROGRESS'|'ACTIVE'|'DELETE_IN_PROGRESS'|'CREATE_FAILED'|'DELETE_FAILED'
      }
      
    **Response Structure**

    

    - *(dict) --* 
      

      - **id** *(string) --* 

        The ID of the target group.

        
      

      - **arn** *(string) --* 

        The Amazon Resource Name (ARN) of the target group.

        
      

      - **name** *(string) --* 

        The name of the target group.

        
      

      - **type** *(string) --* 

        The type of target group.

        
      

      - **config** *(dict) --* 

        The target group configuration.

        
        

        - **port** *(integer) --* 

          The port on which the targets are listening. For HTTP, the default is 80. For HTTPS, the default is 443. Not supported if the target group type is ``LAMBDA``.

          
        

        - **protocol** *(string) --* 

          The protocol to use for routing traffic to the targets. The default is the protocol of the target group. Not supported if the target group type is ``LAMBDA``.

          
        

        - **protocolVersion** *(string) --* 

          The protocol version. The default is ``HTTP1``. Not supported if the target group type is ``LAMBDA``.

          
        

        - **ipAddressType** *(string) --* 

          The type of IP address used for the target group. Supported only if the target group type is ``IP``. The default is ``IPV4``.

          
        

        - **vpcIdentifier** *(string) --* 

          The ID of the VPC. Not supported if the target group type is ``LAMBDA``.

          
        

        - **healthCheck** *(dict) --* 

          The health check configuration. Not supported if the target group type is ``LAMBDA`` or ``ALB``.

          
          

          - **enabled** *(boolean) --* 

            Indicates whether health checking is enabled.

            
          

          - **protocol** *(string) --* 

            The protocol used when performing health checks on targets. The possible protocols are ``HTTP`` and ``HTTPS``. The default is ``HTTP``.

            
          

          - **protocolVersion** *(string) --* 

            The protocol version used when performing health checks on targets. The possible protocol versions are ``HTTP1`` and ``HTTP2``.

            
          

          - **port** *(integer) --* 

            The port used when performing health checks on targets. The default setting is the port that a target receives traffic on.

            
          

          - **path** *(string) --* 

            The destination for health checks on the targets. If the protocol version is ``HTTP/1.1`` or ``HTTP/2``, specify a valid URI (for example, ``/path?query``). The default path is ``/``. Health checks are not supported if the protocol version is ``gRPC``, however, you can choose ``HTTP/1.1`` or ``HTTP/2`` and specify a valid URI.

            
          

          - **healthCheckIntervalSeconds** *(integer) --* 

            The approximate amount of time, in seconds, between health checks of an individual target. The range is 5–300 seconds. The default is 30 seconds.

            
          

          - **healthCheckTimeoutSeconds** *(integer) --* 

            The amount of time, in seconds, to wait before reporting a target as unhealthy. The range is 1–120 seconds. The default is 5 seconds.

            
          

          - **healthyThresholdCount** *(integer) --* 

            The number of consecutive successful health checks required before considering an unhealthy target healthy. The range is 2–10. The default is 5.

            
          

          - **unhealthyThresholdCount** *(integer) --* 

            The number of consecutive failed health checks required before considering a target unhealthy. The range is 2–10. The default is 2.

            
          

          - **matcher** *(dict) --* 

            The codes to use when checking for a successful response from a target.

            .. note::    This is a Tagged Union structure. Only one of the     following top level keys will be set: ``httpCode``.     If a client receives an unknown member it will     set ``SDK_UNKNOWN_MEMBER`` as the top level key,     which maps to the name or tag of the unknown     member. The structure of ``SDK_UNKNOWN_MEMBER`` is     as follows::

                        'SDK_UNKNOWN_MEMBER': {'name': 'UnknownMemberName'}


          
            

            - **httpCode** *(string) --* 

              The HTTP code to use when checking for a successful response from a target.

              
        
      
        

        - **lambdaEventStructureVersion** *(string) --* 

          The version of the event structure that your Lambda function receives. Supported only if the target group type is ``LAMBDA``. The default is ``V1``.

          
    
      

      - **status** *(string) --* 

        The status. You can retry the operation if the status is ``CREATE_FAILED``. However, if you retry it while the status is ``CREATE_IN_PROGRESS``, there is no change in the status.

        
  
  **Exceptions**
  
  *   :py:class:`VPCLattice.Client.exceptions.ValidationException`

  
  *   :py:class:`VPCLattice.Client.exceptions.AccessDeniedException`

  
  *   :py:class:`VPCLattice.Client.exceptions.ConflictException`

  
  *   :py:class:`VPCLattice.Client.exceptions.ResourceNotFoundException`

  
  *   :py:class:`VPCLattice.Client.exceptions.ThrottlingException`

  
  *   :py:class:`VPCLattice.Client.exceptions.ServiceQuotaExceededException`

  
  *   :py:class:`VPCLattice.Client.exceptions.InternalServerException`

  