You may sometimes encounter the below-mentioned error while deleting IAM Policies
"The policy could not be deleted
Detach the policy from any buckets or users utilizing it and try again"
Here are the steps to correctly delete IAM Policies
1. Detach the IAM Policy from all entities
Go to your IAM Policy and check to see if this policy is attached to any Users, Groups, or Roles. You would be able to see the attachment count and Policy Usage as shown in this example screenshot below
Now, detach all Users, Groups, or Roles from your Policy until you see Attachment Count as '0'.
2. Delete all older versions of the same Policy
Your Policy could also be having multiple versions and hence, we need to delete all older versions of that policy (see screenshot below) until you are left with the default version only.
3. Now you may successfully delete the policy