How to Load config from ~/.aws/config

sreenivas picture sreenivas · Jun 8, 2017 · Viewed 13.7k times · Source

change log says Load config from ~/.aws/config if AWS_SDK_LOAD_CONFIG is set. Couldn't find any examples or documentation regarding how to load the config. Any help!

Answer

sreenivas picture sreenivas · Jun 22, 2017

There is a little bit of magic in how aws-sdk loads the config

either set the env variable

export AWS_SDK_LOAD_CONFIG="true"

or before loading the aws-sdk set

process.env.AWS_SDK_LOAD_CONFIG = true; 

Then load the aws module;

var AWS = require('aws-sdk');

You can access the region directly by

AWS.config.region