Skip to content

Commit

Permalink
Add credentialProvider as an optional parameter of ConfigurationOptio…
Browse files Browse the repository at this point in the history
…ns (#1339)

* Add credentialProvider as an optional parameter of ConfigurationOptions

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

* Provide changelog information for the next release
  • Loading branch information
RLovelett authored and chrisradek committed Feb 2, 2017
1 parent 67f8e30 commit 0642da0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changes/next-release/bugfix-TypeScript-5f321e6b.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "bugfix",
"category": "TypeScript",
"description": "Add `credentialProvider` as an optional parameter of `ConfigurationOptions`."
}
5 changes: 5 additions & 0 deletions lib/config.d.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 0642da0

Please sign in to comment.