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!
Sign in to the AWS Management Console and open the AWS Config console at https://console.aws.amazon.com/config/ .
To deploy a configuration by using the consoleIn the navigation pane, choose AWS AppConfig. On the Applications tab, choose an application, and then choose View details. On the Environments tab, choose an environment, and then choose View details. Choose Start deployment.
The config file is located at ~/. aws/config on Linux or macOS, or at C:\Users\ USERNAME \. aws\config on Windows. This file contains the configuration settings for the default profile and any named profiles.
To turn on AWS Config with the AWS CLI, use the put-configuration-recorder, put-delivery-channel, and start-configuration-recorder commands. The put-configuration-recorder command creates a new configuration recorder to record your selected resource configurations.
The answer of sreenivas is correct. It also seems to be the only way to do this without writing a custom function.
I've traced it back in the source code and the the way it loads ~/.aws/config
is similar to this pseudocode:
if process.env.AWS_SDK_LOAD_CONFIG:
return load('~/.aws/credentials').overwrite('~/.aws/config')
else:
return load('~/.aws/credentials')
This also means you can set the environment variable after require('aws-sdk')
, as long as you do it before new SharedIniFileCredentials({..})
or credentials.refresh()
. Beware that credentials.get()
will not work until the sessiontoken has expired.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With