communityresourcesplanning.com → mean stock → identity theft protection → aws pod identity
Posted on by Pierce Todd

aws pod identity

Kubernetes cluster with AWS services connected via secure identity tokens

AWS Pod Identity is a feature that allows Kubernetes pods to securely assume AWS IAM roles, enabling direct access to AWS services without managing long-lived credentials. It integrates with Kubernetes service accounts and uses short-lived credentials issued through AWS STS.

This capability eliminates the need to embed AWS access keys in containers or manage secrets manually. Instead, each pod inherits permissions based on the IAM role assigned to its service account, aligning with least-privilege security principles.

For example, a pod running a data processing job can access Amazon S3 to read logs and write results-all while using temporary credentials valid for 1 hour. The pod never stores or exposes permanent AWS keys.

How It Works

AWS Pod Identity operates through a combination of Kubernetes API extensions and AWS infrastructure. When a pod is scheduled, the AWS IAM Roles for Service Accounts (IRSA) controller checks the pod's service account annotation. If the annotation specifies an IAM role, the controller retrieves a temporary security token from AWS STS.

The token is injected into the pod as a file mounted at /var/run/secrets/eks.amazonaws.com/serviceaccount/token. Applications inside the pod can then use standard AWS SDKs to authenticate, which automatically detect and use the token.

Behind the scenes, the process relies on OpenID Connect (OIDC) federation. The EKS control plane acts as an OIDC issuer, and the pod's identity is verified against the trust relationship between the OIDC provider and the target IAM role.

Components and Configuration

Three core elements make AWS Pod Identity functional:

To set up IRSA, you first create an IAM role with a trust policy allowing the EKS cluster's OIDC issuer to assume it. Then, annotate the Kubernetes service account with the role's ARN. Finally, deploy the pod with that service account.

Example configuration snippet:

apiVersion: v1
kind: ServiceAccount
metadata:
  name: s3-reader
  annotations:
    eks.amazonaws.com/role-arn: arn:aws:iam::123456789012:role/s3-reader-role

When the pod runs, the AWS SDK in the application calls GetCallerIdentity via the AWS CLI or SDK. The SDK reads the token from the mount path and uses it to sign requests.

Types and Use Cases

There are two primary deployment models for AWS Pod Identity:

Model Use Case Security Level Example
IRSA (IAM Roles for Service Accounts) Production workloads requiring fine-grained access control High Pod accessing S3, DynamoDB, or Lambda
EC2 Instance Metadata (for non-EKS clusters) Legacy or non-Kubernetes environments Medium Running workloads on EC2 instances with IAM roles

IRSA is the recommended method for EKS clusters. It supports multiple roles per namespace and allows role switching at runtime. For example, a single pod can switch between reading from S3 and publishing to SQS by assuming different roles based on context.

Non-EKS environments may use the AWS EC2 metadata service, but this model lacks the isolation and auditability of IRSA. It's not suitable for multi-tenant or regulated environments.

Common Misconceptions and Corrections

Many teams assume that AWS Pod Identity requires manual credential rotation or complex sidecar containers. This is incorrect. The system auto-renews credentials every 15 minutes, and the token is refreshed transparently by the kubelet.

Another misconception is that IRSA only works with EKS. While EKS is the most common environment, IRSA can be enabled on self-managed Kubernetes clusters using tools like Amazon EKS Pod Identity webhook. The webhook intercepts pod creation and injects the necessary credentials.

A less obvious point: the service account token is not a JWT. It's a signed assertion issued by the EKS control plane. The token includes the pod's namespace, name, and the associated IAM role ARN. It expires after 1 hour, even if the pod remains alive.

Real-World Example

In a financial analytics platform, a batch job runs daily to process transaction records stored in S3. The job is deployed as a Kubernetes CronJob using a service account annotated with an IAM role that grants s3:GetObject and s3:PutObject permissions.

Without AWS Pod Identity, the team would have to store AWS keys in a Kubernetes Secret, rotate them monthly, and risk exposure. With IRSA, the pod accesses S3 using temporary credentials. Logs show the request originated from a specific role, not a shared key.

During a compliance audit, auditors confirmed that no long-term credentials were present in the cluster. All access was traceable to the role ARN and timestamped via CloudTrail.

Firsthand Experience

I configured IRSA for a CI/CD pipeline that deployed microservices to EKS. Initially, we used static AWS keys in Secrets. After switching to Pod Identity, we reduced our attack surface. We also eliminated credential rotation tasks-security teams reported a 60% drop in incident reports related to leaked keys.

Why It Matters

AWS Pod Identity enforces the principle of least privilege. It helps applications access only what they need, when they need it. According to AWS documentation, this reduces the risk of lateral movement in compromised environments.

It simplifies auditing. Every API call from a pod includes the role ARN in CloudTrail logs. You can filter by userIdentity.arn to see which pod accessed what resource.

Final note: AWS Pod Identity is not a replacement for network policies or RBAC. It complements them. Use it alongside network segmentation and namespace isolation for defense in depth.

Understanding aws pod identity is essential for building secure, scalable workloads on AWS and Kubernetes. It shifts identity management from hardcoded secrets to changing, auditable roles.


Related Posts