Lesson 07 β IAM Roles for Service Accounts (IRSA)
Learning Objectives
Section titled βLearning ObjectivesβBy the end of this lesson, you will be able to:
- Understand what IAM Roles for Service Accounts (IRSA) is
- Explain why IRSA is required in Amazon EKS
- Understand how IRSA works
- Learn the relationship between Kubernetes Service Accounts and AWS IAM Roles
- Understand the role of OIDC and AWS STS
- Identify common IRSA security risks
- Apply enterprise best practices for workload identity
Why This Matters
Section titled βWhy This MattersβApplications running inside Kubernetes often need to access AWS services.
Examples include:
- Amazon S3
- Amazon DynamoDB
- Amazon SQS
- Amazon SNS
- AWS Secrets Manager
- Amazon ECR
- AWS KMS
- Amazon CloudWatch
The question is:
How can a Pod securely access AWS services without storing AWS Access Keys inside the container?
Historically, developers embedded AWS credentials inside:
- Source code
- Docker images
- Environment variables
- Configuration files
This created serious security risks.
Amazon EKS solves this problem using IAM Roles for Service Accounts (IRSA).
What is IRSA?
Section titled βWhat is IRSA?βIAM Roles for Service Accounts (IRSA) is an Amazon EKS feature that allows Kubernetes workloads to securely assume AWS IAM Roles.
Instead of storing AWS credentials inside Pods, workloads receive temporary AWS credentials automatically.
Application
β
Service Account
β
IAM Role
β
Temporary Credentials
β
AWS ServiceThis provides secure, cloud-native authentication.
Traditional Authentication (Not Recommended)
Section titled βTraditional Authentication (Not Recommended)βOlder Kubernetes deployments often stored AWS credentials directly inside applications.
Application
β
AWS Access Key
β
AWS Secret Key
β
Amazon S3Problems include:
- Hardcoded credentials
- Credential theft
- Difficult rotation
- Shared secrets
- Compliance issues
This approach should never be used in production.
Modern Authentication with IRSA
Section titled βModern Authentication with IRSAβIRSA removes the need for static AWS credentials.
Application
β
Service Account
β
OIDC Provider
β
AWS STS
β
Temporary Credentials
β
Amazon S3No AWS Access Keys are stored inside the container.
Why IRSA is Important
Section titled βWhy IRSA is ImportantβIRSA provides several security benefits.
Without IRSA:
- Static credentials
- Difficult credential rotation
- Shared AWS accounts
- Weak auditing
- High attack surface
With IRSA:
- Temporary credentials
- Automatic credential rotation
- Fine-grained permissions
- Better auditing
- Least privilege access
Components of IRSA
Section titled βComponents of IRSAβIRSA relies on several AWS and Kubernetes components.
Amazon EKS
β
OIDC Provider
β
IAM Role
β
Service Account
β
AWS STS
β
AWS ServiceEach component contributes to secure workload authentication.
How IRSA Works
Section titled βHow IRSA WorksβAuthentication process:
Pod Starts
β
Uses Service Account
β
OIDC Token Generated
β
AWS STS Validates Token
β
IAM Role Assumed
β
Temporary Credentials Issued
β
Application Calls AWS APIsThis entire process is automatic and transparent to the application.
Step-by-Step IRSA Workflow
Section titled βStep-by-Step IRSA WorkflowβDeveloper deploys an application.
β
Application uses a Kubernetes Service Account.
β
The Service Account is associated with an AWS IAM Role.
β
Amazon EKS issues an OIDC token.
β
AWS STS validates the token.
β
STS issues temporary AWS credentials.
β
Application accesses AWS securely.
OpenID Connect (OIDC)
Section titled βOpenID Connect (OIDC)βIRSA depends on OpenID Connect (OIDC).
Amazon EKS creates an OIDC identity provider for every cluster.
Amazon EKS
β
OIDC Provider
β
AWS IAM TrustThe IAM Role trusts identities issued by this OIDC provider.
Without OIDC, IRSA cannot function.
AWS Security Token Service (STS)
Section titled βAWS Security Token Service (STS)βAWS STS issues temporary AWS credentials after validating the workload identity.
OIDC Token
β
AWS STS
β
Temporary Credentials
β
AWS ServiceTemporary credentials:
- Automatically expire
- Cannot be reused indefinitely
- Improve security
- Reduce credential theft
IAM Trust Relationship
Section titled βIAM Trust RelationshipβEvery IAM Role used by IRSA includes a trust policy.
IAM Role
β
Trust Policy
β
OIDC Provider
β
Specific Service AccountOnly authorised Service Accounts can assume the IAM Role.
IRSA Architecture
Section titled βIRSA Architectureβ Amazon EKS Cluster
ββββββββββββββββββββββββββββββ β Application Pod β β β β Service Account β ββββββββββββββββ¬βββββββββββββββ β βΌ OIDC Authentication β βΌ AWS STS β βΌ IAM Role β βΌ Amazon S3 / DynamoDB / SQSApplications authenticate without requiring embedded AWS credentials.
Enterprise Example
Section titled βEnterprise ExampleβAn image processing application uploads photographs to Amazon S3.
Architecture:
Image Processing Pod
β
Service Account
β
IAM Role
β
AWS STS
β
Temporary Credentials
β
Amazon S3IAM permissions:
- Upload images
- Read images
- List bucket contents
Denied permissions:
- Delete bucket
- Manage IAM
- Launch EC2
- Modify networking
The application receives only the permissions it needs.
IRSA with AWS Secrets Manager
Section titled βIRSA with AWS Secrets ManagerβMany applications retrieve secrets from AWS Secrets Manager.
Application
β
IRSA
β
IAM Role
β
AWS Secrets Manager
β
Database PasswordThe password never exists inside the application image.
IRSA with Amazon DynamoDB
Section titled βIRSA with Amazon DynamoDBβOrder Service
β
IRSA
β
IAM Role
β
Amazon DynamoDBThe application receives temporary permissions to read and update only its required DynamoDB tables.
IRSA with Amazon SQS
Section titled βIRSA with Amazon SQSβPayment Service
β
IRSA
β
IAM Role
β
Amazon SQSOnly queue operations required by the application are permitted.
Enterprise Identity Architecture
Section titled βEnterprise Identity ArchitectureβApplication
β
Service Account
β
RBAC
β
OIDC Provider
β
AWS STS
β
IAM Role
β
AWS ServiceKubernetes RBAC controls access to Kubernetes resources.
IAM controls access to AWS resources.
Together they provide complete workload identity.
Common IRSA Security Risks
Section titled βCommon IRSA Security RisksβCloud Security Engineers commonly identify:
- Shared Service Accounts
- Overprivileged IAM Roles
- Wildcard IAM policies
- Default Service Accounts
- Missing OIDC validation
- Excessive AWS permissions
- Unused IAM Roles
- Weak trust policies
- Overprivileged RBAC
- Long-lived credentials still present
Misconfigured IRSA can allow workloads to access resources beyond their intended scope.
Enterprise Monitoring
Section titled βEnterprise MonitoringβSecurity teams should monitor:
- IAM Role assumptions
- AWS STS activity
- OIDC authentication events
- Service Account changes
- IAM policy updates
- Trust policy modifications
- Failed AssumeRole requests
- Unusual AWS API calls
- RBAC changes
- Privilege escalation attempts
CloudTrail and GuardDuty provide valuable visibility into IRSA activity.
Enterprise Example
Section titled βEnterprise ExampleβA global healthcare provider runs patient management applications on Amazon EKS.
Each workload has its own identity.
Patient API
β
Service Account
β
Patient IAM Role
β
AWS Secrets Manager
β
Database Credentials
----------------------------
Image Service
β
Service Account
β
Image IAM Role
β
Amazon S3
β
Medical ImagesEvery workload receives only the permissions required for its business function.
This architecture improves:
- Security
- Compliance
- Auditing
- Operational efficiency
Best Practices
Section titled βBest PracticesβAs a Kubernetes Security Engineer:
- Create dedicated Service Accounts for every workload.
- Implement IRSA for all production applications.
- Follow the Principle of Least Privilege.
- Use narrowly scoped IAM policies.
- Never store AWS Access Keys inside Pods.
- Enable CloudTrail logging.
- Monitor AWS STS activity.
- Review IAM trust policies regularly.
- Rotate application permissions as requirements change.
- Remove unused IAM Roles and Service Accounts.
IRSA should be the standard method for granting AWS permissions to Kubernetes workloads.
Real-World Scenario
Section titled βReal-World ScenarioβA media company stores AWS Access Keys inside a Docker image used by several applications.
The image is accidentally published to a public container registry.
An attacker extracts the credentials and:
- Downloads confidential data from Amazon S3.
- Launches EC2 instances.
- Reads DynamoDB tables.
- Deletes backups.
After migrating to IRSA:
- No AWS credentials exist inside container images.
- Temporary credentials expire automatically.
- IAM Roles restrict access to specific AWS resources.
- CloudTrail records every AssumeRole event.
The organisation significantly reduces its attack surface and improves compliance.
Key Takeaways
Section titled βKey TakeawaysβAfter completing this lesson, you should understand:
- What IAM Roles for Service Accounts (IRSA) is
- Why IRSA is important in Amazon EKS
- How OIDC and AWS STS enable workload authentication
- How Service Accounts integrate with IAM Roles
- The benefits of temporary credentials
- Common IRSA security risks
- Enterprise best practices for workload identity
IRSA is one of the most important Amazon EKS security features because it eliminates long-lived AWS credentials while providing secure, auditable, and least-privilege access to AWS services.
Knowledge Check
Section titled βKnowledge CheckβQuestion 1
Section titled βQuestion 1βWhat is the primary purpose of IAM Roles for Service Accounts (IRSA)?
- A. Increase Pod performance
- B. Securely grant AWS permissions to Kubernetes workloads
- C. Replace Kubernetes RBAC
- D. Encrypt Kubernetes Secrets
Answer: B
Question 2
Section titled βQuestion 2βWhich AWS service issues temporary credentials for IRSA?
- A. Amazon S3
- B. AWS Security Token Service (STS)
- C. Amazon CloudWatch
- D. Amazon Route 53
Answer: B
Question 3
Section titled βQuestion 3βWhich Kubernetes object is associated with an IAM Role when using IRSA?
- A. Namespace
- B. Deployment
- C. Service Account
- D. ConfigMap
Answer: C
Question 4
Section titled βQuestion 4βWhich protocol enables trust between Amazon EKS and AWS IAM for IRSA?
- A. FTP
- B. SMTP
- C. OpenID Connect (OIDC)
- D. SNMP
Answer: C
Question 5
Section titled βQuestion 5βWhich of the following is considered an IRSA best practice?
- A. Store AWS Access Keys inside Docker images.
- B. Share one IAM Role across all applications.
- C. Create dedicated Service Accounts with least-privilege IAM Roles.
- D. Disable CloudTrail logging.
Answer: C
Whatβs Next?
Section titled βWhatβs Next?βIn the next lesson, you will learn about Least Privilege Design, where you will explore how enterprise organisations minimise permissions across Kubernetes RBAC, AWS IAM, Service Accounts, and workloads to reduce the attack surface and prevent privilege escalation.
β‘οΈ Next Lesson: Lesson 08 β Least Privilege Design