Skip to content

Amazon.Runtime.AmazonClientException: The retrieved credentials have already expired #3864

Open
@grietine

Description

@grietine

Describe the bug

We run ECS on EC2. During the weekend we stop the ECS service and the underlying instance. From time to time we get into situation where the ECS Task can't get the credentials and thus execution of the intended action / call fails. If we restart the ECS Task the issue no longer persists and it gets the credentials. Not sure if it's a bug from AWS SDK side or the underlying services themselves.

Exception:

Amazon.Runtime.AmazonClientException: The retrieved credentials have already expired: Now = 05/19/2025 06:43:19, Credentials expiration = 05/16/2025 23:49:10 at
Amazon.Runtime.RefreshingAWSCredentials.UpdateToGeneratedCredentials(CredentialsRefreshState state, TimeSpan preemptExpiryTime) at
Amazon.Runtime.RefreshingAWSCredentials.GetCredentialsAsync() at
Amazon.Runtime.Internal.CredentialsRetriever.InvokeAsync[T](IExecutionContext executionContext) at
Amazon.Runtime.Internal.RetryHandler.InvokeAsync[T](IExecutionContext executionContext) at
Amazon.Runtime.Internal.RetryHandler.InvokeAsync[T](IExecutionContext executionContext) at
Amazon.Runtime.Internal.CallbackHandler.InvokeAsync[T](IExecutionContext executionContext) at
Amazon.Runtime.Internal.CallbackHandler.InvokeAsync[T](IExecutionContext executionContext) at
Amazon.Runtime.Internal.ErrorCallbackHandler.InvokeAsync[T](IExecutionContext executionContext) at
Amazon.Runtime.Internal.MetricsHandler.InvokeAsync[T](IExecutionContext executionContext) at

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

Credentials are refreshed.

Current Behavior

Seems that cached version of credentials (especially at the EC2 / ECS startup) are used.

Reproduction Steps

Possible Solution

No response

Additional Information/Context

No response

AWS .NET SDK and/or Package version used

"AWSSDK.Core" Version="3.7.402.5"

Targeted .NET Platform

.NET 9

Operating System and version

AmazonLinux

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.credentialsneeds-reproductionThis issue needs reproduction.p2This is a standard priority issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions