-
-
Save wancw/cb774528c95288bd3dc4a21f485a71d5 to your computer and use it in GitHub Desktop.
AWS CredentialProviderChain example in aws-sdk of NodeJS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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