delete_policy

delete_policy(**kwargs)

Deletes the specified policy from your organization. Before you perform this operation, you must first detach the policy from all organizational units (OUs), roots, and accounts.

This operation can be called only from the organization's management account.

See also: AWS API Documentation

Request Syntax

response = client.delete_policy(
    PolicyId='string'
)
Parameters
PolicyId (string) --

[REQUIRED]

The unique identifier (ID) of the policy that you want to delete. You can get the ID from the ListPolicies or ListPoliciesForTarget operations.

The regex pattern for a policy ID string requires "p-" followed by from 8 to 128 lowercase or uppercase letters, digits, or the underscore character (_).

Returns
None

Exceptions

  • Organizations.Client.exceptions.AccessDeniedException
  • Organizations.Client.exceptions.AWSOrganizationsNotInUseException
  • Organizations.Client.exceptions.ConcurrentModificationException
  • Organizations.Client.exceptions.InvalidInputException
  • Organizations.Client.exceptions.PolicyInUseException
  • Organizations.Client.exceptions.PolicyNotFoundException
  • Organizations.Client.exceptions.ServiceException
  • Organizations.Client.exceptions.TooManyRequestsException
  • Organizations.Client.exceptions.UnsupportedAPIEndpointException

Examples

The following example shows how to delete a policy from an organization. The example assumes that you previously detached the policy from all entities:

response = client.delete_policy(
    PolicyId='p-examplepolicyid111',
)

print(response)

Expected Output:

{
    'ResponseMetadata': {
        '...': '...',
    },
}