Delete an IAM role policy using an AWS SDK - AWS SDK Code Examples

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

Delete an IAM role policy using an AWS SDK

The following code example shows how to delete an IAM role policy.


There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

using System; using System.Threading.Tasks; using Amazon.IdentityManagement; using Amazon.IdentityManagement.Model; public class DeleteRolePolicy { /// <summary> /// Initializes the IAM client object and then calls DeleteRolePolicyAsync /// to delete the Policy attached to the Role. /// </summary> public static async Task Main() { var client = new AmazonIdentityManagementServiceClient(); var response = await client.DeleteRolePolicyAsync(new DeleteRolePolicyRequest { PolicyName = "ExamplePolicy", RoleName = "Test-Role", }); if (response.HttpStatusCode == System.Net.HttpStatusCode.OK) { Console.WriteLine("Policy successfully deleted."); } else { Console.WriteLine("Could not delete pollicy."); } } }