Reduce boilerplate code when configuring the AWS Node.js SDK.
http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/node-configuring.html
Takes care of the following:
- Handles corporate proxy via https-proxy-agent if
HTTPS_PROXY
environment variable exists. - Utilize a named profile from
.aws/credentials
file if profile
option specified - Support
AWS_TIMEOUT
environment variable to enforce a maximum timeout for all AWS SDK operations - Honors the
AWS_DEFAULT_PROFILE
and AWS_DEFAULT_REGION
environment variables used by the AWS CLI. - Honors the
AWS_WEB_IDENTITY_TOKEN_FILE
environment variable used for web token based authentication for kubernetes service accounts
Installation
npm install aws-config
Options
awsConfig({
region: 'us-east-1'
sslEnabled: true,
maxRetries: 3,
accessKeyId: 'your_aws_access_key',
secretAccessKey: 'your_secret_key'
profile: 'profile_name',
timeout: 15000
});
Usage
var AWS = require('aws-sdk');
var awsConfig = require('aws-config');
var s3 = new AWS.S3(awsConfig({accessKeyId: '123', secretAccessKey: 'abc'}));
var ec2 = new AWS.EC2(awsConfig({profile: 'aws-profile-name'}));
var dynamo = new AWS.DynamoDB(awsConfig({timeout: 5000}));
AWS.config = awsConfig();
var s3 = new AWS.S3();