Class: AWS.EC2MetadataCredentials

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

Overview

Note:

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

Represents credentials received from the metadata service on an EC2 instance.

By default, this class will connect to the metadata service using AWS.MetadataService and attempt to load any available credentials. If it can connect, and credentials are available, these will be used with zero configuration.

This credentials class will by default timeout after 1 second of inactivity and retry 3 times. If your requests to the EC2 metadata service are timing out, you can increase these values by configuring them directly:

AWS.config.credentials = new AWS.EC2MetadataCredentials({
  httpOptions: { timeout: 5000 }, // 5 second timeout
  maxRetries: 10, // retry 10 times
  retryDelayOptions: { base: 200 } // see AWS.Config for information
});

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.EC2MetadataCredentials(options) ⇒ void

Method Details

refresh(callback) ⇒ void

Loads the credentials from the instance metadata service

Callback (callback):

  • function(err) { ... }

    Called when the instance metadata service responds (or fails). 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.EC2MetadataCredentials.get