Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅中国的 Amazon Web Services 服务入门。使用 Amazon 开发工具包删除 IAM 角色策略
以下代码示例显示如何删除 IAM 角色策略。
- .NET
-
- Amazon SDK for .NET
-
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.");
}
}
}
有关 Amazon 软件开发工具包开发人员指南和代码示例的完整列表,请参阅 将 IAM 与 Amazon 开发工具包配合使用。本主题还包括有关入门的信息以及有关先前的软件开发工具包版本的详细信息。