AWS.EnvironmentCredentials — AWS SDK for JavaScript (original) (raw)

We recommend that you migrate to AWS SDK for JavaScript v3. For dates, additional details, and information on how to migrate, please refer to the linked announcement.

Overview

Represents credentials from the environment.

By default, this class will look for the matching environment variables prefixed by a given envPrefix. The un-prefixed environment variable names for each credential value is listed below:

accessKeyId: ACCESS_KEY_ID
secretAccessKey: SECRET_ACCESS_KEY
sessionToken: SESSION_TOKEN

With the default prefix of 'AWS', the environment variables would be:

AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN

Constructor Summarycollapse

Property Summarycollapse

Properties inherited from AWS.Credentials

expired, expireTime, accessKeyId, secretAccessKey, sessionToken, expiryWindow

Method Summarycollapse

Methods inherited from AWS.Credentials

needsRefresh, get, getPromise, refreshPromise

Constructor Details

new AWS.EnvironmentCredentials(envPrefix) ⇒ void

Creates a new EnvironmentCredentials class with a given variable prefix envPrefix. For example, to load credentials using the 'AWS' prefix:

var creds = new AWS.EnvironmentCredentials('AWS');
creds.accessKeyId == 'AKID' // from AWS_ACCESS_KEY_ID env var

Property Details

envPrefix ⇒ String

Returns the prefix for the environment variable names excluding the separating underscore ('_').

Method Details

refresh(callback) ⇒ void

Loads credentials from the environment using the prefixed environment variables.