From 337eb79b61921e7c734511027b5c0e00e4cce258 Mon Sep 17 00:00:00 2001 From: exoego Date: Fri, 4 Jan 2019 21:00:11 +0900 Subject: [PATCH 1/2] Add regression test for cf.REGION syntax. --- lib/plugins/aws/provider/awsProvider.test.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/plugins/aws/provider/awsProvider.test.js b/lib/plugins/aws/provider/awsProvider.test.js index c2952fe88..d3ce0ee92 100644 --- a/lib/plugins/aws/provider/awsProvider.test.js +++ b/lib/plugins/aws/provider/awsProvider.test.js @@ -324,6 +324,7 @@ describe('AwsProvider', () => { }, }, }; + expect(awsProvider.getCredentials()).to.deep.eql({ region: options.region }); return awsProvider .request('CloudFormation', @@ -332,6 +333,8 @@ describe('AwsProvider', () => { { region: 'ap-northeast-1' }) .then(data => { expect(data).to.eql({ region: 'ap-northeast-1' }); + // Requesting different region should not affect region in credentials + expect(awsProvider.getCredentials()).to.deep.eql({ region: options.region }); }); }); From d74c0bb679134e4ed781aba50aec6642fc027db9 Mon Sep 17 00:00:00 2001 From: exoego Date: Fri, 4 Jan 2019 21:00:59 +0900 Subject: [PATCH 2/2] Deep-clone so modifying credentials in method does not affect original credentials. --- lib/plugins/aws/provider/awsProvider.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/plugins/aws/provider/awsProvider.js b/lib/plugins/aws/provider/awsProvider.js index 1b4cc8655..cb68ddcd8 100644 --- a/lib/plugins/aws/provider/awsProvider.js +++ b/lib/plugins/aws/provider/awsProvider.js @@ -226,7 +226,7 @@ class AwsProvider { */ request(service, method, params, options) { const that = this; - const credentials = that.getCredentials(); + const credentials = _.cloneDeep(that.getCredentials()); // Make sure options is an object (honors wrong calls of request) const requestOptions = _.isObject(options) ? options : {}; const shouldCache = _.get(requestOptions, 'useCache', false);