codetheweb / serverless-step-functions-local

Run AWS step functions offline with Serverless
MIT License
16 stars 17 forks source link

Serverless 3.x support? #20

Open baziliolg opened 2 years ago

baziliolg commented 2 years ago

Hi, the requirements state that this plugin requires Serverless >= v2.32.0. I have Serverless 3.21.0: Environment: darwin, node 18.6.0, framework 3.21.0 (local), plugin 6.2.2, SDK 4.3.2

When I try to install serverless-step-functions-local package, the installation fails:

$ ./node_modules/serverless/bin/serverless.js plugin install -n serverless-step-functions-local
✖ npm ERR! code ERESOLVE
  npm ERR! ERESOLVE unable to resolve dependency tree
  npm ERR!
  npm ERR! While resolving: undefined@undefined
  npm ERR! Found: serverless@3.21.0
  npm ERR! node_modules/serverless
  npm ERR!   serverless@"^3.18.2" from the root project
  npm ERR!
  npm ERR! Could not resolve dependency:
  npm ERR! peer serverless@"^2.32.0" from serverless-step-functions-local@0.4.0
  npm ERR! node_modules/serverless-step-functions-local
  npm ERR!   dev serverless-step-functions-local@"0.4.0" from the root project
  npm ERR!
  npm ERR! Fix the upstream dependency conflict, or retry
  npm ERR! this command with --force, or --legacy-peer-deps
  npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

Is this by design, the plugin does not indeed support Serverless 3.x?

codetheweb commented 2 years ago

The peer dependency is ^2.32.0, which means any version >= 2.32.0 and < 3.0.0.

I haven't tested it with the most recent version of Serverless. If it does work, happy to accept a PR updating the peer dependency. :)

shinnoki commented 2 years ago

I've tried this plugin with serverless@3.21.0 and serverless-offline@9.1.6, and found out that OFFLINE_STEP_FUNCTIONS_ARN_ environment variables do not appear.

As a workaround, directly defining arn:aws:states:${region}:${accountId}:stateMachine:${stateMachineName} in lambda codes seems working.

jkbgo commented 2 years ago

@shinnoki I tried the solution you recommended and it starts the execution but after the first lambda function, it goes into a wait state, and then after some time it gives a timeout error. Did you face this issue also?

cullylarson commented 1 year ago

I'm running into the same issue. Manually setting the OFFLINE_STEP_FUNCTIONS_ARN_ env variables doesn't seem to work. I get this error:

StateMachineDoesNotExist: State Machine Does Not Exist

Also not seeing any logs from serverless-step-functions-local on startup (as we did before upgrading serverless). It seems like maybe serverless-step-functions-local is not starting at all.

serverless: 3.24.1
serverless-offline: 11.2.3
serverless-step-functions: 3.11.0
serverless-step-functions-local: 0.4.0

In case it helps someone find this in search, we were initially getting this error before realizing the OFFLINE_STEP_FUNCTIONS_ARN_ env variables aren't being set:

InvalidArn: Invalid Arn: ''

EDIT

I ended up getting this to work. There are a few issues:

Warning: Invalid configuration encountered at 'provider.environment': unrecognized property 'OFFLINE_STEP_FUNCTIONS_ARN_dripEmailScheduling-development'

It might be possible to tell serverless to allow those env variables. But for now manually setting them is a fine workaround.

jkbgo commented 1 year ago

Does it invoke local lambda functions as well in steps? @cullylarson

walleXD commented 1 year ago

I have tried out the PR #21 and I my state machine also gets stuck in the wait state until it times out

@cullylarson was your solution to just to use sls offline start?

walleXD commented 1 year ago

Does it invoke local lambda functions as well in steps? @cullylarson

You can invoke it with the aws cli aws stepfunctions --endpoint-url http://localhost:8083 start-execution --state-machine-arn ARN