GithubHelp home page GithubHelp logo

vkkis93 / serverless-step-functions-offline Goto Github PK

View Code? Open in Web Editor NEW
78.0 78.0 40.0 593 KB

Emulate step functions locally when developing your Serverless project

License: MIT License

JavaScript 100.00%
aws aws-lambda lambda serverless serverless-step-functions-offline sls state-machine step-functions

serverless-step-functions-offline's People

Contributors

ajagnanan avatar gd-aichi avatar j0k3r avatar sergioramos avatar vkkis93 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

serverless-step-functions-offline's Issues

Assumes JavaScript

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?

Compatibility with serverless-webpack

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)

Error with step functions running using webpack

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",

Shortcut `-s` results in `opt:stage` variable set

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?

Connection to port 443 refused

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

Possibility to add new community maintainers

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!

What

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.

How we might want to address this.

@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!

  • Ryan

Published version on NPM doesn't seems to be the same as the one in the repo

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.

Choice variables can only be one level deep.

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:

const isConditionTrue = choice.checkFunction(result[choice.variable], choice.compareWithValue);

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.

Offline HTTP Event Support

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}

Function "SaveSlotDetails" does not presented in serverless.yml

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

Function 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"

When using Parallel task type, failed validation when using Fn:GettAtt for lambda arn for either of the branches

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

Function-level env vars not loaded

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.

Question: is it posible to use `stepfunctions.startExecution` in a `localdev` environment?

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}`);
          }
        });

image

Thanks!

Promise support (Node.js8)

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.

Absolut path for Event file

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

Function "Hello" does not presented in serverless.yml

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```


[BUG] variables, functions, etc are not available if splitted into files

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.