:doc:`IoT <../../iot>` / Client / attach_thing_principal

**********************
attach_thing_principal
**********************



.. py:method:: IoT.Client.attach_thing_principal(**kwargs)

  

  Attaches the specified principal to the specified thing. A principal can be X.509 certificates, Amazon Cognito identities or federated identities.

   

  Requires permission to access the `AttachThingPrincipal <https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions>`__ action.

  

  See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/iot-2015-05-28/AttachThingPrincipal>`_  


  **Request Syntax**
  ::

    response = client.attach_thing_principal(
        thingName='string',
        principal='string',
        thingPrincipalType='EXCLUSIVE_THING'|'NON_EXCLUSIVE_THING'
    )
    
  :type thingName: string
  :param thingName: **[REQUIRED]** 

    The name of the thing.

    

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

    The principal, which can be a certificate ARN (as returned from the CreateCertificate operation) or an Amazon Cognito ID.

    

  
  :type thingPrincipalType: string
  :param thingPrincipalType: 

    The type of the relation you want to specify when you attach a principal to a thing.

     

    
    * ``EXCLUSIVE_THING`` - Attaches the specified principal to the specified thing, exclusively. The thing will be the only thing that’s attached to the principal.
    

     

    
    * ``NON_EXCLUSIVE_THING`` - Attaches the specified principal to the specified thing. Multiple things can be attached to the principal.
    

    

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

    
    ::

      {}
      
    **Response Structure**

    

    - *(dict) --* 

      The output from the AttachThingPrincipal operation.

      
  
  **Exceptions**
  
  *   :py:class:`IoT.Client.exceptions.ResourceNotFoundException`

  
  *   :py:class:`IoT.Client.exceptions.InvalidRequestException`

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

  
  *   :py:class:`IoT.Client.exceptions.UnauthorizedException`

  
  *   :py:class:`IoT.Client.exceptions.ServiceUnavailableException`

  
  *   :py:class:`IoT.Client.exceptions.InternalFailureException`

  