Skip to content

Commit b5ca732

Browse files
authored
Merge pull request #111 from hgiasac/add-provider-based-region-support
Add provider based region support
2 parents 94d11d6 + 56b8c0b commit b5ca732

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

shared/utils.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,17 @@ module.exports = {
77
setDefaults() {
88
this.options.stage = _.get(this, 'options.stage')
99
|| 'dev';
10-
this.options.region = _.get(this, 'options.region')
11-
|| 'us-central1';
1210
this.options.runtime = _.get(this, 'options.runtime')
1311
|| 'nodejs8';
1412

13+
// serverless framework is hard-coding us-east-1 region from aws
14+
// this is temporary fix for multiple regions
15+
const region = _.get(this, 'options.region')
16+
|| _.get(this, 'serverless.service.provider.region');
17+
18+
this.options.region = (!region || region === 'us-east-1')
19+
? 'us-central1' : region;
20+
1521
return BbPromise.resolve();
1622
},
1723
};

shared/utils.test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,16 @@ describe('Utils', () => {
3434
expect(googleCommand.options.runtime).toEqual('nodejs6');
3535
});
3636
});
37+
38+
39+
it('should set the provider values for stage and region if provided', () => {
40+
googleCommand.serverless.service.provider = {
41+
region: 'my-region',
42+
};
43+
44+
return googleCommand.setDefaults().then(() => {
45+
expect(googleCommand.options.region).toEqual('my-region');
46+
});
47+
});
3748
});
3849
});

0 commit comments

Comments
 (0)