AWS IAM access keys are created in the IAM console under Users → your user → Security credentials → Create access key. Each key is a pair, an access key ID (starts with AKIA for long-term keys) and a secret access key that is shown only once. AWS recommends temporary credentials from IAM roles or IAM Identity Center instead of long-term keys.
AWS (IAM access keys) key types
| Type | Prefix | Secret? | Scope | Expiry |
|---|---|---|---|---|
| Long-term access key (IAM user or root) An IAM user can have a maximum of two access keys. The secret access key can be retrieved only when the key is created. | AKIA | Yes | Whatever the IAM user's policies allow; there is no separate key scope | Does not expire unless you deactivate or delete it |
| Temporary access key (from AWS STS) Used together with AWS_SESSION_TOKEN. | ASIA | Yes | The permissions of the role or session that issued it | Expires; the credentials include a session token with an expiry time |
How to create a AWS (IAM access keys) key
- Sign in to the AWS Management Console and open the IAM console.
- In the navigation pane, choose Users, then choose the user.
- Open the Security credentials tab.
- In Access keys, choose Create access key, pick a use case, then choose Next.
- Choose Create access key, then Show or Download .csv file to save the secret access key. This is the only time you can see it.
Open AWS (IAM access keys)'s key settings
Limiting what the key can do
Access keys carry the permissions of the IAM user they belong to, so narrow access by attaching least-privilege IAM policies to a dedicated user, or avoid user keys by using IAM roles for temporary credentials. AWS says not to create access keys for the root user.
How to rotate a AWS (IAM access keys) key
- While the first key is active, create a second access key (
aws iam create-access-keyor the console). - Update all applications and tools to use the new key.
- Check the old key's Last used information (
aws iam get-access-key-last-used). - Deactivate the old key (
aws iam update-access-keywith statusInactive) and confirm nothing breaks. - After a waiting period, delete the old key (
aws iam delete-access-key).
AWS recommends deactivating before deleting, and you can reactivate the old key if something still depends on it.
How to revoke a AWS (IAM access keys) key
- In the IAM console, open the user's Security credentials tab.
- In Access keys, choose Actions, then Deactivate to stop the key working immediately.
- When you are sure nothing uses it, choose Actions, then Delete.
If your AWS (IAM access keys) key leaked
- Deactivate the exposed key straight away (
aws iam update-access-key --access-key-id <key id> --user-name <user> --status Inactive). - Review CloudTrail for activity by that access key ID and remove any resources or IAM users, roles or keys you did not create.
- Delete the exposed key and create a replacement, stored in a secrets manager rather than in code.
- If AWS has attached the
AWSCompromisedKeyQuarantinepolicy to the user, remove it only after the key is replaced and the account is clean.
Environment variables and CLI
AWS (IAM access keys)'s SDKs and docs read the key from AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN, AWS_PROFILE, AWS_DEFAULT_REGION or AWS_REGION.
AWS CLI (aws): aws configure for access keys, aws configure sso for IAM Identity Center, or aws login for console credentials (short-term)
Things that catch people out
- The secret access key is shown only once; if you lose it you must delete the key and create a new one.
- Access keys in
~/.aws/credentialsare stored in plaintext. - A key starting
ASIAis temporary and needsAWS_SESSION_TOKENas well, or requests fail. - Each IAM user can hold only two access keys, which is what makes zero-downtime rotation possible.
Recent incidents that put AWS (IAM access keys) keys at risk
If you were affected by one of these, rotate your AWS (IAM access keys) keys using the rotation steps above.
- LiteLLM 1.107.0 on PyPI and Docker carried a credential stealer after a leaked master key 2026-10-21
- tensorlake 0.5.144 on npm shipped a Shai-Hulud variant with a wipe-on-revoke dead-man's switch 2026-10-08
- GhostAction returns: fake security workflows pushed to 30,000+ repos to steal Actions secrets 2026-10-07
- keyv, flat-cache and cache-manager npm releases carried a CI-secret stealer with a revocation trap 2026-08-04
- 32 @redhat-cloud-services npm packages compromised after a VS Code extension hijacked a GitHub account 2026-06-01
- 14 typosquatted OpenSearch and DevOps npm packages stole AWS, Vault, GitHub Actions and npm secrets 2026-05-28
Using your AWS (IAM access keys) key with AI agents
A coding agent that can read your .env file or your shell history can read the key, and anything in its context can end up in logs, transcripts or a prompt-injected request. The safer pattern is to keep the key in a credential broker that performs the authenticated step for the agent and hands back only the result.
BotPassword works this way. For a AWS (IAM access keys) key, these intents fit:
| Intent | What BotPassword does |
|---|---|
list_credentials | Lists the credentials this agent is granted and what it may do with each. Never values. |
run_with | Runs a command with the key injected as an environment variable or a 0600 temporary file, never on the command line, and redacts the key from the output. |
cli_login | Lets git, Docker, the AWS CLI and kubectl log in through bpw's credential helper, so the token is fetched when the tool needs it and not written into its config. The helper hands the value to the tool, so the grant is always disclosing. Other tools use run_with; OAuth device logins are planned. |
rotate | Partly built: creates a new key, stores it as pending, verifies it, promotes it, then revokes the old key after a grace period. Today it works for Cloudflare tokens and AWS IAM keys you have set up, and an agent can start it only under a grant with autopilot; other providers cannot be rotated through their API yet. |
store_secret | Saves a value the agent already holds as a new vault item. |
capture_secret | Planned, not built yet: will read a newly created key straight from the page or command output into the vault. |
Set it up in your agent: Aider · Amp · Claude Code · Claude Desktop · Cline · OpenAI Codex CLI · all agents
Frequently asked questions
Where do I find my AWS access key ID and secret access key?
The access key ID is listed under IAM → Users → your user → Security credentials. The secret access key cannot be viewed again after creation; if it is lost, create a new key.
How do I rotate an AWS access key?
Create a second key, switch your apps to it, deactivate the old key, confirm nothing breaks, then delete the old key. A user can hold at most two keys, so this is the supported pattern.
What does an AWS access key starting with AKIA or ASIA mean?
AKIA marks a long-term key for an IAM user or the root user. ASIA marks temporary credentials issued through AWS STS.
Should I use AWS access keys at all?
AWS says to prefer temporary credentials from IAM roles or IAM Identity Center, and to use long-term keys only when there is no alternative.
Can an AI agent use my AWS (IAM access keys) key without seeing it?
Yes, if the key never enters the agent's context. Instead of pasting the key into a chat or leaving it in a .env file the agent can read, keep it in a credential broker that injects it into the command or request on the agent's behalf. BotPassword does this with list_credentials, run_with, store_secret, so the agent gets the result and never the value.