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

*************
attach_policy
*************



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

  

  Attaches the specified policy to the specified principal (certificate or other credential).

   

  Requires permission to access the `AttachPolicy <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/AttachPolicy>`_  


  **Request Syntax**
  ::

    response = client.attach_policy(
        policyName='string',
        target='string'
    )
    
  :type policyName: string
  :param policyName: **[REQUIRED]** 

    The name of the policy to attach.

    

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

    The `identity <https://docs.aws.amazon.com/iot/latest/developerguide/security-iam.html>`__ to which the policy is attached. For example, a thing group or a certificate.

    

  
  
  :returns: None
  **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`

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

  