Join our Newsletter — 33% off our NHI Course
Home› Guides› How to rotate an AWS IAM access key…
Guide Non-Human Identity (NHI)

How to rotate an AWS IAM access key without downtime: The two key overlap method, step by step

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, edited by Lalit Choda Updated 8 November 2026 10 min read
On this page

Rotating an AWS IAM access key breaks production when the old key is deleted before every consumer has moved to the new one. IAM gives each user two key slots precisely so that you can overlap the old and new key, watch the old one go quiet, deactivate it, and only then delete it. This guide walks through that overlap method with the AWS CLI commands from the IAM documentation, how to prove that nothing still uses the old key with last-used data and CloudTrail, and how to roll back in seconds. It is for cloud and platform engineers who own IAM users that still need long-term keys. For the wider context on when access keys are acceptable at all, see the AWS Access Keys Security Guide.

This is an independent guide from NHI Mgmt Group, based on AWS's public documentation as of November 2026. It is not sponsored or reviewed by AWS. Product features change, so confirm settings against AWS's current documentation.

Key takeaways

  • Use both key slots. Each IAM user can have at most two access keys, so you create the new key while the old one stays active.
  • Deactivate, never delete first. update-access-key --status Inactive is reversible; delete-access-key is not, and IAM requires a key to be deactivated before deletion in the console.
  • Prove the old key is quiet. Check get-access-key-last-used after several days and search CloudTrail by AccessKeyId before you deactivate.
  • The secret is shown once. Write the new secret straight into the secret store your consumers read from, never into a ticket or chat.
  • Rotation is a stopgap. AWS recommends temporary credentials through roles; every rotation is a chance to remove the key entirely.

When you need this

  • Scheduled rotation: the AWS Config managed rule access-keys-rotated (identifier ACCESS_KEYS_ROTATED) marks an IAM user NON_COMPLIANT when an active key is older than maxAccessKeyAge, which defaults to 90 days.
  • Staff or supplier change: AWS's own guidance names an employee leaving as a reason to update keys. The same applies when a contractor or vendor that held the key ends the relationship.
  • Precautionary rotation after a provider incident: when a provider you gave credentials to reports an incident, rotate the credentials you supplied, API access keys first. A no-downtime method matters most when you have to rotate dozens of keys on the same day.
  • Not for a confirmed leak: if the key is known to be exposed, speed beats overlap. Deactivate immediately and follow the Cloud Access Key Leak Playbook. Leaked keys are often tested within minutes.

Before you start

CheckWhy it mattersHow
The user has only one keyWith two keys already present, you cannot create a thirdaws iam list-access-keys --user-name <user-name>
You know every consumerMissed consumers are the cause of rotation outagesLast-used service and Region, CloudTrail by key ID, the credential report, owner interview
Consumers read from a secret storeUpdating one store entry is faster and safer than editing many hostsAWS Secrets Manager, Parameter Store, Vault or CI secret variables
You have IAM permissionsRotation needs create, update, delete and last-used actions on the useriam:CreateAccessKey, iam:UpdateAccessKey, iam:DeleteAccessKey, iam:GetAccessKeyLastUsed, iam:ListAccessKeys
Not the root userAWS says not to use root credentials to create access keys; root keys should not existCredential report root row

Generate a baseline credential report first. It shows, for each user, access_key_1_active, access_key_1_last_rotated, access_key_1_last_used_date, access_key_1_last_used_service and the same for key 2. IAM produces a new report at most once every four hours.

aws iam generate-credential-report
aws iam get-credential-report --query Content --output text | base64 --decode > credential-report.csv

Step-by-step

Steps 1 and 2 are read-only. Steps 3 to 6 change the user's credentials; step 7 is destructive.

  1. Record the current state. List the keys and note the old key ID, its creation date and status.
    aws iam list-access-keys --user-name <user-name>
  2. Find every consumer of the old key. Last-used shows only the most recent service and Region, so pair it with CloudTrail event history, which can look up management events from the last 90 days by AccessKeyId.
    aws iam get-access-key-last-used --access-key-id <OLD_ACCESS_KEY_ID>
    aws cloudtrail lookup-events --lookup-attributes AttributeKey=AccessKeyId,AttributeValue=<OLD_ACCESS_KEY_ID>
    Event history is per Region, so repeat across the Regions the key is used in. Group results by source IP address and user agent to list distinct consumers. CloudTrail notes that accessKeyId can be absent or empty in some events, so treat this as strong evidence, not a complete list.
  3. Create the new key. The new key is active immediately, so the user now has two active keys.
    aws iam create-access-key --user-name <user-name>
    The response contains the secret access key, which cannot be retrieved again. Pipe it into your secret store rather than the terminal history where possible. In the console, the equivalent is IAM > Users > user > Security credentials > Access keys > Create access key, with a description tag that names the consumer and the rotation date.
  4. Update every consumer. Write the new key to the secret store, then restart or reload each consumer so it picks up the change. Applications that cache credentials at start-up keep using the old key until restarted. Update CI variables, scheduled jobs, on-premises hosts with ~/.aws/credentials files (stored in plaintext, which AWS warns about) and any third-party SaaS that was given the key.
  5. Watch the old key go quiet. Wait several days, as AWS advises, and long enough to cover weekly and month-end jobs. Re-run get-access-key-last-used on the old key; the LastUsedDate should stop moving, and the new key should show activity from the expected services. A fresh credential report gives the same picture for both slots in one row, which is useful when you are rotating many users in parallel. If the old key's last-used service or Region changes during the wait, a consumer you did not know about has just run: find it before going further.
  6. Deactivate the old key (reversible).
    aws iam update-access-key --user-name <user-name> --access-key-id <OLD_ACCESS_KEY_ID> --status Inactive
    AWS recommends deactivating even when last-used shows no recent use. Leave it inactive for a further agreed period, for example two weeks, while you watch for errors.
  7. Delete the old key (destructive).
    aws iam delete-access-key --user-name <user-name> --access-key-id <OLD_ACCESS_KEY_ID>
    Deletion frees the slot for the next rotation and ends the old key for good.

