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

*************
delete_policy
*************



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

  

  Deletes the specified policy.

   

  A policy cannot be deleted if it has non-default versions or it is attached to any certificate.

   

  To delete a policy, use the  DeletePolicyVersion action to delete all non-default versions of the policy; use the  DetachPolicy action to detach the policy from any certificate; and then use the DeletePolicy action to delete the policy.

   

  When a policy is deleted using DeletePolicy, its default version is deleted with it.

   

  .. note::

    

    Because of the distributed nature of Amazon Web Services, it can take up to five minutes after a policy is detached before it's ready to be deleted.

    

   

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


  **Request Syntax**
  ::

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

    The name of the policy to delete.

    

  
  
  :returns: None
  **Exceptions**
  
  *   :py:class:`IoT.Client.exceptions.DeleteConflictException`

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

  