Identity: cluster access and pod IAM
Cluster access: access entries
Historically, IAM principals were mapped to Kubernetes users/groups in the aws-auth ConfigMap in kube-system — fragile (one bad edit locks everyone out) and invisible to AWS APIs.
Access entries (the current approach) manage access through the EKS API:
aws eks create-access-entry --cluster-name acme-prod \
--principal-arn arn:aws:iam::123456789012:role/PlatformAdmins
aws eks associate-access-policy --cluster-name acme-prod \
--principal-arn arn:aws:iam::123456789012:role/PlatformAdmins \
--policy-arn arn:aws:eks::aws:cluster-access-policy/AmazonEKSClusterAdminPolicy \
--access-scope type=cluster
aws eks associate-access-policy --cluster-name acme-prod \
--principal-arn arn:aws:iam::123456789012:role/CheckoutDevelopers \
--policy-arn arn:aws:eks::aws:cluster-access-policy/AmazonEKSViewPolicy \
--access-scope type=namespace,namespaces=shop,checkout
- Built-in access policies:
AmazonEKSClusterAdminPolicy,AmazonEKSAdminPolicy,AmazonEKSEditPolicy,AmazonEKSViewPolicy— scoped to the cluster or specific namespaces. - Or map a principal to Kubernetes groups in the access entry and bind them with your own RBAC Roles.
- Cluster authentication modes:
CONFIG_MAP,API_AND_CONFIG_MAP(migration),API. - Humans should use roles (via SSO/Identity Center), not IAM users.
Pod IAM with IRSA
IAM Roles for Service Accounts gives pods AWS credentials scoped to one Kubernetes ServiceAccount, without node credentials or static keys:
- The cluster has an OIDC issuer; you register it as an IAM OIDC identity provider.
- You create an IAM role whose trust policy allows
sts:AssumeRoleWithWebIdentityfrom that provider only for a specific service account (system:serviceaccount:shop:orders) and audiencests.amazonaws.com. - You annotate the ServiceAccount with the role ARN.
- The EKS pod identity webhook injects a projected, short-lived, audience-bound service account token and env vars (
AWS_ROLE_ARN,AWS_WEB_IDENTITY_TOKEN_FILE) into pods using it. - AWS SDKs call STS AssumeRoleWithWebIdentity with that token and get temporary credentials.
{
"Effect": "Allow",
"Principal": { "Federated": "arn:aws:iam::123456789012:oidc-provider/oidc.eks.ap-south-1.amazonaws.com/id/ABCDEF" },
"Action": "sts:AssumeRoleWithWebIdentity",
"Condition": {
"StringEquals": {
"oidc.eks.ap-south-1.amazonaws.com/id/ABCDEF:sub": "system:serviceaccount:shop:orders",
"oidc.eks.ap-south-1.amazonaws.com/id/ABCDEF:aud": "sts.amazonaws.com"
}
}
}
apiVersion: v1
kind: ServiceAccount
metadata:
name: orders
namespace: shop
annotations:
eks.amazonaws.com/role-arn: arn:aws:iam::123456789012:role/shop-orders-s3-read
In three sentences for an interview: the cluster's OIDC provider issues a signed, projected token to the pod; IAM trusts tokens from that provider for one specific service account; the pod exchanges the token with STS for temporary role credentials.
EKS Pod Identity
The newer, simpler alternative (2023):
- Install the EKS Pod Identity Agent add-on (DaemonSet).
- Create an IAM role trusting the service principal
pods.eks.amazonaws.com(same trust policy for every cluster). - Create a pod identity association: cluster + namespace + service account → role (
aws eks create-pod-identity-association).
Advantages over IRSA: no per-cluster OIDC provider or trust-policy edits (roles are reusable across clusters — great for blue/green clusters), associations managed via the EKS API, session tags for ABAC. IRSA still works everywhere (and outside EKS-native features), so know both.
Least privilege examples
- A pod reading one bucket:
s3:GetObjectonarn:aws:s3:::acme-reports/*ands3:ListBucketon the bucket — nots3:*. - External DNS:
route53:ChangeResourceRecordSetson specific hosted zones. - Flux image automation / source controller: ECR read-only via IRSA/Pod Identity.
- Karpenter controller: EC2 fleet/launch permissions scoped by tags.