How to find and rotate stale IAM access keys
Long-lived IAM access keys are the credential most likely to leak and least likely to be noticed. This guide walks the full lifecycle: pull the account credential report, spot every key past 90 days, rotate it with zero downtime using the two-key method, delete root keys, and move workloads to IAM roles and people to short-lived federated credentials. Real AWS CLI, console, and Terraform steps throughout.
Updated 2026-07-20 · ~8 minute read
Why stale keys are the credential that bites you
An IAM access key is a static, long-lived secret. Unlike a console session, it does not expire. It gets pasted into CI variables, laptop dotfiles, old scripts, and Slack threads, and it keeps working for years unless someone rotates or deletes it. When a key leaks — a public repo, a stolen laptop, a compromised build box — the blast radius is whatever policy that key's user carries. Stale keys (unrotated, unused, or on the root account) are the ones no owner is watching, which is exactly why attackers and auditors both look for them first.
The CloudArq checks that catch this
CloudArq runs the credential-report inventory for you and flags the three stale-credential patterns automatically — read-only, with the exact remediation steps attached to each finding. They are 3 of the 192 checks CloudArq runs against an AWS account.
Each finding ships the copy-paste rotate / deactivate / delete commands — CloudArq is read-only and never touches the key itself.
Frequently asked
- 01How often should IAM access keys be rotated?
- The CIS AWS Foundations Benchmark has long recommended rotating credentials at least every 90 days, and the AWS Config managed rule access-keys-rotated defaults to that window. The stronger move is to eliminate long-lived keys entirely: use IAM roles for workloads and short-lived, federated credentials for people, so there is nothing to rotate.
- 02What is the safest way to rotate a key without breaking things?
- Use the two-key method. IAM allows two access keys per user, so you can create a second key, deploy it everywhere the old one is used, then set the old key to Inactive (not deleted). Watch the last-used data for a few days to confirm nothing still calls the old key, then delete it. This gives you an instant rollback if a service was missed.
- 03How do I find which keys are stale?
- Generate the account credential report (aws iam generate-credential-report, then get-credential-report) — its CSV lists every user with access_key_1_last_rotated and access_key_1_last_used_date. Anything not rotated in over 90 days, or never used, is a candidate. For a single key, aws iam get-access-key-last-used shows the last service and region it touched.
- 04Should the root user have access keys at all?
- No. AWS guidance is to have zero long-lived access keys on the root user — a leaked root key is account-wide and cannot be scoped. If root keys exist, sign in as root, delete them under Security credentials, and use IAM roles or IAM Identity Center users for everyday work.
- 05Can I enforce a maximum key age automatically?
- AWS does not expire keys on its own, but the AWS Config managed rules access-keys-rotated (ACCESS_KEYS_ROTATED) and iam-user-unused-credentials-check flag keys older than a set age and dormant credentials, so you get continuous drift detection instead of a one-off cleanup.
- 06Does CloudArq rotate the keys for me?
- No. CloudArq is a read-only audit — it connects through a read-only IAM role with an ExternalId, never stores your credentials, and never auto-fixes anything. It detects stale, root, and unused IAM credentials and hands you the exact CLI and Terraform steps to rotate or remove them; you apply the change.