aws-sdk-js: Getting CredentialsError: Missing credentials in config starting in v2.44.0

I use the aws-sdk from a little node.js CLI tool that I wrote for running some EC2 tasks. This has been working for several weeks with no problem. Then, I recently upgraded the version of the aws-sdk from 2.9.0 to 2.45.0. After that I started getting the error whenever my tool made a call to the aws-sdk.:

CredentialsError: CredentialsError: Missing credentials in config
    at ClientRequest.<anonymous> (C:\Dev\GitHub\vcme\cq-loadtest\node_modules\aws-sdk\lib\http\node.js:83:34)
    at ClientRequest.g (events.js:291:16)
    at emitNone (events.js:86:13)
    at ClientRequest.emit (events.js:185:7)
    at Socket.emitTimeout (_http_client.js:620:10)
    at Socket.g (events.js:291:16)
    at emitNone (events.js:86:13)
    at Socket.emit (events.js:185:7)
    at Socket._onTimeout (net.js:339:8)
    at ontimeout (timers.js:365:14)
    at tryOnTimeout (timers.js:237:5)
    at Timer.listOnTimeout (timers.js:207:5)

I downgraded my aws-sdk version to 2.44.0, and the error still occurs in that version. I downgraded again to 2.43.0, and the error no longer occurs.

So, it seems that whatever is causing this to happen is a change introduced in aws-sdk@2.44.0.

Here is an example of the code in my tool where the problem occurs:


    // excerpt
    const AWS = require('aws-sdk/global');
    const ECS = require('aws-sdk/clients/ecs');

    const ecs = new ECS();
    const params = {
        cluster: 'cluster-mycluster-XXXXXXXXXXX',
        desiredStatus = 'RUNNING'
    };

    ecs.listTasks(params, (err, taskListData) => {
        if (err) return done(err);   // callback
        // do something with taskListData
        return done(null);  // callback 
    }

I checked out he CHANGELOG for 2.44.0, and I did see a mention of a change related to the AWS_SHARED_CREDENTIALS_FILE. I’m not sure that’s directly relevant though.

I can say that this tool always runs using the default credentials specified via the awscli, i.e. set via aws configure.

Not sure at this point whether this is an actual bug in aws-sdk, or in my code that was somehow revealed by the change to aws-sdk.

I’m a n00b to aws-sdk, so any suggestions or guidance is welcome.

Thanks and cheers, Matt

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 16 (6 by maintainers)

Most upvoted comments

@matsaleh13 v2.44.0 of the SDK did introduce the ability to source credentials from the ~/.aws/config file, where previously it was only able to be sourced from ~/.aws/credentials. However, that should only happen if AWS_SDK_LOAD_CONFIG is set to a truthy value.

Can you verify in your node.js script if AWS_SDK_LOAD_CONFIG is set? You can do that by checking process.env.AWS_SDK_LOAD_CONFIG from within your script.

The error object you are receiving should also contain some special fields (I believe originalError is one). Can you JSON.stringify the error and share what that looks like as well? That may tell us what profile/file was attempted to be read.