AWS Identity and Access Management
CLI Reference (API Version 2010-05-08)
« PreviousNext »
View the PDF for this guide.Go to the AWS Discussion Forum for this product.Did this page help you?  Yes | No |  Tell us about it...

iam-userdel

Description

Deletes a user from your AWS account. When this command is used only with the -u option, the user must not belong to any groups, have any keys or signing certificates, or have any attached policies.

To delete the user recursively, use the -r option. Recursively deleting the user automatically deletes it from any associated groups and deletes any attached entities such as keys, signing certificates, and policies.

Important

Use the -r option with caution. Before performing a recursive delete, to ensure you are not deleting anything you don't want to, use the -p option along with the -r option to list all the user's associated entities and groups without actually performing the recursive deletion.

Syntax

iam-userdel -u USERNAME [ -r [-p] ]

Options

Name Description Required

-u USERNAME

Name of the user to delete.

Type: String

Default: None

Yes

-r

Deletes the user from associated groups and deletes the user's credentials and policies along with the user.

Type: String

Default: None

Optional

-r -p

Returns what would be deleted, without actually recursively deleting the user. Use this before using -r to ensure you are not deleting anything you don't want to. The -p option indicates pretend mode; use only with the -r option.

Type: String

Constraints: You can apply -p only together with -r.

Default: None

Optional

Output

If the command is successful, the output is empty.

Examples

The following example deletes the user called Jack. This example assumes Jack is in no groups and has no policies.

PROMPT> iam-userdel -u Jack

The following example shows what would be deleted if you were to recursively delete the user Jack.

PROMPT> iam-userdel -u Jack -r -p
accesskeys
     AKIAIOSFODNN7EXAMPLE
policies
     KeyPolicy
certificates
     TA7SMP42TDN5Z26OBPJE7EXAMPLE
groups
     arn:aws:iam::123456789012:group/Managers
     arn:aws:iam::123456789012:group/Finance

The following example recursively deletes user Jack.

PROMPT> iam-userdel -u Jack -r