Skip to content

Commit 7162e84

Browse files
author
Chris Sullivan
committed
Added simple custom naming, still follows normalization
1 parent 076e8e6 commit 7162e84

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

lib/deploy/stepFunctions/compileStateMachines.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ module.exports = {
1010
let DefinitionString;
1111
let RoleArn;
1212
let DependsOn;
13+
let Name;
14+
15+
if( stateMachineObj.Name ) {
16+
Name = stateMachineObj.Name;
17+
}
1318

1419
if (stateMachineObj.definition) {
1520
DefinitionString = JSON.stringify(stateMachineObj.definition);
@@ -47,8 +52,8 @@ module.exports = {
4752
DependsOn = 'IamRoleStateMachineExecution';
4853
}
4954

50-
const stateMachineLogicalId = this.getStateMachineLogicalId(stateMachineName);
51-
const stateMachineOutputLogicalId = this.getStateMachineOutputLogicalId(stateMachineName);
55+
const stateMachineLogicalId = this.getStateMachineLogicalId(stateMachineName, Name);
56+
const stateMachineOutputLogicalId = this.getStateMachineOutputLogicalId(stateMachineName, Name);
5257

5358
const stateMachineTemplate = `
5459
{
@@ -83,6 +88,7 @@ module.exports = {
8388
_.merge(this.serverless.service.provider.compiledCloudFormationTemplate.Outputs,
8489
newStateMachineOutPutObject
8590
);
91+
8692
return BbPromise.resolve();
8793
});
8894
}

lib/naming.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
'use strict';
22

33
module.exports = {
4-
getStateMachineLogicalId(stateMachineName) {
4+
getStateMachineLogicalId(stateMachineName, Name) {
5+
if( Name ) {
6+
return Name;
7+
}
58
return `${this.provider.naming
69
.getNormalizedFunctionName(stateMachineName)}StepFunctionsStateMachine`;
710
},
811

9-
getStateMachineOutputLogicalId(stateMachineName) {
12+
getStateMachineOutputLogicalId(stateMachineName, Name) {
13+
if( Name ) {
14+
return Name;
15+
}
1016
return `${this.provider.naming
1117
.getNormalizedFunctionName(stateMachineName)}StepFunctionsStateMachineArn`;
1218
},

0 commit comments

Comments
 (0)