Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅
中国的 Amazon Web Services 服务入门
(PDF)。
使用 Amazon SDK 删除 IAM 组
以下代码示例显示了如何删除 IAM 组。
- .NET
-
- Amazon SDK for .NET
-
/// <summary>
/// Delete an IAM group.
/// </summary>
/// <param name="groupName">The name of the IAM group to delete.</param>
/// <returns>A Boolean value indicating the success of the action.</returns>
public async Task<bool> DeleteGroupAsync(string groupName)
{
var response = await _IAMService.DeleteGroupAsync(new DeleteGroupRequest { GroupName = groupName });
return response.HttpStatusCode == HttpStatusCode.OK;
}
- JavaScript
-
- SDK for JavaScript (v3)
-
import { DeleteGroupCommand, IAMClient } from "@aws-sdk/client-iam";
const client = new IAMClient({});
/**
*
* @param {string} groupName
*/
export const deleteGroup = async (groupName) => {
const command = new DeleteGroupCommand({
GroupName: groupName,
});
const response = await client.send(command);
console.log(response);
return response;
};
有关 Amazon 软件开发工具包开发人员指南和代码示例的完整列表,请参阅 将 IAM 与 Amazon 开发工具包配合使用。本主题还包括有关入门的信息以及有关先前的软件开发工具包版本的详细信息。