Remove or deactivate an IAM user
Best practices recommend that you remove unused IAM users from your AWS account. If you want to retain the IAM users credentials for future use, instead of deleting them from the account you can deactivate the user's access. For more information, see Deactivating an IAM user.
Prerequisite – View IAM user access
Before you remove a user, review their recent service-level activity. This helps prevent removing access from a principal (person or application) who is using it. For more information about viewing last accessed information, see Refine permissions in AWS using last accessed information.
Removing an IAM user (console)
When you use the AWS Management Console to remove an IAM user, IAM automatically deletes the following associated information:
-
The IAM user identifier
-
Any group memberships—that is, the IAM user is removed from any groups that the IAM user was a member of
-
Any password associated with the IAM user
-
Any access keys belonging to the IAM user
-
All inline policies embedded in the IAM user (policies that were applied to the IAM user using user group permissions are not affected)
Note
IAM removes any managed policies attached to the IAM user when you delete the user, but does not delete managed policies.
-
Any associated MFA device
To remove an IAM user (console)
Deleting an IAM user (AWS CLI)
Unlike the AWS Management Console, when you delete a IAM user with the AWS CLI, you must delete the items attached to the IAM user manually. This procedure illustrates the process.
To delete an IAM user from your AWS account (AWS CLI)
-
Delete the user's password, if the user has one.
-
Delete the user's access keys, if the user has them.
aws iam list-access-keys
(to list the user's access keys) andaws iam delete-access-key
-
Delete the user's signing certificate. Note that when you delete a security credential, it's gone forever and can't be retrieved.
aws iam list-signing-certificates
(to list the user's signing certificates) andaws iam delete-signing-certificate
-
Delete the user's SSH public key, if the user has them.
aws iam list-ssh-public-keys
(to list the user's SSH public keys) andaws iam delete-ssh-public-key
-
Delete the user's Git credentials.
aws iam list-service-specific-credentials
(to list the user's git credentials) andaws iam delete-service-specific-credential
-
Deactivate the user's multi-factor authentication (MFA) device, if the user has one.
aws iam list-mfa-devices
(to list the user's MFA devices),aws iam deactivate-mfa-device
(to deactivate the device), andaws iam delete-virtual-mfa-device
(to permanently delete a virtual MFA device) -
Delete the user's inline policies.
aws iam list-user-policies
(to list the inline policies for the user) andaws iam delete-user-policy
(to delete the policy) -
Detach any managed policies that are attached to the user.
aws iam list-attached-user-policies
(to list the managed policies attached to the user) andaws iam detach-user-policy
(to detach the policy) -
Remove the user from any IAM groups.
aws iam list-groups-for-user
(to list the IAM groups to which the user belongs) andaws iam remove-user-from-group
-
Delete the user.
Deactivating an IAM user
You might need to deactivate an IAM user while they are temporarily away from your company. You can leave their IAM user credentials in place and still block their AWS access.
To deactivate a user, create and attach a policy to deny the user access to AWS. You can restore the user's access later.
Here are two examples of deny policies that you can attach to a user to deny their access.
The following policy does not include a time limit. You must remove the policy to restore the user's access.
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Deny", "Action": "*", "Resource": "*" } ] }
The following policy includes a condition that starts the policy on December 24, 2024 at 11:59 PM (UTC) and ends it on February 28, 2025 at 11:59 PM (UTC).
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Deny", "Action": "*", "Resource": "*", "Condition": { "DateGreaterThan": {"aws:CurrentTime": "2024-12-24T23:59:59Z"}, "DateLessThan": {"aws:CurrentTime": "2025-02-28T23:59:59Z"} } } ] }