Intermittent AmazonSQSException: The security token included in the request is invalid in EKS + IRSA with AddAWSService<IAmazonSQS>() and BackgroundService #4138
felixextraordinarypay
started this conversation in
General
Replies: 1 comment 3 replies
-
|
Can you provide the exact version number of the AWSSDK.Core that is being used? Since it is inherited dependency it might be easier to look in the *.deps.json file in your build output to see what version was resolved to. In version 4.0.3.0 of AWSSDK.Core we pushed a fix that rework the background refreshing of credentials. If you are before that version I would start with upgrading to the latest to see if the problem continues. The 4.0.3.0 of AWSSDK.Core was released recently on November 7th 2025. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
Runtime: .NET 9 (ASP.NET Core worker services using
BackgroundService)AWS SDK for .NET:
AWSSDK.SQS(and other AWS packages) – latest versionHosting: AWS EKS, using IRSA (IAM Roles for Service Accounts)
Credential source: IRSA only (no static
AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY/AWS_SESSION_TOKENin pod env)After upgrading our applications from AWS SDK for .NET v3 to v4, our EKS background workers that use IAM Roles for Service Accounts (IRSA) started intermittently failing with:
Full stack trace example:
This issue never occurred on v3, and no infrastructure/configuration changes were made — only NuGet updates (including .NET runtime packages and AWS SDK packages).
The application is a long-running background worker that receives messages from SQS. After running successfully for some time, SQS API calls begin to fail with the above error. Restarting the pod temporarily resolves it.
Additional Notes / Diagnostics
Our DI configuration for AWS clients looks like:
We have investigated:
✔ Verified IRSA is correctly configured
subclaim, and token file are all correct.AWS_WEB_IDENTITY_TOKEN_FILEandAWS_ROLE_ARN.✔ Verified no other credential sources
AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY,AWS_PROFILE, or AWS config files present.✔ Enabled AWS SDK logging
✔ Scoped DI vs Singleton
Changing from:
to:
✔ No code changes
Beta Was this translation helpful? Give feedback.
All reactions