diff --git a/lib/Project.js b/lib/Project.js index 227725b62..3dc712a71 100644 --- a/lib/Project.js +++ b/lib/Project.js @@ -263,6 +263,10 @@ class Project extends SerializerFileSystem { return this.getStage( stageName ).getAllRegions(); } + getAllRegionNames(stageName){ + return _.map(this.getAllRegions(stageName), 'name'); + } + setRegion(stageName, region){ let stage = this.getStage(stageName); stage.setRegion(region); diff --git a/lib/actions/EndpointDeploy.js b/lib/actions/EndpointDeploy.js index 219afc217..14c8b3ca7 100644 --- a/lib/actions/EndpointDeploy.js +++ b/lib/actions/EndpointDeploy.js @@ -169,7 +169,7 @@ module.exports = function(SPlugin, serverlessPath) { // Set defaults _this.evt.options.names = _this.evt.options.names ? _this.evt.options.names : []; - _this.regions = _this.evt.options.region ? [_this.evt.options.region] : _this.project.getAllRegions(_this.evt.options.stage).map(r => {return r.name;}); + _this.regions = _this.evt.options.region ? [_this.evt.options.region] : _this.project.getAllRegionNames(_this.evt.options.stage); if (_this.evt.options.names.length) { _this.evt.options.names.forEach(function(name) { diff --git a/lib/actions/EventDeploy.js b/lib/actions/EventDeploy.js index 3ccf00c80..494ca2046 100644 --- a/lib/actions/EventDeploy.js +++ b/lib/actions/EventDeploy.js @@ -151,7 +151,7 @@ module.exports = function(SPlugin, serverlessPath) { // Set defaults _this.evt.options.names = _this.evt.options.names ? _this.evt.options.names : []; - _this.regions = _this.evt.options.region ? [_this.evt.options.region] : Object.keys(_this.meta.stages[_this.evt.options.stage].regions); + _this.regions = _this.evt.options.region ? [_this.evt.options.region] : _this.project.getAllRegionNames(_this.evt.options.stage); if (_this.evt.options.names.length) { _this.evt.options.names.forEach(function(endpointName) { diff --git a/lib/actions/FunctionDeploy.js b/lib/actions/FunctionDeploy.js index db7cc3b86..00f799039 100644 --- a/lib/actions/FunctionDeploy.js +++ b/lib/actions/FunctionDeploy.js @@ -186,8 +186,7 @@ module.exports = function(SPlugin, serverlessPath) { _this.project = _this.S.getProject(); // Set Deploy Regions - _this.regions = _this.evt.options.region ? [_this.evt.options.region] : _this.S.getProject().getAllRegions(_this.evt.options.stage).map(r => r.name); - + _this.regions = _this.evt.options.region ? [_this.evt.options.region] : _this.S.getProject().getAllRegionNames(_this.evt.options.stage); if (_this.evt.options.names.length) { _this.evt.options.names.forEach(function(name) { diff --git a/lib/utils/index.js b/lib/utils/index.js index 0110868b1..9beadcfe4 100644 --- a/lib/utils/index.js +++ b/lib/utils/index.js @@ -472,7 +472,7 @@ module.exports = { return BbPromise.reject(new SError(`Invalid stage ${stage}`, SError.errorCodes.UNKNOWN)); } - regions = _.map(S.getProject().getAllRegions(stage), 'name'); + regions = S.getProject().getAllRegionNames(stage); } return BbPromise.map(regions, (region => {