Aws-sdk-js: TypeError: this.extractCredentials is not a function

Created on 21 Apr 2017  路  13Comments  路  Source: aws/aws-sdk-js

Hi, I'm getting this error in Node, which stop at this line

aws.Config({ 
  accessKeyId: 'FOO', 
  secretAccessKey: 'BAR', 
  region: 'us-west-2'
})

TypeError: this.extractCredentials is not a function at Object.Config (aws-sdk/lib/config.js:273:20)

Any suggestions?

I'm testing this:

var config = new AWS.Config({
  accessKeyId: 'AKID', secretAccessKey: 'SECRET', region: 'us-west-2'
});

From the docs:

https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html#constructor-property

guidance

Most helpful comment

I ran into this too, and the problem is that you must run the constructor explicitly with new.
@johnelliott , use:

const config = new AWS.Config(awsConfig);
//instead of 
const config = AWS.Config(awsConfig);

All 13 comments

@babakness
What version of the SDK are you using?
I just tested your exact code with the latest version and it is not throwing an error:

var AWS = require('aws-sdk');
var config = new AWS.Config({
  accessKeyId: 'AKID', secretAccessKey: 'SECRET', region: 'us-west-2'
});

Do you have any dependencies or code that might be modifying the SDK?

I have this error too, I'm using the aws-sdk version: ^2.45.0

@ramonmulia
Can you share a code sample that I can reproduce the error with? Running the above sample, I'm unable to reproduce.

I used this library and solved my problem:

https://www.npmjs.com/package/aws-config

I'm having the same issue

Same issue:

W20170531-22:47:22.511(-4)? (STDERR) TypeError: this.extractCredentials is not a function
W20170531-22:47:22.512(-4)? (STDERR)     at Object.Config (/Users/jcursi/Sites/joncursi/redbird-web/node_modules/aws-sdk/lib/config.js:275:20)
W20170531-22:47:22.513(-4)? (STDERR)     at meteorInstall.imports.startup.server.accounts.js (imports/startup/server/accounts.js:86:7)
W20170531-22:47:22.513(-4)? (STDERR)     at fileEvaluate (packages/modules-runtime.js:333:9)
W20170531-22:47:22.514(-4)? (STDERR)     at require (packages/modules-runtime.js:228:16)
W20170531-22:47:22.514(-4)? (STDERR)     at meteorInstall.imports.startup.server.index.js (imports/startup/server/index.js:3:1)
W20170531-22:47:22.515(-4)? (STDERR)     at fileEvaluate (packages/modules-runtime.js:333:9)
W20170531-22:47:22.515(-4)? (STDERR)     at require (packages/modules-runtime.js:228:16)
W20170531-22:47:22.515(-4)? (STDERR)     at meteorInstall.server.main.js (server/main.js:3:8)
W20170531-22:47:22.516(-4)? (STDERR)     at fileEvaluate (packages/modules-runtime.js:333:9)
W20170531-22:47:22.516(-4)? (STDERR)     at require (packages/modules-runtime.js:228:16)

@joncursi
Can you share a code sample showing how you're configuring the SDK?

I don't have the exact code since I eventually got it to work... I was trying to set a global config via AWS.config = { ... } which turned the error. I opted to set a local config on the S3 object instead:

const AWS_S3 = new AWS.S3({
  accessKeyId: AWS_ACCESS_ID,
  region: 'us-east-1',
  secretAccessKey: AWS_ACCESS_SECRET,
});

I have the same issue, same line of code as the stack trace @joncursi mentioned.

Here's how I'm making the call:

const awsConfig = {
  region: process.env.AWS_REGION,
  accessKeyId: process.env.AWS_ACCESS_KEY_ID,
  secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
  logger: console.log
};
const config = AWS.Config(awsConfig);

I ran into this too, and the problem is that you must run the constructor explicitly with new.
@johnelliott , use:

const config = new AWS.Config(awsConfig);
//instead of 
const config = AWS.Config(awsConfig);
AWS.config = {
    region: '****,
    accessKeyId: '****',
    secretAccessKey: '****'
};

This solved my problem! 馃暫

It looks like this was resolved. Let us know if you have followup questions.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

Was this page helpful?
0 / 5 - 0 ratings