Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Use DeleteGroup with an AWS SDK or CLI

Focus mode
Use DeleteGroup with an AWS SDK or CLI - AWS Identity and Access Management

The following code examples show how to use DeleteGroup.

CLI
AWS CLI

To delete an IAM group

The following delete-group command deletes an IAM group named MyTestGroup.

aws iam delete-group \ --group-name MyTestGroup

This command produces no output.

For more information, see Deleting an IAM user group in the AWS IAM User Guide.

  • For API details, see DeleteGroup in AWS CLI Command Reference.

JavaScript
SDK for JavaScript (v3)
Note

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

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; };
  • For API details, see DeleteGroup in AWS SDK for JavaScript API Reference.

PowerShell
Tools for PowerShell

Example 1: This example deletes the IAM group named MyTestGroup. The first command removes any IAM users that are members of the group, and the second command deletes the IAM group. Both commands work without any prompts for confirmation.

(Get-IAMGroup -GroupName MyTestGroup).Users | Remove-IAMUserFromGroup -GroupName MyTestGroup -Force Remove-IAMGroup -GroupName MyTestGroup -Force
  • For API details, see DeleteGroup in AWS Tools for PowerShell Cmdlet Reference.

AWS CLI

To delete an IAM group

The following delete-group command deletes an IAM group named MyTestGroup.

aws iam delete-group \ --group-name MyTestGroup

This command produces no output.

For more information, see Deleting an IAM user group in the AWS IAM User Guide.

  • For API details, see DeleteGroup in AWS CLI Command Reference.

For a complete list of AWS SDK developer guides and code examples, see Using this service with an AWS SDK. This topic also includes information about getting started and details about previous SDK versions.

PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.