# Least privilege for workload identities in AWS means one narrow role per workload, delivered as temporary credentials

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

Workload identities in AWS are the IAM roles that Lambda functions, EC2 instances and Kubernetes pods use. AWS documentation read on 16 Nov 2026 covers Lambda execution roles, IRSA and EKS Pod Identity. This guide gives the tools, the steps, the roles to avoid and the measures.

## Workloads get permissions from roles that AWS delivers as temporary credentials

AWS's IAM best practices page tells you to require workloads to use temporary credentials with IAM roles. On compute services such as Amazon EC2 and Lambda, AWS delivers the role's credentials to the compute resource and AWS SDKs find them without any key being distributed.

A Lambda function runs under an execution role. AWS's Lambda guide says Lambda assumes the role when the function is invoked, that the console creates a default role with the AWSLambdaBasicExecutionRole managed policy (permission to write logs to CloudWatch Logs), and that the trust policy must name lambda.amazonaws.com.

For Kubernetes on Amazon EKS there are two mechanisms. IAM roles for service accounts (IRSA) uses an OIDC provider for each cluster and the AssumeRoleWithWebIdentity call. EKS Pod Identity maps a role to a Kubernetes service account in a namespace, and the role's trust policy names the principal pods.eks.amazonaws.com. AWS describes Pod Identity as simpler than IRSA because it does not use OIDC identity providers.

Workloads outside AWS can still use temporary credentials through IAM Roles Anywhere, AssumeRoleWithSAML, AssumeRoleWithWebIdentity and several service-specific integrations, according to the same best practices page.

## Access Analyzer policy generation is AWS's route to a narrower execution role

AWS's Lambda guide says a role created during development often grants more than needed and that before production you should adjust it to the required permissions. It points to IAM Access Analyzer, which reviews CloudTrail logs for the date range you specify and produces a policy template containing only what the function used.

The generated template can be turned into a managed policy and attached to the role. AWS states the date range can be up to 90 days, so a job that runs quarterly will be missing from a 90-day window. Test generated policies before production, as AWS advises.

The unused access analyzer reports unused roles and unused permissions for existing roles, and IAM last accessed information shows the services and actions each role last used. Both rely on the same CloudTrail and last accessed data, so they agree on what is idle.

For pods, the scoping happens at the service account. AWS says you can scope IAM permissions to a service account so only pods using it receive them, and that when access to the instance metadata service is restricted a pod can retrieve credentials only for its own role. AWS also warns that containers are not a security boundary and that pods with hostNetwork set to true always have metadata service access.

## Steps to bring workload roles to least privilege

- Make one role per workload, not per team. Name it for the workload so ownership is visible in the console and in CloudTrail.
- Remove IAM user access keys from workloads that run on AWS compute and attach a role instead.
- On EKS, restrict access to the instance metadata service for pods and associate a separate role with each service account through Pod Identity or IRSA, so pods do not fall back to the node role.
- Generate a policy from CloudTrail activity for each execution or task role that currently carries a managed or wildcard policy.
- Replace wildcard actions with the generated action list, then add resource ARNs and conditions. AWS's best practices page describes conditions such as requiring requests to use TLS or to come through a specific service.
- Where one account hosts many workloads, add a service control policy as a ceiling. AWS says SCPs grant no permissions on their own.
- Rerun policy generation after each release that adds an integration, and delete roles the unused access analyzer flags.

## Roles and settings to avoid on workload identities

| Role or setting | Documented reason (AWS, read 16 Nov 2026) | Use instead |
| --- | --- | --- |
| AdministratorAccess on an execution role | AWS describes it as all actions on all resources, and says development-phase roles should be reduced before production. | A policy generated from the function's activity. |
| Long-term IAM user keys inside a workload | AWS says to use roles so no long-lived credentials are distributed to workloads on AWS. | The execution, instance or task role. |
| One shared node role for every pod | AWS says that if metadata access is not restricted, pod containers can reach the node role's credentials. | Pod Identity or IRSA, plus restricted metadata access. |
| Pods with hostNetwork: true | AWS says these pods always have metadata service access. | Avoid the setting unless the pod truly needs it. |
| Manually calling sts:AssumeRole for a Lambda execution role | AWS says to avoid it and that self-assumption requires the role in its own trust policy. | Let Lambda assume the role at invocation. |

## Measure actions granted against actions called per role

For each workload role, record the actions in its policies and the actions in CloudTrail over the window, then report the share granted but unused. Track roles whose policies contain a wildcard action as a separate count, because generated policies remove those first.

Count pods or functions that still run under a shared role. A falling count means each workload is moving to its own identity. [The principle of least privilege](/principle-of-least-privilege/) explains why an unused permission is exposure, and [privilege creep](/privilege-creep/) shows how a role grows between releases.

Related guides: [Azure workload identities](/guides/azure-workload-identities/), [Google Cloud workload identities](/guides/google-cloud-workload-identities/) and [AWS third-party identities](/guides/aws-third-party-identities/).

## Related pages

- [Least privilege for third-party identities in AWS](/guides/aws-third-party-identities/)
- [Least privilege for human users in Azure](/guides/azure-human-identities/)
- [Least privilege for service identities in Azure](/guides/azure-service-identities/)
- [All of them](/guides/)

## Sources

- AWS IAM User Guide: Security best practices in IAM: https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html (read 16 Nov 2026)
- AWS Lambda Developer Guide: Lambda execution role: https://docs.aws.amazon.com/lambda/latest/dg/lambda-intro-execution-role.html (read 16 Nov 2026)
- Amazon EKS User Guide: IAM roles for service accounts: https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts.html (read 16 Nov 2026)
- Amazon EKS User Guide: EKS Pod Identity: https://docs.aws.amazon.com/eks/latest/userguide/pod-identities.html (read 16 Nov 2026)
- AWS IAM User Guide: IAM Access Analyzer policy generation: https://docs.aws.amazon.com/IAM/latest/UserGuide/access-analyzer-policy-generation.html (read 16 Nov 2026)
- AWS IAM User Guide: IAM Access Analyzer findings: https://docs.aws.amazon.com/IAM/latest/UserGuide/access-analyzer-findings.html (read 16 Nov 2026)
- AWS IAM User Guide: Refine permissions using last accessed information: https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_last-accessed.html (read 16 Nov 2026)
- AWS IAM User Guide: AWS managed policies for job functions: https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_job-functions.html (read 16 Nov 2026)

Last reviewed 16 Nov 2026. Canonical: https://leastprivilegeprinciple.com/guides/aws-workload-identities/
