serverless-step-functions
serverless-step-functions copied to clipboard
Bug - scripts added to the serverless.yml are running twice
This is a Bug Report
Description
There are 2 issues after plugin version 1.4.0
-
use of ${self:} throws error ServerlessError: Trying to populate non string value into a string for variable ${self:}. Please make sure the value of the property is a string using ${self} works
-
serverless plugin (version 2.29.0) does the variables.populateService on start which runs the scripts from serverless.yml link: https://github.com/serverless/serverless/blob/f5b2b9be395c9c2d3de4c4f91f991276bc22dc33/lib/Serverless.js#L296
also the serverless-step-functions plugin (version 2.30.0) tries to populate the variables before setting up step functions link: https://github.com/serverless-operations/serverless-step-functions/blob/e0a391d531b2868f5b03fd8eeede3d9073735efa/lib/yamlParser.js#L26
because of this scripts are running twice, which is not expected.
this is a link to a PR after which these issues are coming https://github.com/serverless-operations/serverless-step-functions/pull/116
sharing a sample example to reproduce the issue
service: test-step-function
provider:
name: aws
onStart: ${file(./on_start.js):onStart}
frameworkVersion: '2'
stepFunctions:
stateMachines:
hellostepfunc1:
definition:
StartAt: HelloWorld1
States:
HelloWorld1:
Type: Task
Next: ToSqsQueue
Resource: "arn:aws:lambda:#{AWS::Region}:#{AWS::AccountId}:function:hello-world"
End: true
ToSqsQueue:
Type: Task
Resource: arn:aws:states:::sqs:sendMessage
Parameters:
QueueUrl: https://sqs.#{AWS::Region}.amazonaws.com/#{AWS::AccountId}/hello-world-queue
MessageBody.$: "$"
MessageGroupId: "1"
End: true
plugins:
- serverless-step-functions
custom:
servicename: ${self:} # first issue, ${self:} doesn't work after version 1.4.0, works for ${self}, error is ServerlessError: Trying to populate non string value into a string for variable ${self:}. Please make sure the value of the property is a string
add_resources: ${file(./resources.js)}
export:
statics:
- service: ${self:custom.servicename}
Additional Data
sample project to reproduce the issues: step_functions_example.zip