# Use short-lived role credentials and no long-lived access keys for the agent

Facts read 10 Nov 2026. Page reviewed 16 Nov 2026.

Check 2 of 30: Use short-lived role credentials and no long-lived access keys for the agent. A key stored in code, a config file or a container image stays valid until someone rotates it, so a leak gives an attacker lasting access. Temporary credentials from a role expire on their own.

## Why it matters

A key stored in code, a config file or a container image stays valid until someone rotates it, so a leak gives an attacker lasting access. Temporary credentials from a role expire on their own.

## How, in each cloud

- **AWS:** Have the workload use temporary credentials through an IAM role rather than IAM user access keys.
- **Google Cloud:** Use workload identity or an attached service account instead of service account keys, which Google describes as powerful credentials that can present a security risk.
- **Azure:** Use a managed identity; Microsoft documents that you do not manage its credentials.

## What the documentation says

- "Require workloads to use temporary credentials with IAM roles to access AWS" ([source](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html))
- "security burden associated with service account keys." ([source](https://cloud.google.com/iam/docs/workload-identity-federation))
- "You don't need to manage credentials." ([source](https://learn.microsoft.com/en-us/entra/identity/managed-identities-azure-resources/overview))

- [Previous: Give each agent its own role or service account, not a shared one](/checklist/own-identity-per-agent/)
- [Next: Limit who can pass, attach or impersonate the agent's role](/checklist/restrict-who-can-attach-role/)

## Related pages

- [Limit who can pass, attach or impersonate the agent's role: the check, and how in AWS, Google Cloud and Azure](/checklist/restrict-who-can-attach-role/)
- [Scope the role's trust to the specific agent, service account or workload: the check, and how in AWS, Google Cloud and Azure](/checklist/scope-trust-to-the-agent/)
- [Do not run the agent as a default or pre-granted account: the check, and how in AWS, Google Cloud and Azure](/checklist/no-default-accounts/)

## Sources

- docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html: https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html (read 10 Nov 2026)
- cloud.google.com/iam/docs/workload-identity-federation: https://cloud.google.com/iam/docs/workload-identity-federation (read 10 Nov 2026)
- learn.microsoft.com/en-us/entra/identity/managed-identities-azure-resources/over: https://learn.microsoft.com/en-us/entra/identity/managed-identities-azure-resources/overview (read 10 Nov 2026)

Last reviewed 16 Nov 2026. Canonical: https://aiagentaccesscontrol.com/checklist/short-lived-credentials/
