Class: AWS.TemporaryCredentials
- Inherits:
-
AWS.Credentials
- Object
- AWS.Credentials
- AWS.TemporaryCredentials
- Defined in:
- lib/credentials/temporary_credentials.js
Overview
AWS.TemporaryCredentials is deprecated, but remains available for backwards compatibility. AWS.ChainableTemporaryCredentials is the preferred class for temporary credentials.
In order to create temporary credentials, you first need to have "master" credentials configured in AWS.Config.credentials. These master credentials are necessary to retrieve the temporary credentials, as well as refresh the credentials when they expire.
Represents temporary credentials retrieved from AWS.STS. Without any extra parameters, credentials will be fetched from the AWS.STS.getSessionToken() operation. If an IAM role is provided, the AWS.STS.assumeRole() operation will be used to fetch credentials for the role instead.
To setup temporary credentials, configure a set of master credentials using the standard credentials providers (environment, EC2 instance metadata, or from the filesystem), then set the global credentials to a new temporary credentials object:
// Note that environment credentials are loaded by default,
// the following line is shown for clarity:
AWS.config.credentials = new AWS.EnvironmentCredentials('AWS');
// Now set temporary credentials seeded from the master credentials
AWS.config.credentials = new AWS.TemporaryCredentials();
// subsequent requests will now use temporary credentials from AWS STS.
new AWS.S3().listBucket(function(err, data) { ... });
Constructor Summary
-
new AWS.TemporaryCredentials(params, masterCredentials) ⇒ void
constructor
Creates a new temporary credentials object.
Property Summary
-
masterCredentials ⇒ AWS.Credentials
readwrite
The master (non-temporary) credentials used to get and refresh temporary credentials from AWS STS.
Properties inherited from AWS.Credentials
expired, expireTime, accessKeyId, secretAccessKey, sessionToken, expiryWindow
Method Summary
-
refresh(callback) ⇒ void
Refreshes credentials using AWS.STS.assumeRole() or AWS.STS.getSessionToken(), depending on whether an IAM role ARN was passed to the credentials constructor().
Methods inherited from AWS.Credentials
needsRefresh, get, getPromise, refreshPromise
Constructor Details
new AWS.TemporaryCredentials(params, masterCredentials) ⇒ void
In order to create temporary credentials, you first need to have "master" credentials configured in AWS.Config.credentials. These master credentials are necessary to retrieve the temporary credentials, as well as refresh the credentials when they expire.
Creates a new temporary credentials object.
Property Details
masterCredentials ⇒ AWS.Credentials (readwrite)
Returns the master (non-temporary) credentials used to get and refresh temporary credentials from AWS STS.
Method Details
refresh(callback) ⇒ void
Refreshes credentials using AWS.STS.assumeRole() or AWS.STS.getSessionToken(), depending on whether an IAM role ARN was passed to the credentials constructor().