AWS_ACCESS_KEY_ID
SensitiveThe access key ID for AWS IAM user or role authentication. Part of the long-term credential pair (along with the secret access key) used to sign programmatic requests to AWS services. For production workloads, prefer IAM roles or temporary credentials over long-term access keys.
Last updated:
AWS_ACCESS_KEY_ID is the public half of a long-term IAM credential pair — it identifies which IAM user or access key is signing a request, while AWS_SECRET_ACCESS_KEY signs it. Keys for IAM users start with the prefix AKIA; temporary keys from STS start with ASIA. The AWS SDKs and CLI read it automatically from the environment as part of the default credential provider chain, so exporting it is usually all you need to authenticate. For anything running inside AWS (EC2, ECS, Lambda, EKS), you should not set it at all — use an IAM role and let the metadata service hand out short-lived credentials.
- Provider
- AWS
- Category
- authentication
- Set by
- AWS Console → IAM → Users → your user → Security credentials → Create access key
- Example
- AKIAIOSFODNN7EXAMPLE
How to set AWS_ACCESS_KEY_ID
bash (pair with the secret)
export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE
export AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
aws sts get-caller-identitypreferred: no static key (assume a role)
aws configure sso
# or, inside AWS, attach an IAM role — no keys in env at allReferences
Frequently Asked Questions
What is the difference between AKIA and ASIA access keys?
AKIA prefixes a long-term key tied to an IAM user — it stays valid until you delete it. ASIA prefixes a temporary key issued by AWS STS (assumed role, SSO, MFA session) and expires within hours. ASIA keys must be sent together with AWS_SESSION_TOKEN; AKIA keys must not.
Should I use access keys on an EC2 instance or in Lambda?
No. Attach an IAM role instead. The SDK credential chain automatically picks up short-lived credentials from the instance/container metadata service, so there are no long-term secrets to leak or rotate. Setting AWS_ACCESS_KEY_ID there actually overrides the safer role.
Stay up to date
Get notified about new guides, tools, and cheatsheets.