Class: AWS.SharedIniFileCredentials

Inherits:
AWS.Credentials show all
Defined in:
lib/credentials/shared_ini_file_credentials.js

Overview

Note:

This feature is not supported in the browser environment of the SDK.

Represents credentials loaded from shared credentials file (defaulting to ~/.aws/credentials or defined by the AWS_SHARED_CREDENTIALS_FILE environment variable).

Using the shared credentials file

This provider is checked by default in the Node.js environment. To use the credentials file provider, simply add your access and secret keys to the ~/.aws/credentials file in the following format:

[default]
aws_access_key_id = AKID...
aws_secret_access_key = YOUR_SECRET_KEY

Using custom profiles

The SDK supports loading credentials for separate profiles. This can be done in two ways:

  1. Set the AWS_PROFILE environment variable in your process prior to loading the SDK.
  2. Directly load the AWS.SharedIniFileCredentials provider:
var creds = new AWS.SharedIniFileCredentials({profile: 'myprofile'});
AWS.config.credentials = creds;

Constructor Summary collapse

Property Summary

Properties inherited from AWS.Credentials

expired, expireTime, accessKeyId, secretAccessKey, sessionToken, expiryWindow

Method Summary collapse

Methods inherited from AWS.Credentials

needsRefresh, get, getPromise, refreshPromise

Constructor Details

new AWS.SharedIniFileCredentials(options) ⇒ void

Creates a new SharedIniFileCredentials object.

Parameters:

  • options (map)

    a set of options

Options Hash (options):

  • profile (String) — default: AWS_PROFILE env var or 'default'

    the name of the profile to load.

  • filename (String) — default: '~/.aws/credentials' or defined by AWS_SHARED_CREDENTIALS_FILE process env var

    the filename to use when loading credentials.

  • disableAssumeRole (Boolean) — default: false

    True to disable support for profiles that assume an IAM role. If true, and an assume role profile is selected, an error is raised.

Method Details

refresh(callback) ⇒ void

Loads the credentials from the shared credentials file

Callback (callback):

  • function(err) { ... }

    Called after the shared INI file on disk is read and parsed. When this callback is called with no error, it means that the credentials information has been loaded into the object (as the accessKeyId, secretAccessKey, and sessionToken properties).

    Parameters:

    • err (Error)

      if an error occurred, this value will be filled

See Also:

  • AWS.SharedIniFileCredentials.get