Skip to content

Commit cae3f1e

Browse files
authored
Merge pull request #51 from horike37/pr-50
update name variables to follow camelCase
2 parents 8b94d46 + 70f4d69 commit cae3f1e

File tree

4 files changed

+40
-37
lines changed

4 files changed

+40
-37
lines changed

README.md

+30-27
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ stepFunctions:
3434
- http:
3535
path: gofunction
3636
method: GET
37+
name: myStateMachine
3738
definition:
3839
Comment: "A Hello World example of the Amazon States Language using an AWS Lambda Function"
3940
StartAt: HelloWorld1
@@ -55,6 +56,31 @@ stepFunctions:
5556
- yourTask
5657
```
5758

59+
### Adding a custom name for a stateMachine
60+
In case you need to interpolate a specific stage or service layer variable as the
61+
stateMachines name you can add a `name` property to your yaml.
62+
63+
```yml
64+
service: messager
65+
66+
functions:
67+
sendMessage:
68+
handler: handler.sendMessage
69+
70+
stepFunctions:
71+
stateMachines:
72+
sendMessageFunc:
73+
name: sendMessageFunc-${self:custom.service}-${opt:stage}
74+
definition:
75+
<your definition>
76+
77+
plugins:
78+
- serverless-step-functions
79+
```
80+
81+
Please note, that during normalization some characters will be changed to adhere to CloudFormation templates.
82+
You can get the real statemachine name using `{ "Fn::GetAtt": ["MyStateMachine", "Name"] }`.
83+
5884
## Events
5985
### API Gateway
6086
To create HTTP endpoints as Event sources for your StepFunctions statemachine
@@ -135,45 +161,22 @@ functions:
135161
hello:
136162
handler: handler.hello
137163
environment:
138-
statemachine_arn: ${self:resources.Outputs.HelloStepfunc.Value}
164+
statemachine_arn: ${self:resources.Outputs.MyStateMachine.Value}
139165

140166
stepFunctions:
141167
stateMachines:
142168
hellostepfunc:
169+
name: myStateMachine
143170
definition:
144171
<your definition>
145172

146173
resources:
147174
Outputs:
148-
HelloStepfunc:
175+
MyStateMachine:
149176
Description: The ARN of the example state machine
150177
Value:
151-
Ref: HellostepfuncStepFunctionsStateMachine
178+
Ref: MyStateMachine
152179

153180
plugins:
154181
- serverless-step-functions
155182
```
156-
157-
### Adding a custom name for a stateMachine
158-
In case you need to interpolate a specific stage or service layer variable as the
159-
stateMachines name you can add a `Name` property to your yaml.
160-
161-
```yml
162-
service: messager
163-
164-
functions:
165-
sendMessage:
166-
handler: handler.sendMessage
167-
168-
stepFunctions:
169-
stateMachines:
170-
sendMessageFunc:
171-
Name: sendMessageFunc-${self:custom.service}-${opt:stage}
172-
definition:
173-
<your definition>
174-
175-
plugins:
176-
- serverless-step-functions
177-
```
178-
179-
Please note, that during normalization some characters will be changed to adhere to CloudFormation templates.

lib/deploy/stepFunctions/compileStateMachines.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ module.exports = {
1212
let DependsOn;
1313
let Name;
1414

15-
if (stateMachineObj.Name) {
16-
Name = stateMachineObj.Name;
15+
if (stateMachineObj.name) {
16+
Name = stateMachineObj.name;
1717
}
1818

1919
if (stateMachineObj.definition) {

lib/deploy/stepFunctions/compileStateMachines.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ describe('#compileStateMachines', () => {
8181
stateMachines: {
8282
myStateMachine1: {
8383
definition: 'definition1',
84-
Name: 'stateMachineBeta1',
84+
name: 'stateMachineBeta1',
8585
},
8686
myStateMachine2: {
8787
definition: 'definition2',
88-
Name: 'stateMachineBeta2',
88+
name: 'stateMachineBeta2',
8989
},
9090
},
9191
};

lib/naming.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
'use strict';
22

33
module.exports = {
4-
getStateMachineLogicalId(stateMachineName, Name) {
5-
if (Name) {
6-
return `${this.provider.naming.getNormalizedFunctionName(Name)}`;
4+
getStateMachineLogicalId(stateMachineName, customName) {
5+
if (customName) {
6+
return `${this.provider.naming.getNormalizedFunctionName(customName)}`;
77
}
88
return `${this.provider.naming
99
.getNormalizedFunctionName(stateMachineName)}StepFunctionsStateMachine`;
1010
},
1111

12-
getStateMachineOutputLogicalId(stateMachineName, Name) {
13-
if (Name) {
14-
return `${this.provider.naming.getNormalizedFunctionName(Name)}Arn`;
12+
getStateMachineOutputLogicalId(stateMachineName, customName) {
13+
if (customName) {
14+
return `${this.provider.naming.getNormalizedFunctionName(customName)}Arn`;
1515
}
1616
return `${this.provider.naming
1717
.getNormalizedFunctionName(stateMachineName)}StepFunctionsStateMachineArn`;

0 commit comments

Comments
 (0)