diff --git a/.changes/next-release/feature-ChainableTemporaryCredentials-5b0ffa87.json b/.changes/next-release/feature-ChainableTemporaryCredentials-5b0ffa87.json new file mode 100644 index 0000000000..5f5e00e8bb --- /dev/null +++ b/.changes/next-release/feature-ChainableTemporaryCredentials-5b0ffa87.json @@ -0,0 +1,5 @@ +{ + "type": "feature", + "category": "ChainableTemporaryCredentials", + "description": "Support for specifying STS client config when creating ChainableTemporaryCredentials to override endpoint or region." +} diff --git a/dist/aws-sdk-react-native.js b/dist/aws-sdk-react-native.js index 3ee4fe0bda..35695a90bc 100644 --- a/dist/aws-sdk-react-native.js +++ b/dist/aws-sdk-react-native.js @@ -17825,10 +17825,14 @@ return /******/ (function(modules) { // webpackBootstrap this.tokenCodeFn = options.tokenCodeFn; } } - this.service = new STS({ - params: params, - credentials: options.masterCredentials || AWS.config.credentials - }); + config = AWS.util.merge( + { + params: params, + credentials: options.masterCredentials || AWS.config.credentials + }, + options.stsConfig || {} + ); + this.service = new STS(config); }, /** diff --git a/lib/credentials/chainable_temporary_credentials.d.ts b/lib/credentials/chainable_temporary_credentials.d.ts index d71656d9af..5ef8520564 100644 --- a/lib/credentials/chainable_temporary_credentials.d.ts +++ b/lib/credentials/chainable_temporary_credentials.d.ts @@ -3,7 +3,7 @@ import {AWSError} from '../error'; import STS = require('../../clients/sts'); export class ChainableTemporaryCredentials extends Credentials { - constructor(options: ChainableTemporaryCredentials.ChainableTemporaryCredentialsOptions, masterCredentials?: Credentials); + constructor(options: ChainableTemporaryCredentials.ChainableTemporaryCredentialsOptions); /** * Creates a new temporary credentials object. */ @@ -24,6 +24,7 @@ declare namespace ChainableTemporaryCredentials { export type ChainableTemporaryCredentialsOptions = { params?: STS.Types.AssumeRoleRequest|STS.Types.GetSessionTokenRequest, masterCredentials?: Credentials, + stsConfig: STS.Types.ClientConfiguration, tokenCodeFn?: (serialNumber: string, callback: (err?: Error, token?: string) => void) => void } } diff --git a/lib/credentials/chainable_temporary_credentials.js b/lib/credentials/chainable_temporary_credentials.js index 7dc6e9daea..f286eac41a 100644 --- a/lib/credentials/chainable_temporary_credentials.js +++ b/lib/credentials/chainable_temporary_credentials.js @@ -119,10 +119,14 @@ AWS.ChainableTemporaryCredentials = AWS.util.inherit(AWS.Credentials, { this.tokenCodeFn = options.tokenCodeFn; } } - this.service = new STS({ - params: params, - credentials: options.masterCredentials || AWS.config.credentials - }); + config = AWS.util.merge( + { + params: params, + credentials: options.masterCredentials || AWS.config.credentials + }, + options.stsConfig || {} + ); + this.service = new STS(config); }, /** diff --git a/package.json b/package.json index 453c8b2760..f08e2be1a3 100644 --- a/package.json +++ b/package.json @@ -143,4 +143,4 @@ "helper-test": "mocha scripts/lib/test-helper.spec.js", "csm-functional-test": "mocha test/publisher/functional_test" } -} \ No newline at end of file +} diff --git a/test/credentials.spec.js b/test/credentials.spec.js index 758c7c7af7..94d41f1a98 100644 --- a/test/credentials.spec.js +++ b/test/credentials.spec.js @@ -1609,6 +1609,12 @@ }); expect(creds).to.have.property('tokenCodeFn', null); }); + it('should forward enpoint param to sts client', function() { + var creds = new AWS.ChainableTemporaryCredentials({ + stsConfig: { endpoint: 'https://testendpoint' } + }); + expect(creds.service.endpoint.hostname).to.equal('testendpoint'); + }); }); describe('masterCredentials', function() { var origCreds, origProvider;