Managing AWS Credentials in EKS Pods with EKS Pod Identities
Use Amazon EKS Pod Identity to give Kubernetes workloads secure access to AWS services without distributing static credentials.

At AWS re 2023, the EKS team introduced Pod Identity to simplify how Kubernetes workloads receive IAM credentials.
Applications in a pod can use the AWS SDK or AWS CLI to call AWS services with IAM permissions. EKS Pod Identity provides a simpler alternative to distributing credentials: you associate an IAM role with a Kubernetes service account, then configure pods to use that service account.
This guide configures an application running in Amazon EKS to access Amazon S3 through EKS Pod Identity.
Step 0: Before you start
- AWS account.
- EKSctl used for communicating with the cluster API server.
- AWS-IAM-Authenticator – with necessary permissions to call the EKS API.
- EKS Cluster (v1.27) - If you don’t know how to set up an EKS cluster, click here.

Caution (Check current requirements)
The screenshots use Amazon EKS 1.27. Choose a version that is currently supported in your region, and review the latest Amazon EKS pricing before creating a cluster.
Step 1: Install the EKS Pod Identity Agent Add-on and Create an IAM Role
Our first step is to set up a new IAM role with required permissions to access my S3 bucket.
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "pods.eks.amazonaws.com" }, "Action": [ "sts:AssumeRole", "sts:TagSession" ] } ]}

Then you need to install the EKS Pod Identity Agent add-on. You can do it via the console or eksctl. I will choose eksctl because it’s easier and quicker. Don’t forget to replace the name of the cluster and the region that you chose.
eksctl create addon --cluster EKS-pod-identity --name eks-pod-identity-agent --region us-east-1

Now, navigate to the ‘Access’ tab in the EKS cluster, click on ‘Pod Identity Associations’ to map our IAM role to Kubernetes pods.


Step 2: Create an S3 bucket and a service account to test the new Pod Identity
Create an S3 bucket for testing, again, you can do it via the console or AWS CLI
aws s3api create-bucket --bucket fadyio-eks-pod-identity --region us-east-1
Then, create a service account with the IAM role that we previously created
apiVersion: v1kind: ServiceAccountmetadata: annotations: eks.amazonaws.com/role-arn: arn:aws:iam::<YOUR-ACCOUNTID>:role/EKS-Pod-Identity name: pod-identity-sa namespace: default
Step 3: Create a Pod to test access to the S3 bucket
apiVersion: v1kind: Podmetadata: name: ubuntu-identityspec: serviceAccountName: pod-identity-sa containers: - command: - sleep - "3600" image: ubuntu name: ubuntu-identitykubectl apply -f FILENAME.yamlwe will go into the pod to install the AWS CLI and try to list S3 buckets
kubectl exec -it ubuntu-identity -- /bin/bashfrom the AWS CLI Installation Guide
apt update && apt install unzip curl -ycurl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"unzip awscliv2.zip./aws/installLet’s try to copy the AWS CLI zip file to the S3 bucket
aws s3 cp awscliv2.zip s3://fadyio-eks-pod-identity/

Summing it up
EKS Pod Identity is a game-changer that simplifies IAM permissions for applications that runs on EKS, A hassle-free configuration experience that makes it easy to define the necessary IAM permissions for your applications in Amazon EKS, Plus, it brings a bunch of security perks like Least Privilege, Credential Isolation, Auditability, Reusability, and better Scalability into the mix.