8000 What's the deal with credentials. It's voodoo. · Issue #1276 · aws/aws-sdk-js · GitHub
[go: up one dir, main page]

Skip to content
What's the deal with credentials. It's voodoo. #1276
@cmawhorter

Description

@cmawhorter

Today I'm spending my latest hour of time debugging an issue relating to the way aws sdk loads credentials. Apart from the swallowing of errors, this is my single biggest pain point with the js aws sdk.

It seems that require('aws-sdk') does some magic to load credentials, but it's a very bad magician. It' more... "is this your card" than "i just made the statue of liberty disappear".

This is the only way I've found to reliably use aws-sdk across all environments (tests, browserify/webpack, lambda, ec2, etc.).

var s3 = new AWS.S3();
module.exports = { 
  put: function() { 
    s3.put(...); 
  } 
}; 

// becomes 

module.exports = { 
  put: function() { 
    var s3 = new AWS.S3();
    s3.put(...); 
  } 
}; 

And now, throw in the async nature of cognito credential loading and mixed-credential environments, and the time I've spent working through problems around loading credentials in aws sdk can be measured in the tens of hours.

Please, please, please give me var aws = new AWS({ ...config... }) and deprecate the global AWS object.

AWS.config.update is badddddddddd. It's global, but it isn't.

var AWS = require('aws-sdk')
var s3 = new AWS.S3();
console.log('1. s3 region', s3.config.region); // us-east-1
AWS.config.update({ region: 'us-west-2' })
console.log('2. s3 region', s3.config.region); // us-east-1
var s3 = new AWS.S3();
console.log('3. s3 region', s3.config.region); // us-west-2

Hate your job? Sprinkle AWS.config.update's throughout the codebase and watch as your team pulls their hair out.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestA feature should be added or improved.needs-major-versionCan only be considered for the next major release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0