From 0642da0822e9699862a81e424af69152248bdf6a Mon Sep 17 00:00:00 2001 From: Ryan Lovelett Date: Thu, 2 Feb 2017 12:44:22 -0500 Subject: [PATCH] Add credentialProvider as an optional parameter of ConfigurationOptions (#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 --- .changes/next-release/bugfix-TypeScript-5f321e6b.json | 5 +++++ lib/config.d.ts | 5 +++++ ts/config.ts | 11 ++++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 .changes/next-release/bugfix-TypeScript-5f321e6b.json diff --git a/.changes/next-release/bugfix-TypeScript-5f321e6b.json b/.changes/next-release/bugfix-TypeScript-5f321e6b.json new file mode 100644 index 0000000000..1de5e08df0 --- /dev/null +++ b/.changes/next-release/bugfix-TypeScript-5f321e6b.json @@ -0,0 +1,5 @@ +{ + "type": "bugfix", + "category": "TypeScript", + "description": "Add `credentialProvider` as an optional parameter of `ConfigurationOptions`." +} \ No newline at end of file diff --git a/lib/config.d.ts b/lib/config.d.ts index db90702627..e22134d964 100644 --- a/lib/config.d.ts +++ b/lib/config.d.ts @@ -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{ @@ -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. * diff --git a/ts/config.ts b/ts/config.ts index 8a31b65eb2..7820eddab5 100644 --- a/ts/config.ts +++ b/ts/config.ts @@ -93,4 +93,13 @@ var config = AWS.config.loadFromPath('/to/path'); // test update allowing unknown keys AWS.config.update({ fake: 'fake' -}, true); \ No newline at end of file +}, 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); \ No newline at end of file