Skip to content

Behavior of @aws-sdk/credential-providers fromTemporaryCredentials has changed and results in InvalidClientTokenId #6869

@jandppw

Description

@jandppw

Checkboxes for prior research

Describe the bug

When upgrading @aws-sdk/credential-providers from 3.721.0 to 3.742.0, our tests fail when fromTemporaryCredentials is called.

According to credential-providers/CHANGELOG.md, there are changes to fromTemporaryCredentials in 3.731.0 and 3.734.0.

Regression Issue

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

SDK version number

@aws-sdk/[email protected]

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

v22.13.1

Reproduction Steps

The relevant code is:


const fromTemporaryCredentialsOptions = {
  params: {
    RoleArn: `arn:aws:iam::${id}:role/${rolePathAndName}`,
    // Member must have length less than or equal to 64
    RoleSessionName: roleSessionName,
    DurationSeconds: 1800
  },
  clientConfig: { region, profile }
}
const credentialsProvider = fromTemporaryCredentials(fromTemporaryCredentialsOptions)
const credentials = await credentialsProvider()
return { region, credentials } // awsV3ClientConfig

This is general code, that has the intention to get temporary credentials where the "user" gets necessary permissions by assuming a role (RoleArn). The user‘s credentials should be found in ~/.aws/credentials under the given profile. The returned credentials are then used in different places to create a client to perform commands, e.g.,

const apiGatewayClient = new APIGatewayClient(awsV3ClientConfig)
instance = new S3Client(awsV3ClientConfig)

(but we don’t get there).

Observed Behavior

exception (STSServiceException):
InvalidClientTokenId: The security token included in the request is invalid.
    at throwDefaultError (…/node_modules/@smithy/smithy-client/dist-cjs/index.js:867:20)
    at …/node_modules/@smithy/smithy-client/dist-cjs/index.js:876:5
    at de_CommandError (…/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/index.js:299:14)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async …/node_modules/@smithy/middleware-serde/dist-cjs/index.js:35:20
    at async …/node_modules/@smithy/core/dist-cjs/index.js:167:18
    at async …/node_modules/@smithy/middleware-retry/dist-cjs/index.js:321:38
    at async …/node_modules/@aws-sdk/middleware-logger/dist-cjs/index.js:33:22
    at async …/node_modules/@aws-sdk/credential-providers/dist-cjs/fromTemporaryCredentials.base.js:108:33
    at async clientConfig (…/common/awsV3ClientConfig.js:45:27)

Expected Behavior

Return the correct credentials for the role as before.

Possible Solution

No response

Additional Information/Context

No response

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.p2This is a standard priority issuepotential-regressionMarking this issue as a potential regression to be checked by team memberqueuedThis issues is on the AWS team's backlog

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions