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-roledel

Description

Deletes a role from your AWS account. You must remove any attached policies from the role before you can delete it.

To delete a role recursively, use the -c option. Recursively deleting the role automatically deletes the associated instance profile and role policies.

Important

Use the -c 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 -c option to list all the role's associated instance profiles without actually performing the recursive deletion.

Caution

Make sure you do not have any Amazon EC2 instances running with the role or instance profile you are about to delete. Deleting a role or instance profile that is associated with a running instance will break any applications running on the instance.

Syntax

iam-userdel -r ROLENAME [ -c [-p] ]

Options

Name Description Required

-r ROLENAME

Name of the role to delete.

Type: String

Default: None

Yes

-c

Deletes the role and deletes any associated instance profiles along with the role.

Type: String

Default: None

Optional

-c -p

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

Type: String

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

Default: None

Optional

Output

If the command is successful, the output is empty.

Examples

The following example deletes the role called myrole. This example assumes myrole has no associated instance profiles.

PROMPT> iam-roledel -r myrole

The following example shows what would be deleted if you were to recursively delete myrole.

PROMPT> iam-roledel -r myrole -c -p
instance profiles
     arn:aws:iam::123456789012:instance-profile/myinstanceprofile

The following example recursively deletes the role myrole.

PROMPT> iam-roledel -r myrole -c