Search code examples
amazon-dynamodbgithub-actionsaws-sdkaws-sdk-jsaws-sdk-nodejs

AWS JS SDK suddenly throws "The Access Key ID or security token is invalid."


Has anyone also noticed a change in behavior of the AWS JS SDK recently?

Because I have a CI pipeline in Github Actions, in which a Local DynamoDB is started and written to the DyanmoDB using this docClient setup:

const docClient = new AWS.DynamoDB.DocumentClient({
  region: 'localhost',
  endpoint: 'http://localhost:8000',
  accessKeyId: 'DEFAULTACCESSKEY',
  secretAccessKey: 'DEFAULTSECRETKEY',
  convertEmptyValues: true,
});

This also worked wonderfully until now, only since today at noon this fails with this error.

I have not changed anything in the source code, I have only run the CI job again.

 UnrecognizedClientException: The Access Key ID or security token is invalid.
281
      at Request.extractError (node_modules/aws-sdk/lib/protocol/json.js:80:27)
282
      at Request.callListeners (node_modules/aws-sdk/lib/sequential_executor.js:106:20)
283
      at Request.emit (node_modules/aws-sdk/lib/sequential_executor.js:78:10)
284
      at Request.emit (node_modules/aws-sdk/lib/request.js:686:14)

I could not find anything in the aws-sdk package (2.1409.0) released today that could indicate this.


Solution

  • Since the latest release there has been an enforcement on access keys which can be used:

    DynamoDB local version 2.0.0 and greater AWS_ACCESS_KEY_ID can contain the only letters (A–Z, a–z) and numbers (0–9).

    Furthermore, if you're using an external package such as serverless-dynamodb-local you can upgrade to the most recent version, as they have all been modified to handle this change in DynamoDB Local

    https://repost.aws/articles/ARc4hEkF9CRgOrw8kSMe6CwQ/troubleshooting-the-access-key-id-or-security-token-is-invalid-error-after-upgrading-dynamodb-local-to-version-2-0-or-greater