vkkis93 / serverless-step-functions-offline Goto Github PK
View Code? Open in Web Editor NEWEmulate step functions locally when developing your Serverless project
License: MIT License
Emulate step functions locally when developing your Serverless project
License: MIT License
When using this plugin, it informs that "Serverless step offline requires Serverless v1.x.x but found 2.6.0"
I'm trying to develop using Golang. When I attempt to run locally, I get an error
Cannot find module 'C:\my\path\go-binary.js'
For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
Is there a way to use other languages with this plugin?
All my Lambda are written in ES6 and I use serverless-webpack to build them and be able to run them on AWS Lambda.
Your plugin doesn't seems to be compatible with it.
When the step function start I got an error which means the js isn't compiled before being executed:
Serverless: Building StepWorkFlow
OOPS /home/projectsrc/schedule-content/index.js:1
(function (exports, require, module, __filename, __dirname) { import { ScheduleContent } from './scheduleContent'
^^^^^^
SyntaxError: Unexpected token import
at createScript (vm.js:74:10)
Having functions as files result in error like this (Function "GetEvents" does not presented in serverless manifest)
functions:
- ${file(step-functions.yml)}
- ${file(functions.yml)}
Serverless version:
"serverless": "^1.35.1"
"serverless-step-functions-offline": "^2.1.4",
provider:
stage: ${opt:stage, 'dev'}
Running
sls step-functions-offline -s Foo
sets opt:stage
to Foo
and therefore the default value dev
isn't used. Using long form --stateMachine=Foo
works as expected.
Maybe removing the short form is the best solution to avoid clashes with serverless
itself?
when I run the startup command I consistently get a connection refused on port 443
Error: connect ECONNREFUSED 127.0.0.1:443 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16)
plugins:
plugins:
- serverless-mocha
- serverless-dotenv-plugin
- serverless-step-functions
- serverless-step-functions-offline
- serverless-offline-sqs
- serverless-offline-kinesis
- serverless-offline
custom:
stepFunctionsOffline:
IndicatorDataRequest: getIndicatorData
ExportProgress: checkExportProgress
HandleCompletedExport: downloadProcessExport
Hi @vkkis93 ,
Firstly thanks for making this package! It is currently the best way to emulate step functions offline by a wide margin and has helped a bunch!
This package looks to still have a fair few open contributions from community members though the last release for the package was in late 2019 (Nearly 2 years ago). At this stage it seems the the package is edging towards being abandonware.
@vkkis93 would you be open to adding more community maintainers to help out with getting members PRs merged? It seems like there are a fair few community efforts in this region including:
#71
#62
#57
#47
#45
#32
#31
I would be happy to try to help work through this backlog of PRs to get things merged / moving again if you are open to it?
Thanks!
ServerlessError: Either function.handler or function.image must be defined. Pass the handler name (i.e. 'index.handler') as the value for function.image.command[0].
Hi, I'm trying the serverless-step-functions-offline plugin but I'm getting the above error. Any ideas how to solve it, please?
I found few changes in the NPM version which aren't in the repo.
It might be a good practice to keep them synced. At least if you don't want to deal with conflicts when you'll merge PR from contributors.
Also, it might be a good practice to create a release on GitHub (or a tag) each time you release a new version of your plugin.
Task output is always added to $.
regardless of the ResultPath
value given for that state. ResultPath does appear to be honored for "Pass" types.
If you're creating a Choice type state and the variable is in a child object, the variable will be undefined.
For example, assume you have data going into your choice that looks like {myBoolean: true, myObject: {objBoolean: true}}
.
If you have your choice variable value set to $.myBoolean
it will work and the choice, true, will be evaluated.
If you have your choice variable set to $.myObject.objBoolean
, the value will be undefined and it will not evaluate to true.
This is due to the way that the values are retrieved out of the state here:
serverless-step-functions-offline/build.js
Line 215 in e2ffc77
In our example above, we'll be attempting to pull result['myObject.objBoolean']
which is not the same as result.myObject.objBoolean
. We'll need to come up with a better way of evaluating the result
objects properties other than just straight array lookup.
Implement Retry, Catch logic
Hello,
Thanks for the great plugin! I was wondering if there was http event support for offline mode. I'm getting a 404 when trying to hit my route, but deployment seemed to work so I believe my template is formatted correctly.
stepFunctions:
stateMachines:
foo:
events:
- http:
path: /gofunction
method: GET
cors: true
name: foo-notes-${opt:stage}
I have follwed the steps exactly as per the documentation, but I am not able to run the step function locally
below is my serverless.yml file content for the related context
custom:
stepFunctionsOffline:
SaveSlotDetails:CreateSubscription
functions: # add 4 functions for CRUD
createSubscription:
handler: handlers/subscriptions.create
name: CreateSubscription
events:
- http:
path: subscriptions # path will be domain.name.com/dev/subscriptions
method: post
cors: true
stepFunctions:
stateMachines:
SlotCheckingMachine:
name: ProcessSlotAvailabilityStateMachine
definition:
StartAt: SaveSlotDetails
TimeoutSeconds: 3600
States:
SaveSlotDetails:
Type: Task
Resource: "arn:aws:lambda:us-east-1:269266452438:function:CreateSlot"
Next: "SearchSubscriptions"
I have tried using both function names
createSubscription and CreateSubscription, but nothing helps.
I checked issues previously raised, but doesn't help much
I am tried using versions 2.1.2 and 2.1.1, but doesn't work. Any help would be appreciated
Have also raised it on stackoverflow:
https://stackoverflow.com/questions/55574154/function-saveslotdetails-does-not-presented-in-serverless-yml
Hi. From 2.1.0 version custom.stepFunctionsOffline is deprecated. I am deleted this from yml.
When I try start "sls step-functions-offline --stage=dev --stateMachine=test" I get error
Function "servicename-dev-hello" does not presented in serverless.yml
functions:
hello:
name: ${self:service}-${opt:stage}-hello
handler: handler.hello
and
States:
hello:
Type: Task
Resource: "arn:aws:lambda:#{AWS::Region}:#{AWS::AccountId}:function:${self:service}-${opt:stage}-hello"
Error
[400] CreateStateMachine <= Invalid State Machine Definition: ''SCHEMA_VALIDATION_FAILED: Expected value of type [STRING] at /States//Branches[1]/States//Resource''
****: { Type: "Parallel", Next: "****", Branches: [ { StartAt: "****", States: { GetToUserData: { Type: "Task", InputPath: "$.detail.toUserId", Resource: { "Fn::GetAtt": ["****", "Arn"], }, ResultPath: "$.toUserDetails", End: true, }, }, }, { StartAt: "****", States: { ****: { Type: "Task", InputPath: "$.detail.fromUserId", Resource: { "Fn::GetAtt": ["****", "Arn"], }, ResultPath: "$.fromUserDetails", End: true, }, }, }, ],
This deploys fine to AWS
I'm using
"serverless-step-functions": "^1.3.0",
"serverless-step-functions-offline": "^1.0.1",
and noticed that function-level env vars aren't available via process.env
in the handler function..
convert:
handler: convert.default
name: ${self:service}-${self:provider.stage}-convert
environment:
foo: 'bar'
..when invoking this handler as part of a state machine:
stepFunctions:
stateMachines:
ProcessUpload:
definition:
StartAt: convert
States:
convert:
Type: Task
Resource: "arn:aws:lambda:#{AWS::Region}:#{AWS::AccountId}:function:${self:service}-${self:provider.stage}-convert"
End: true
via sls step-functions-offline -s ProcessUpload
โ but they are when using sls invoke local -f convert
.
Hi hackers, nice plugin!
Question: is it posible to use stepfunctions.startExecution
in a localdev
environment?
const params = {
name: "GenerateCourseWorkflow",
stateMachineArn: process.env.statemachine_arn,
input: `{ id: ${course.dataValues.id} }`
};
stepfunctions.startExecution(params, (err, data) => {
console.log(`Params: ${params}`);
if (err) {
console.log(`===> Error: ${err}`);
console.log(`===> Error Stack: ${err.stack}`);
} else {
console.log(`Data: ${data}`);
}
});
Thanks!
When passing data with callback it's working fine (the Next state is being triggered).
export const handler = (event, context, cb) => {
cb(null, {
data: result
});
};
But when I'm using async functions (promises) instead:
export const handler = async event => {
return {
data: result
};
};
It's not working, the process is shutting down. The Next state it's not being triggered at all.
Plugin depends on old variable resolver, which is scheduled to be removed with Serverless Framework v3.
To ensure compliancy this dependency should be removed
Report: https://snyk.io/test/github/vkkis93/serverless-step-functions-offline?targetFile=package.json
Resolution: lodash 4.17.11 -> 4.17.12
Absolut path for event file doesnt work.
Ex:
sls step-functions-offline --stateMachine=TournamentMachine --event=/Users/marcusataide/Documents/Workspace/proak-workflow/proak-workflow/api/tournament/status/registering/event.json
But if you provide a path like this, works:
sls step-functions-offline --stateMachine=TournamentMachine --event=./api/tournament/status/registering/event.json
When I try to execute the step functions in offline, i got the error 'Function "Hello" does not presented in serverless.yml'
Below is the console output
Serverless: Preparing....
Serverless: Trying to find state "hellostepfunc" in serverless.yml
Serverless: Building StepWorkFlow
Serverless: Function "Hello" does not presented in serverless.yml
My serverless.yml is below
package:
exclude:
- node_modules/**
provider:
name: aws
runtime: nodejs8.10
stage: dev
region: ap-southeast-2
functions:
hello:
handler: hello.hello
bye:
handler: bye.bye
stepFunctions:
stateMachines:
hellostepfunc:
events:
- http:
path: hello
method: POST
definition:
Comment: "An example app using step-functions and api gateway"
StartAt: Hello
States:
Hello:
Type: Task
Resource: "arn:aws:lambda:#{AWS::Region}:#{AWS::AccountId}:function:${self:service}-${opt:stage}-hello"
Next: Bye
Bye:
Type: Task
Resource: "arn:aws:lambda:#{AWS::Region}:#{AWS::AccountId}:function:${self:service}-${opt:stage}-bye"
End: true
custom:
stepFunctionsOffline:
stepOne: hello
stepTwo: bye
plugins:
- serverless-step-functions
- serverless-pseudo-parameters
- serverless-offline
- serverless-step-functions-offline```
Hi,
if you use serverless.yaml
instead of serverless.yml
, this plugin won't work and will throw exception stating file not present
Hi,
When I split the code into multiple files, this plugin cant recognize them.
How to re-produce:
just take the stepFunctionsOffline to its own file, and reference them in serverless.yml like this:
stepFunctionsOffline: ${file(step-functions-offline.yml)}
How to fix:
don't use the contructor to get data as you do in this code:
this.functions = this.serverless.service.functions;
this.variables = this.serverless.service.custom.stepFunctionsOffline;
in this line.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.