node.js - Determine if aws-sdk is has global credentials configured -


from information provided in aws sdk config guide there multiple ways configure sdk:

  1. loaded iam roles amazon ec2 (if running on ec2),
  2. loaded shared credentials file (~/.aws/credentials),
  3. loaded environment variables,
  4. loaded json file on disk,
  5. hardcoded in application

is there way determine:

a) if sdk has global config (credentials) , b) how credentials/settings loaded/configured?

so appears can config's credentialprovider object credentialproviderchain. resolve() method returns instance of aws.credentials identify method used configuring credentials.

example follows:

aws.config.credentialprovider.resolve(function(err, credential) {    if(credential !== null) {      awscredential = credential.constructor.name;        })  console.log("aws configured? ", awscredential ? 'yes'.green : 'no'.red);  if(awscredential) {    console.log("    provided by: ", awscredential);  } 

specifically noting returned credential reveals classname via credential.constructor.name.

edit: i've written post comparing use of callbacks promises achieve same goal - in case else encounters same question.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -