Skip to content

Commit 4595a04

Browse files
committed
Add environment variables for ARNs
1 parent 450cb47 commit 4595a04

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ custom:
3939
4040
Although not neccessary, it's strongly recomended to add the folder with the downloaded step function executables to `.gitignore`. By default, this path is `./.step-functions-local`.
4141

42+
The plugin binds to port 8083, this cannot be changed.
43+
44+
It also adds an environment variable for each created state machine that contains the ARN for it. These variables are prefixed by `OFFLINE_STEP_FUNCTIONS_ARN_`, so the ARN of a state machine named 'WaitMachine', for example could be fetched by reading `OFFLINE_STEP_FUNCTIONS_ARN_WaitMachine`.
45+
4246
## Options
4347

4448
(These go under `custom.stepFunctionsLocal`.)

index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,18 @@ class ServerlessStepFunctionsLocal {
8181
this.stateMachines = parsed.stepFunctions.stateMachines;
8282
}
8383

84-
createEndpoints() {
85-
return Promise.all(Object.keys(this.stateMachines).map(stateMachineName => this.stepfunctionsAPI.createStateMachine({
84+
async createEndpoints() {
85+
const endpoints = await Promise.all(Object.keys(this.stateMachines).map(stateMachineName => this.stepfunctionsAPI.createStateMachine({
8686
definition: JSON.stringify(this.stateMachines[stateMachineName].definition),
8787
name: stateMachineName,
8888
roleArn: `arn:aws:iam::${this.config.accountId}:role/DummyRole`
8989
}).promise()
9090
));
91+
92+
// Set environment variables with references to ARNs
93+
endpoints.forEach(endpoint => {
94+
process.env[`OFFLINE_STEP_FUNCTIONS_ARN_${endpoint.stateMachineArn.split(':')[6]}`] = endpoint.stateMachineArn;
95+
});
9196
}
9297
}
9398

0 commit comments

Comments
 (0)