mirror of
https://github.com/serverless/serverless.git
synced 2025-12-08 19:46:03 +00:00
Remove the errant (but understandable) distributed usage of region and stage settings. This otherwise locks in a multitude of bugs around the improper algorithm for selecting (given all context) the proper region or stage setting. Instead, all code should use the centralized algorithm for determining such values. This creates a strange first and second class configuration concept but these two are sufficiently varied and complex in their creation and use that this seems appropriate.
58 lines
1.5 KiB
JavaScript
58 lines
1.5 KiB
JavaScript
'use strict';
|
|
|
|
const BbPromise = require('bluebird');
|
|
|
|
module.exports = {
|
|
getStackInfo() {
|
|
// NOTE: this is the global gatheredData object which will be passed around
|
|
this.gatheredData = {
|
|
info: {
|
|
functions: [],
|
|
endpoint: '',
|
|
service: this.serverless.service.service,
|
|
stage: this.provider.getStage(),
|
|
region: this.provider.getRegion(),
|
|
stack: this.provider.naming.getStackName(),
|
|
},
|
|
outputs: [],
|
|
};
|
|
|
|
const stackName = this.provider.naming.getStackName();
|
|
|
|
// Get info from CloudFormation Outputs
|
|
return this.provider.request('CloudFormation',
|
|
'describeStacks',
|
|
{ StackName: stackName })
|
|
.then((result) => {
|
|
let outputs;
|
|
|
|
if (result) {
|
|
outputs = result.Stacks[0].Outputs;
|
|
|
|
const serviceEndpointOutputRegex = this.provider.naming
|
|
.getServiceEndpointRegex();
|
|
|
|
// Outputs
|
|
this.gatheredData.outputs = outputs;
|
|
|
|
// Functions
|
|
this.serverless.service.getAllFunctions().forEach((func) => {
|
|
const functionInfo = {};
|
|
functionInfo.name = func;
|
|
functionInfo.deployedName = `${
|
|
this.serverless.service.service}-${this.provider.getStage()}-${func}`;
|
|
this.gatheredData.info.functions.push(functionInfo);
|
|
});
|
|
|
|
// Endpoints
|
|
outputs.filter(x => x.OutputKey.match(serviceEndpointOutputRegex))
|
|
.forEach(x => {
|
|
this.gatheredData.info.endpoint = x.OutputValue;
|
|
});
|
|
}
|
|
|
|
return BbPromise.resolve();
|
|
});
|
|
},
|
|
};
|