Verify it worked

  • Key state: list-access-keys shows one active key with a recent creation date.
  • New key in use: get-access-key-last-used on the new key returns a current LastUsedDate and the services you expect.
  • No denied calls: CloudTrail shows no InvalidClientTokenId or access denied errors from the consumers during the inactive period. AWS recommends CloudWatch alarms on denied access attempts, which catch a forgotten consumer quickly.
  • Compliance: the access-keys-rotated Config rule returns COMPLIANT for the user on its next periodic evaluation, and access_key_1_last_rotated in a fresh credential report shows the new date.

Rollback and common errors

SymptomLikely causeFix
A consumer fails after deactivationIt still holds the old keyupdate-access-key --status Active on the old key, update that consumer, then deactivate again
LimitExceeded on createUser already has two keysDelete an inactive or unused key first; if both are active, rotate one of them first
New secret lostSecret not saved at creationDeactivate and delete the new key and create another; secrets cannot be retrieved later
Old key still shows recent use days laterA cached credential or an unknown consumerUse CloudTrail source IP and user agent to locate it; do not deactivate until found
Old key deleted too earlySkipped the inactive periodNo undo. Give the consumer the current key from the secret store
Third party cannot rotate quicklyKey embedded in a supplier platformAgree a rotation window with the supplier and keep both keys active only for that window

Hardening afterwards

  • Remove the key where you can: AWS recommends temporary credentials through IAM roles. Workloads on AWS compute should use instance or task roles; external CI and other clouds can use OIDC federation; on-premises servers can use IAM Roles Anywhere. See the Workload Identity Federation Guide and the AWS IAM Roles Anywhere Security Guide.
  • One consumer per key: a key shared by five systems needs five coordinated changes. Split it into one IAM user (or better, one role) per consumer so rotation and revocation are independent.
  • Tag and document: use the access key description tag to record the consumer and owner so the next rotation starts with a known list.
  • Enforce age: deploy access-keys-rotated with a maxAccessKeyAge that matches your policy, in a Region where the rule is available, since it evaluates global IAM resources.
  • Clean up dormant keys: rotation is the moment to ask whether the user is needed at all. See the sibling runbook How to find unused AWS IAM roles and access keys.

Choosing a rotation approach

ApproachBest forTrade-off
Manual overlap (this guide)A small number of keys with known ownersHuman effort per key; easy to skip the waiting period
Scripted overlap through a secret storeMany keys with consumers that reload from the storeConsumers must reload without restart, or the script must restart them
Replace with role-based temporary credentialsAnything that can assume a roleOne-off migration effort; no rotation needed afterwards

Small teams with a handful of keys should go straight to removing them in favour of roles. Large estates should measure: percentage of active keys older than policy age, number of IAM users with two active keys outside a rotation window, and median days from rotation start to old key deletion. Keys that cannot be removed should be few, owned and tagged.

Framework mapping

FrameworkReferenceRelevance
NIST SP 800-53 Rev 5IA-5 Authenticator ManagementChanging authenticators periodically and on compromise
NIST SP 800-53 Rev 5AC-2 Account ManagementOwner and purpose for each IAM user
NIST CSF 2.0PR.AA-01Credentials for services are managed by the organisation
MITRE ATT&CKT1078.004 Cloud Accounts; T1552.001 Credentials In FilesShortens the useful life of keys stolen from files or repositories

Practitioner checklist

  • Confirm the key is not known to be leaked; if it is, use the leak playbook instead.
  • Check the user has a free key slot with list-access-keys.
  • Build the consumer list from last-used data, CloudTrail by AccessKeyId and the owner.
  • Create the new key and write the secret straight into the secret store.
  • Restart or reload every consumer and confirm the new key shows use.
  • Wait several days, then deactivate the old key, never delete first.
  • Delete after a quiet inactive period and confirm the Config rule is compliant.
  • Record a plan to replace the key with a role.

Standards and references

Related NHI Mgmt Group resources: AWS Access Keys Security Guide · Cloud Access Key Leak Playbook · How to find unused AWS IAM roles and access keys · Workload Identity Federation Guide

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Researched and written by the NHI Mgmt Group editorial team using AI tools, under the editorial direction of Lalit Choda. Facts are drawn from the sources listed on this page and checked by our automated quality process. Last updated 8 November 2026. Spotted an error? Use our contact page.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM and Agentic AI security. nhimg.org

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick the PDF box to continue.