Skip to content

How-to: Rotate AWS IAM access keys

Rotate an IAM user's access keys with zero downtime using the two-key overlap.

How-toCreated Updated

Also:rotate keys · access key rotation · iam · InvalidClientTokenId · key older than 90 days

Security Hub / Trusted Advisor flags a key older than 90 days, or a key may have leaked. (If it leaked: deactivate the old key first, then do this.)

Prereqs: iam:CreateAccessKey, iam:UpdateAccessKey, iam:DeleteAccessKey on the user; know every place the key is used (CI secrets, servers, ~/.aws/credentials).

  1. Confirm who you are: AWS: Check which identity you are using

  2. List the user’s keys and their age (an IAM user can have at most two):

    Terminal window
    aws iam list-access-keys --user-name <user>
  3. Create the new key:

    Terminal window
    aws iam create-access-key --user-name <user>
  4. Update every consumer (CI secret, Vault, servers) with the new key ID + secret.

  5. Deactivate (don’t delete yet) the old key:

    Terminal window
    aws iam update-access-key --user-name <user> --access-key-id <old-key-id> --status Inactive
  6. Wait a day and check nothing broke (aws iam get-access-key-last-used --access-key-id <old-key-id> should not advance), then delete it:

    Terminal window
    aws iam delete-access-key --user-name <user> --access-key-id <old-key-id>
  • Consumers authenticate with the new key (aws sts get-caller-identity from CI).
  • get-access-key-last-used on the old key stays at the pre-rotation timestamp.

Before step 6: reactivate the old key with --status Active.

  • AWS docs: Managing access keys for IAM users
  • Better long-term: replace static keys with OIDC roles for CI and SSO for humans.

My DevOps Playbook by Angelo John Calleja

New runbook

GitHub not connected

Saving is handled by the site: the GitHub token is stored in Cloudflare, not in your browser. Enter the editor password (the EDITOR_PASSWORD secret) to unlock saving in this browser.

Saving commits to gelogrammer/My_DevOps_Playbook. Create a fine-grained token with access to only this repo andContents: Read and write, then paste it here. It is stored only in this browser.

src/content/docs/…