Quick revision
The short answer
If CloudTrail shows the node's instance role even though AWS_ROLE_ARN and AWS_WEB_IDENTITY_TOKEN_FILE are set, the SDK skipped the web identity provider and fell through the chain to instance metadata. In SDK 2.x the usual cause is a missing sts module on the classpath; other causes are an old SDK version without web identity or Pod Identity support, or code that builds clients with an explicit provider such as InstanceProfileCredentialsProvider. We also verify the role's trust policy, block pods from instance metadata so failures surface instead of falling back silently, and log the result of STS GetCallerIdentity at startup.
What to remember
In this answer, we saw that CloudTrail showing the node role means the SDK's chain skipped web identity and fell back to instance metadata. The usual causes in the application are a missing sts module in SDK 2.x, an SDK too old for web identity or Pod Identity, or an explicit provider that bypasses the chain. A wrong trust policy can produce the same symptom, and blocking pods from instance metadata plus logging GetCallerIdentity at startup turn this silent fallback into a clear failure.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
If CloudTrail shows the node's instance role even though AWS_ROLE_ARN and AWS_WEB_IDENTITY_TOKEN_FILE are set, the SDK skipped the web identity provider and fell through the chain to instance metadata. In SDK 2.x the usual cause is a missing sts module on the classpath; other causes are an old SDK version without web identity or Pod Identity support, or code that builds clients with an explicit provider such as InstanceProfileCredentialsProvider. We also verify the role's trust policy, block pods from instance metadata so failures surface instead of falling back silently, and log the result of STS GetCallerIdentity at startup.
Background to this question
This bug is confusing because the Kubernetes side looks perfect: the service account is annotated and the pod has the right environment variables. Yet the application calls AWS as the node, gets AccessDenied, and nothing in the logs says why. The cause is almost always in how the Java application resolves credentials, and the silent fallback to the node role hides it. In this answer, we will recap how IRSA reaches a pod, see why the SDK can skip it, go through the causes in the application, check the trust policy, and set up the startup check and metadata blocking that make this failure visible next time.
1A Quick Recap of How IRSA Works
IRSA, IAM Roles for Service Accounts, connects a Kubernetes service account to an IAM role. When a pod uses the annotated service account, an EKS webhook injects two environment variables: AWS_ROLE_ARN, the role to assume, and AWS_WEB_IDENTITY_TOKEN_FILE, the path of a projected token signed by the cluster's OIDC provider. The SDK reads the token and calls STS AssumeRoleWithWebIdentity. STS checks the role's trust policy, which must trust the cluster's OIDC provider and the exact service account, and returns temporary credentials.
The pod is still running on an EC2 node, so the node's instance metadata service is also reachable unless we block it. That is where the node role comes from.
8 messages in order. Play them, or step through them one at a time.
When the web identity step is skipped, the chain quietly ends at the node role.
2Cause 1: The STS Module Is Missing
In SDK 2.x, the web identity provider is in the core library, but the code that actually calls STS lives in the separate sts module. DefaultCredentialsProvider loads it by reflection. If software.amazon.awssdk:sts is not on the classpath, the web identity provider cannot work, the chain moves on, finds nothing in profiles or the container endpoint, and ends at instance metadata. The application starts fine and the first error is AccessDenied from S3, signed by the node role.
This happens easily, because a service that only uses S3 and DynamoDB never declares sts, and nothing fails at build time. The fix is one dependency, versioned by the BOM like the rest of the SDK.
3Cause 2: An Old SDK, and Cause 3: An Explicit Provider
Older SDKs do not know these mechanisms. Version 1.x needs its own aws-java-sdk-sts module and a recent enough release to support web identity, and early 2.x releases predate EKS Pod Identity, which is served through the container credentials endpoint with a newer variable, AWS_CONTAINER_CREDENTIALS_FULL_URI. If the service or a library brings in an old SDK, upgrading is the fix; check the minimum versions in the AWS documentation for your mechanism.
The other common cause is code that bypasses the chain. Someone once wrote a configuration class for running on EC2, and it still builds every client with InstanceProfileCredentialsProvider, or with ProfileCredentialsProvider for a named profile. Those clients never look at the web identity variables.
We search the code base and shared libraries for credentialsProvider( and for any explicit provider class. Spring Cloud AWS also has properties that can force a profile or instance provider, so we check application configuration for spring.cloud.aws.credentials settings as well.
4Checking the Trust Policy
If the SDK does try web identity but STS rejects the token, the provider fails and, depending on the SDK version and chain behaviour, the error may be swallowed and the chain may continue to the node role. So we also check the role's trust policy. It must name the cluster's OIDC provider as a federated principal, allow sts:AssumeRoleWithWebIdentity, and have conditions matching the token's subject, system:serviceaccount:<namespace>:<service-account-name>, and the audience sts.amazonaws.com. A typo in the namespace, or a service account renamed in a Helm chart, breaks it. CloudTrail shows failed AssumeRoleWithWebIdentity calls with the reason.
5Making the Failure Visible
The deeper problem is that the failure was silent. Two changes fix that. First, block pods from the node's instance metadata: with IMDSv2 required and a hop limit of 1 on the node launch template, pods on the pod network cannot reach it, or a network policy denies the metadata address. Then a misconfigured pod fails with a clear credentials error instead of borrowing the node's identity, which is also a real security improvement.
Second, check identity at startup. A small bean calls STS GetCallerIdentity and logs the ARN, and can fail startup if it is not the expected role. That one log line would have pointed straight at this bug.
- Log GetCallerIdentity at startupwhich role are we really?
- Node role?YesInspect the Java sideNoCheck role policy permissions
- sts module on classpath?YesContinueNoAdd software.amazon.awssdk:sts
- Explicit provider in code or config?YesRemove it, use the default chainNoContinue
- Trust policy matches namespace and SA?YesCheck SDK versionNoFix the trust policy
- Block instance metadata for podsso the next failure is loud
6 steps in order. Play them, or step through them one at a time.
6Follow-up questions
What is the difference between IRSA and EKS Pod Identity?
IRSA uses the cluster's OIDC provider: the pod gets a projected token and the SDK exchanges it with STS, and each role's trust policy must name the specific cluster OIDC provider and service account, which gets awkward across many clusters. EKS Pod Identity uses an agent on the node and an association, created through the EKS API, between a service account and a role; the trust policy trusts a single EKS service principal, so the same role works across clusters without editing trust for each one. The SDK reaches Pod Identity through the container credentials provider, so it needs a version that supports it, and the sts module is not involved in the same way.
Why does the node role exist at all, and can we remove its permissions?
Nodes need a role to join the cluster, pull images and run networking add-ons. We keep it to exactly those permissions, never application permissions, so a pod that falls back to it gets AccessDenied quickly rather than accidentally working.
How do you test this before production?
Run the startup identity check in every environment, and include a test that the built jar contains the sts module, for example a dependency rule in the build. Staging should block instance metadata like production, so a fallback fails there first.
7Conclusion
In this answer, we saw that CloudTrail showing the node role means the SDK's chain skipped web identity and fell back to instance metadata. The usual causes in the application are a missing sts module in SDK 2.x, an SDK too old for web identity or Pod Identity, or an explicit provider that bypasses the chain. A wrong trust policy can produce the same symptom, and blocking pods from instance metadata plus logging GetCallerIdentity at startup turn this silent fallback into a clear failure.
Open with
The symptom says the SDK never used the web identity credentials and fell through the default chain to the node's instance metadata. Since the pod has AWS_ROLE_ARN and the token file, Kubernetes did its part, so I would look at the Java side.
Then, if they want more
The most common cause with SDK 2.x is that the sts module is not on the classpath. The web identity provider needs it to call AssumeRoleWithWebIdentity, and without it the provider is skipped quietly. Adding software.amazon.awssdk:sts fixes it.
Second, an old SDK, 1.x or an early 2.x, may not support web identity or EKS Pod Identity, so I would check versions, including SDKs pulled in by libraries. Third, code that builds clients with an explicit provider, like InstanceProfileCredentialsProvider or a fixed profile, ignores the chain entirely, so I would search the code and Spring Cloud AWS credentials properties.
Outside the code, I would check the role's trust policy: the OIDC provider, sts.amazonaws.com as audience, and the exact namespace and service account name in the subject condition. CloudTrail shows failed AssumeRoleWithWebIdentity calls if that is the problem.
Then I would make it impossible to fail silently: block pods from instance metadata with IMDSv2 and a hop limit of 1 or a network policy, keep the node role minimal, and add a startup check that calls GetCallerIdentity, logs the role ARN and fails if it is not the expected role.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- AWS documentation
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "On EKS, a Java service configured with IRSA (an annotated service account) gets...": https://scrivio-interview-library.netlify.app/spring-boot/aws/10d4cb3ffe/