Search code examples
amazon-web-servicesaws-sdkaws-sdk-nodejs

How to Load config from ~/.aws/config


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!


Solution

  • 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