The pod kept failing every time it tried to list files in S3.
It wasn’t the network. It wasn’t the code. It was IAM.
If you run Kubernetes with Ingress routing to services that need to read from AWS S3, the fastest way to stop permissions hell is to set up read-only roles right. Done wrong, you risk over-permissive policies or broken access. Done right, you get a clean, secure path from your cluster to S3 without giving anything more than what’s necessary.
1. Map the trust
Each Kubernetes workload that needs S3 read access must assume a role designed only for that task. On AWS, this means creating an IAM Role with an S3 policy scoped down to the exact bucket and prefix. Use s3:GetObject and s3:ListBucket only. No writes. No deletes.
2. Bind the role to the pod
If your cluster runs in EKS, use IAM Roles for Service Accounts (IRSA). Create a service account in the target namespace. Annotate it with the ARN of your read-only role. This ensures only pods using that account can pull objects from the bucket.