Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
AWS CredentialProviderChain example in aws-sdk of NodeJS
var AWS = require('aws-sdk');
var chain = new AWS.CredentialProviderChain();
var credentials
AWS.CredentialProviderChain.defaultProviders = [
function () { return new AWS.EnvironmentCredentials('AWS'); },
function () { return new AWS.EnvironmentCredentials('AMAZON'); },
function () { return new AWS.SharedIniFileCredentials({profile: 'my_profile_name'}); },
function () { return new AWS.EC2MetadataCredentials(); }
]
chain.resolve((err, cred)=>{
AWS.config.credentials = credentials = cred;
});
AWS.config.update({region: 'us-west-2' });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment