AWS Builder Center
# How Does a Kubernetes Pod Get AWS Permissions? Understanding IAM OIDC & IRSA in Amazon EKS šŸ”

# How Does a Kubernetes Pod Get AWS Permissions? Understanding IAM OIDC & IRSA in Amazon EKS šŸ”

OIDC establishes trust, IRSA connects a Kubernetes ServiceAccount to an IAM Role, and STS provides temporary AWS credentials. Think of it this way: Pod → Identity Token → Verification → IAM Role → Temporary Credentials → AWS APIs

Imagine deploying an application on Amazon EKS. Everything works perfectly until one day your Kubernetes workload needs to interact with AWS services.
For example:
Your AWS Load Balancer Controller needs to create an Application Load Balancer (ALB).
But here's the question:
How does a Pod running inside Kubernetes get permission to access AWS services?
Should we put our AWS IAM access keys inside the container?
Absolutely not! That's a security risk.
This is where IAM Roles for Service Accounts (IRSA) and OIDC come into the picture.

First, understand the problem.

We have:
  • An EKS cluster.
  • An AWS Load Balancer Controller running as a Kubernetes Pod.
  • A requirement to create and manage AWS Load Balancers.
The controller needs AWS permissions, but Kubernetes ServiceAccounts alone don't automatically provide AWS IAM permissions.
So, how do we establish trust between a Kubernetes workload and AWS IAM?

What is OIDC?

OIDC stands for OpenID Connect.
Think of it as an identity verification mechanism.
Amazon EKS has an OIDC issuer that provides identity tokens for Kubernetes workloads.
AWS IAM can trust this identity provider and verify whether a workload is allowed to assume a particular IAM role.

How OIDC + IRSA actually works

Let's break down the flow:
1. Kubernetes ServiceAccount
The AWS Load Balancer Controller Pod runs using a specific Kubernetes ServiceAccount.
2. Identity Token
The Pod receives a projected OIDC identity token associated with that ServiceAccount.
3. AWS STS Verification
The Pod uses this token to request temporary credentials through AWS STS (Security Token Service).
STS validates the token against the IAM role's trust policy.
4. IAM Role Assumption
If the token satisfies the trust policy conditions, AWS allows the Pod to assume the associated IAM role.
5. Access AWS Services
STS returns temporary AWS credentials, allowing the controller to interact with AWS APIs according to the permissions attached to that IAM role.
For example:
  • Create Application Load Balancers.
  • Configure listeners.
  • Manage target groups.
And all of this happens without storing long-lived AWS access keys inside the container!

Why is this important?

Consider these two approaches:
āŒ Without IRSA:
  • Store AWS access keys inside containers.
  • Risk accidental credential exposure.
  • Potentially give workloads excessive permissions.
āœ… With IRSA:
  • Each workload gets its own IAM identity.
  • Permissions are controlled through IAM roles.
  • Temporary credentials are used.
  • No need to distribute long-lived IAM user access keys.

Where will we use this?

In our EKS-based DevOps project, we'll use this mechanism while installing the AWS Load Balancer Controller.
Our implementation flow:
  1. Create the EKS cluster.
  1. Associate an IAM OIDC provider with the cluster.
  1. Create an IAM role with the required permissions.
  1. Configure its trust policy for the controller's Kubernetes ServiceAccount.
  1. Install the AWS Load Balancer Controller using Helm.
One interesting thing I learned: OIDC establishes trust, IRSA connects the Kubernetes ServiceAccount with an IAM role, and AWS STS provides temporary credentials.
That's the bigger picture!



Let's discuss! šŸ’¬

If you're working with Amazon EKS:
Have you implemented IRSA in your projects, or are you using the newer EKS Pod Identity approach?
I'd love to hear about your experience and learn how others are handling workload authentication in AWS.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article