# aws iam update-access-key

AWS CLI commands · Updated 16 November 2026

**Short answer:** aws iam update-access-key --user-name my-user --access-key-id AKIA... --status Inactive switches an IAM user's access key off without deleting it. Requests signed with an inactive key are rejected, and you can turn it back on with --status Active if something important breaks.

## What the command does

It changes one key's status between `Active` and `Inactive`. Nothing else about the key changes; the secret stays the same. That makes deactivation the safe middle step between "this key looks unused" and deleting it, and the fast first response when a key may have leaked.

The call returns no output on success. Like other IAM changes, it takes effect across AWS within seconds, though not necessarily instantly everywhere.

## Syntax

```
aws iam update-access-key \
  --access-key-id <AKIA...> \
  --status Active|Inactive \
  [--user-name <user>]
```

## Worked examples

**Deactivate a key that may be compromised:**

```
aws iam update-access-key --user-name ci-deploy \
  --access-key-id AKIAIOSFODNN7EXAMPLE --status Inactive
```

**Confirm the change:**

```
aws iam list-access-keys --user-name ci-deploy \
  --query "AccessKeyMetadata[].[AccessKeyId,Status]" --output text
```

**Reactivate** if a forgotten integration turns out to need it:

```
aws iam update-access-key --user-name ci-deploy \
  --access-key-id AKIAIOSFODNN7EXAMPLE --status Active
```

**Delete once you are sure** (irreversible):

```
aws iam delete-access-key --user-name ci-deploy \
  --access-key-id AKIAIOSFODNN7EXAMPLE
```

## Responding to a leaked key

1. **Deactivate it now** with the command above. Do not wait to find out who uses it.
2. **Find the owner and what it could do.** `aws iam get-access-key-last-used` gives the user; their policies define the blast radius.
3. **Look for misuse in CloudTrail.** Filter events by the key ID to see what was called, from where, and whether new users, keys or roles were created.
4. **Issue a replacement** with [create-access-key](https://cloudconsole.dev/cli/iam-create-access-key) for the legitimate workload, or better, move it to a role.
5. **Delete the old key** once the replacement is in place, and revoke anything an attacker may have created.

## Deciding what is safe to switch off

Before deactivating a key that is merely suspected to be unused, check its last-used date and service. A key last used yesterday by S3 in `eu-west-2` is clearly live; one with no recorded use since creation is a strong candidate. Tell the owner of the user before you act if you can, and record the time you deactivated it: if a nightly job fails a few hours later, that timestamp is what connects the two.

## Rotation, step by step

| Step | Command |
|---|---|
| Create second key | `aws iam create-access-key --user-name ci-deploy` |
| Deploy the new key everywhere | (your secret store / CI settings) |
| Check the old key stopped being used | `aws iam get-access-key-last-used --access-key-id <old>` |
| Deactivate the old key | `aws iam update-access-key ... --status Inactive` |
| Wait a safe period, then delete | `aws iam delete-access-key ...` |

## Gotchas

- **Temporary credentials are not covered.** Session credentials already issued by STS to that user (for example via `get-session-token`) are separate; to cut those off, attach a deny policy conditioned on token issue time, as the IAM console's revoke-sessions feature does for roles.
- **Status values are case-sensitive:** `Active` and `Inactive`.
- **You can lock yourself out.** Deactivating the key your own CLI uses ends your session immediately. Make sure you have another way in.
- **Omitting `--user-name`** targets the calling IAM user's own key.

## Questions

### Is deactivating an access key reversible?

Yes. Set --status Active again and the same key works. Deleting is not reversible.

### How quickly does deactivating a key take effect?

Within seconds in practice, though IAM is eventually consistent, so a request or two may still succeed right after the change.

### What happens to applications using an inactive key?

Their requests fail with an authentication error, typically InvalidClientTokenId or a security-token error, until you reactivate the key or give them a new one.

## When this happens away from your desk

Leaked-key alerts arrive at any hour and the first move is time-critical. CloudConsole is built to bring AWS alarms and resource details to a phone, with guardrails around production changes.

[About the CloudConsole app](https://cloudconsole.dev/aws-console-app) · [Download on the App Store](https://apps.apple.com/app/cloudconsole-for-aws/id6835419710)

## Sources

- [aws iam update-access-key (AWS CLI Command Reference)](https://docs.aws.amazon.com/cli/latest/reference/iam/update-access-key.html)
- [Manage access keys for IAM users (IAM User Guide)](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html)

## Related

- [How to rotate IAM access keys](https://cloudconsole.dev/how-to/rotate-iam-access-keys)
- [aws iam list-access-keys](https://cloudconsole.dev/cli/iam-list-access-keys)
- [aws iam create-access-key](https://cloudconsole.dev/cli/iam-create-access-key)
- [InvalidClientTokenId: The security token included in the request is invalid](https://cloudconsole.dev/errors/invalidclienttokenid)
- [How to find unused IAM access keys](https://cloudconsole.dev/how-to/find-unused-iam-access-keys)
- [aws iam create-role](https://cloudconsole.dev/cli/iam-create-role)

---

Source: https://cloudconsole.dev/cli/iam-update-access-key

CloudConsole is an independent iPhone and Android app for Amazon Web Services by Cloudconcur Ltd. It is not affiliated with Amazon Web Services.
