Skip to content

Instantly share code, notes, and snippets.

@subfuzion
Created July 23, 2019 02:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save subfuzion/bd6da29f125927b00209b3389c28ee9e to your computer and use it in GitHub Desktop.
Save subfuzion/bd6da29f125927b00209b3389c28ee9e to your computer and use it in GitHub Desktop.
cdk credentials
const {defaultProvider} = require('@aws-sdk/credential-provider-node');
async function load() {
defaultProvider()
process.env.AWS_SDK_LOAD_CONFIG = true
let profile = process.env.AWS_DEFAULT_PROFILE || 'default'
try {
var provider = new aws.SharedIniFileCredentials({
profile: profile
})
let chain = new aws.CredentialProviderChain([provider])
let credentials = await chain.resolvePromise()
console.log(credentials)
let config = new aws.Config({
profile: profile
});
console.log(config)
console.log('profile: ', credentials.profile)
console.log('region: ', config.region)
} catch (err) {
console.log(err)
}
}
(async () => {
await load()
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment