Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Respect custom stack name
Browse files Browse the repository at this point in the history
Use a custom name for the CloudFormation stack set using provider.stackName parameter
zvymazal committed Mar 18, 2019

Verified

This commit was signed with the committer’s verified signature.
SimonBrandner Šimon Brandner
1 parent 526eeae commit 12c9c47
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -45,8 +45,6 @@ class ServerlessResourcesEnv {
* @returns {Promise.<TResult>}
*/
afterDeploy() {
const stackName = this.getStackName();

// First fetch all of our Resources from AWS by doing a network call
return this.fetchCFResources().then((resourceResult) => {
// Map these to an object keyed by the Logical id pointing to the PhysicalId
@@ -57,7 +55,7 @@ class ServerlessResourcesEnv {

// For each function, update the env files on that function.
const updatePromises = _.map(_.keys(this.serverless.service.functions), (functionName) => {
const awsFunctionName = `${stackName}-${functionName}`;
const awsFunctionName = `${this.serverless.service.service}-${this.getStage()}-${functionName}`;
const resourceList = _.map(
this.serverless.service.functions[functionName].custom &&
this.serverless.service.functions[functionName].custom['env-resources'],
@@ -250,7 +248,11 @@ class ServerlessResourcesEnv {
* @returns {string}
*/
getStackName() {
return `${this.serverless.service.service}-${this.getStage()}`;
let returnValue = `${this.serverless.service.service}-${this.getStage()}`;
if (this.serverless.service.provider.stackName) {
returnValue = this.serverless.service.provider.stackName;
}
return returnValue;
}
}

0 comments on commit 12c9c47

Please sign in to comment.