Opscraft
Amazon EKS · Lesson 4 of 11 · 4 min read

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.
Enlarge diagramIAM rolefrom SSO:PlatformAdminsAccess entryin the EKS APIAccess policye.g. view, scoped tonamespace shop
Figure 1. Access entries: who can use kubectl is managed through the EKS API instead of editing the fragile aws-auth ConfigMap.
Swipe sideways to see all of it, or tap to open it full screen.

Pod IAM with IRSA

IAM Roles for Service Accounts gives pods AWS credentials scoped to one Kubernetes ServiceAccount, without node credentials or static keys:

  1. The cluster has an OIDC issuer; you register it as an IAM OIDC identity provider.
  2. You create an IAM role whose trust policy allows sts:AssumeRoleWithWebIdentity from that provider only for a specific service account (system:serviceaccount:shop:orders) and audience sts.amazonaws.com.
  3. You annotate the ServiceAccount with the role ARN.
  4. 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.
  5. 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):

  1. Install the EKS Pod Identity Agent add-on (DaemonSet).
  2. Create an IAM role trusting the service principal pods.eks.amazonaws.com (same trust policy for every cluster).
  3. 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.

Enlarge diagramIRSAPod IdentityOIDC provider per clusterTrust policy names the service accountAnnotate the ServiceAccountWorks everywhere, incl. FargateAgent add-on on each nodeSame trust (pods.eks.amazonaws.com)Association via the EKS APIRoles reusable across clusters
Figure 2. Two ways to give pods AWS permissions. Both give per-service-account temporary credentials; Pod Identity is simpler to run at scale.
Swipe sideways to see all of it, or tap to open it full screen.

Least privilege examples

  • A pod reading one bucket: s3:GetObject on arn:aws:s3:::acme-reports/* and s3:ListBucket on the bucket — not s3:*.
  • External DNS: route53:ChangeResourceRecordSets on specific hosted zones.
  • Flux image automation / source controller: ECR read-only via IRSA/Pod Identity.
  • Karpenter controller: EC2 fleet/launch permissions scoped by tags.