DeletePolicy
Deletes the specified managed policy.
Before you can delete a managed policy, you must first detach the policy from all users, groups, and roles that it is attached to. In addition, you must delete all the policy's versions. The following steps describe the process for deleting a managed policy:
- Detach the policy from all roles that the policy is attached to, using DetachRolePolicy. To list all the roles that a policy is attached to, use ListEntitiesForPolicy.
- Delete all versions of the policy using DeletePolicyVersion. To list the policy's versions, use ListPolicyVersions. You cannot use DeletePolicyVersion to delete the version that is marked as the default version. You delete the policy's default version in the next step of the process.
- Delete the policy (this automatically deletes the policy's default version) using this operation.
For information about managed policies, see Managed policies and inline policies in the IAM User Guide.
Permissions
Action | Description | Resource |
---|---|---|
DeletePolicy | Grants permission to delete the specified managed policy and remove it from any IAM entities (users, groups, or roles) to which it is attached | policy |
Request Parameters
For information about the parameters that are common to all actions, see Common Parameters.
PolicyArn
The Amazon Resource Name (ARN) of the IAM policy you want to delete.
For more information about ARNs, see Amazon Resource Names (ARNs) in the AWS General Reference.
Type: String
Length Constraints: Minimum length of 20. Maximum length of 2048.
Required: Yes
Errors
DeleteConflict
The request was rejected because it attempted to delete a resource that has attached subordinate entities. The error message describes these entities.
HTTP Status Code: 409
InvalidInput
The request was rejected because an invalid or out-of-range value was supplied for an input parameter.
HTTP Status Code: 400
LimitExceeded
The request was rejected because it attempted to create resources beyond the current AWS account limits. The error message describes the limit exceeded.
HTTP Status Code: 409
NoSuchEntity
The request was rejected because it referenced a resource entity that does not exist. The error message describes the resource.
HTTP Status Code: 404
InternalError
The request processing has failed because of an unknown error, exception or failure.
HTTP Status Code: 500
Examples
Example
This example illustrates one usage of DeletePolicy.
https://<partition>.iam.astran.io/?Action=DeletePolicy
&PolicyArn=arn:aws:iam::123456789012:policy/S3-read-only-example-bucket
&Version=2010-05-08
&AUTHPARAMS
<DeletePolicyResponse xmlns="https://iam.amazonaws.com/doc/2010-05-08/">
<ResponseMetadata>
<RequestId>4706281b-3d19-11e4-a4a0-cffb9EXAMPLE</RequestId>
</ResponseMetadata>
</DeletePolicyResponse>
See Also
For more information about using this API in one of the language-specific AWS SDKs, see the following: