The Two Worlds of Identity
To understand why this gets messy, you first have to look at the two distinct layers of authority at play. On one side, you have AWS Identity and Access Management (IAM). This is the gatekeeper for your entire cloud footprint. It decides who can spin
up a server, who can delete a database, and who can touch your S3 buckets. It is the foundation of your cloud perimeter. On the other side, you have Kubernetes Role-Based Access Control (RBAC). This is the internal security guard for your container clusters. Once a user or a service is inside the Kubernetes environment, RBAC dictates what they can do within that specific sandbox—like creating a pod, listing services, or deleting a deployment. The complication arises because modern applications live in both worlds simultaneously.
The Friction of Translation
The real trouble starts when a workload inside a Kubernetes cluster needs to talk to a service outside of it, like an AWS managed database. This is where the 'translation' problem occurs. Kubernetes doesn't inherently know how to prove its identity to AWS, and AWS doesn't naturally recognize a Kubernetes ServiceAccount as a valid entity. In the old days, developers often took a dangerous shortcut: they would create an IAM user with long-term access keys and bake those keys directly into a Kubernetes Secret or a container image. This is a massive security risk because if those keys are leaked, an attacker has a permanent skeleton key to your cloud account. The goal is to move away from these static, long-term credentials and toward a system of temporary, short-lived tokens.
Bridging the Gap with IAM Roles
To solve this, engineers use IAM roles to provide temporary security credentials. Instead of using a permanent user, you create a role that defines exactly what a specific task is allowed to do. You then establish a trust relationship that allows a specific service—like an EC2 instance or a Lambda function—to assume that role. In the Kubernetes context, this is often achieved through mechanisms like IAM Roles for Service Accounts (IRSA). This allows a Kubernetes ServiceAccount to act as a bridge, assuming an AWS IAM role to get the temporary credentials it needs. This effectively links the Kubernetes identity to the AWS identity, ensuring that the application only has the permissions it needs for a limited window of time.
The Principle of Least Privilege
Even with the right tools, the complexity remains high because of the 'Least Privilege' requirement. It is easy to create a role that works, but it is much harder to create a role that is perfectly restricted. A common pitfall is granting an application full S3 administrator permissions when it only needs to write to one specific folder. In a complex environment, you end up managing two different sets of policies: the Kubernetes RBAC policies that control internal cluster movement, and the AWS IAM policies that control external resource access. If these two aren't perfectly aligned, you either end up with an application that can't do its job, or an application that has far too much power, creating a massive blast radius if a container is compromised.













