Skip to content

Commit

Permalink
Add credentialProvider as an optional parameter of ConfigurationOptions
Browse files Browse the repository at this point in the history
As discussed in #1338 the documentation for AWS.S3 and AWS.SES both
state that they accept credentialProvider, which is an instance of
AWS.CredentialProviderChain, as part of the configuration options.

However, the declaration for ConfigurationOptions did not expose such a
parameter. This patch resolves that issue.

Fixes #1338
  • Loading branch information
RLovelett committed Feb 2, 2017
1 parent 67f8e30 commit 159a768
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/config.d.ts
Expand Up @@ -2,6 +2,7 @@ import {Agent as httpAgent} from 'http';
import {Agent as httpsAgent} from 'https';
import {AWSError} from './error';
import {Credentials, CredentialsOptions} from './credentials';
import {CredentialProviderChain} from './credentials/credential_provider_chain';
import {ConfigurationServicePlaceholders, ConfigurationServiceApiVersions} from './config_service_placeholders';

export class ConfigBase extends ConfigurationOptions{
Expand Down Expand Up @@ -171,6 +172,10 @@ export abstract class ConfigurationOptions {
* The AWS credentials to sign requests with.
*/
credentials?: Credentials|CredentialsOptions
/**
* The provider chain used to resolve credentials if no static credentials property is set.
*/
credentialProvider?: CredentialProviderChain
/**
* AWS access key ID.
*
Expand Down
11 changes: 10 additions & 1 deletion ts/config.ts
Expand Up @@ -93,4 +93,13 @@ var config = AWS.config.loadFromPath('/to/path');
// test update allowing unknown keys
AWS.config.update({
fake: 'fake'
}, true);
}, true);

// Test constructing with a CredentialProviderChain
var options = {
credentialProvider: new AWS.CredentialProviderChain([
() => new AWS.EC2MetadataCredentials()
])
};
var s3 = new AWS.S3(options);
var ses = new AWS.SES(options);

0 comments on commit 159a768

Please sign in to comment.