aws-sdk-config-loader
v1.0.1
Published
AWS config file loader for CLI tools
Downloads
19
Readme
aws-sdk-config-loader
AWS config file loader for CLI tools.
this library load ~/.aws/config
that aws-sdk-js is not supported.
Installation
npm install aws-sdk-config-loader aws-sdk
Usage
API Document: https://moqada.github.io/aws-sdk-config-loader/
put following ~/.aws/credentials
[default]
aws_access_key_id = default_key_id
aws_secret_access_key = default_secret_key
[foo]
aws_access_key_id = foo_key_id
aws_secret_access_key = foo_secret_key
put following ~/.aws/config
.
[default]
region = ap-northeast-1
[foo]
region = us-east-1
import AWS from 'aws-sdk';
import loader from 'aws-sdk-config-loader';
loader(AWS);
// AWS.config.region === 'ap-northeast-1'
// AWS.config.credentials.accessKeyId = 'default_key_id'
// AWS.config.credentials.secretAccessKey = 'default_secret_key'
// export AWS_PROFILE=foo
loader(AWS);
// AWS.config.region === 'us-east-1'
// AWS.config.credentials.accessKeyId = 'foo_key_id'
// AWS.config.credentials.secretAccessKey = 'foo_secret_key'
// export AWS_CONFIG_FILE=/path/to/config
loader(AWS);
// set AWS.config from /path/to/config
loader(AWS, {profile: 'foo'})
// AWS.config.region === 'us-east-1'
// AWS.config.credentials.accessKeyId = 'foo_key_id'
// AWS.config.credentials.secretAccessKey = 'foo_secret_key'
loader(AWS, {profile: 'foo', noReflectCredentials: true})
// AWS.config.region === 'us-east-1'
// AWS.config.credentials.accessKeyId = 'default_key_id'
// AWS.config.credentials.secretAccessKey = 'default_secret_key'