Overview
The IAM configuration creates IAM roles for Kubernetes service accounts using OIDC (OpenID Connect) authentication. This enables EKS pods to assume AWS IAM roles and access AWS services securely without managing long-lived credentials.Core Resources
Product Service Account Roles
Creates IAM roles for application workloads:- IAM role for each product/service defined in
local.iam_service_accounts - Trust policy allowing the EKS OIDC provider to assume the role
- Role mapped to Kubernetes service accounts in the default namespace
local.iam_service_accounts):
team-sync: Syncs GitHub organization dataplatform: Platform-specific AWS access- Other application services requiring AWS permissions
Secret Sync Role
Creates a role for the secret synchronization system:- Role name:
secret-sync - Allowed namespaces:
default,monitoring - Used by the secret synchronization service to sync Vault secrets to Kubernetes
Cert Manager Role
Creates a role for cert-manager to manage TLS certificates:- Role name:
cert-manager - Allowed namespace:
cert-manager - Used by cert-manager to perform DNS-01 challenges for Let’s Encrypt certificates via Route53
IAM Module Architecture
The./modules/iam module (referenced by all roles above) creates:
- IAM Role with OIDC-based assume role policy
- Trust Relationship allowing the EKS OIDC provider to assume the role
- Service Account Mapping restricting which Kubernetes service accounts can use the role
Typical Module Structure
The IAM module accepts these parameters:Name of the IAM role (e.g., “team-sync”, “secret-sync”)
Kubernetes namespaces allowed to use this role
OIDC issuer URL from the EKS cluster
ARN of the OIDC provider for the EKS cluster
OIDC Authentication Flow
The OIDC-based IAM roles work as follows:- EKS OIDC Provider: The EKS cluster has an OIDC identity provider registered in IAM
- Service Account Annotation: Kubernetes service accounts are annotated with the IAM role ARN
- Pod Identity: When a pod starts, it receives a projected service account token
- AssumeRoleWithWebIdentity: The AWS SDK exchanges the token for temporary AWS credentials
- AWS API Access: The pod can now call AWS APIs with the permissions of the IAM role
Example Service Account
Example Pod Using IAM Role
Benefits of OIDC-Based IAM
- No Long-Lived Credentials: Temporary credentials are automatically rotated
- Least Privilege: Each service gets only the permissions it needs
- Namespace Isolation: Roles can be restricted to specific namespaces
- Audit Trail: CloudTrail logs show which pod assumed which role
- Native AWS Integration: Works seamlessly with AWS SDKs
Common IAM Policies
Typical permissions attached to these roles (managed within the./modules/iam module):
Secret Sync Permissions
- Read/write access to AWS Secrets Manager
- Read access to Parameter Store
- Decrypt KMS keys for secrets
Cert Manager Permissions
route53:GetChangeroute53:ListHostedZonesroute53:ChangeResourceRecordSetsroute53:ListResourceRecordSets
Product/Service Permissions
- S3 bucket access for specific services
- SES send email permissions
- SQS/SNS access for messaging
- CloudWatch logs and metrics
Dependencies
- EKS Module (
eks.tf): Provides OIDC issuer URL and provider ARN - IAM Module: Located at
./modules/iamwith reusable role creation logic - Local Variables:
local.iam_service_accountsdefines which services need IAM roles
Role ARN Outputs
Each IAM module outputs the role ARN, which is used by:- Vault Module: References
module.iam-secret-sync.role-arnandmodule.iam-products["team-sync"].role-arn - Kubernetes Manifests: Service account annotations reference the role ARNs
- Helm Charts: Pass role ARNs as values for service account configuration