Skip to content

feat: support Arguments for Lambda when query language is JSONata - #645

Merged
zirkelc merged 3 commits into
serverless-operations:masterfrom
edvaldoszy:master
May 3, 2025
Merged

feat: support Arguments for Lambda when query language is JSONata#645
zirkelc merged 3 commits into
serverless-operations:masterfrom
edvaldoszy:master

Conversation

@edvaldoszy

@edvaldoszy edvaldoszy commented Mar 28, 2025

Copy link
Copy Markdown
Contributor

When using JSONata as the query language, AWS creates the step definition with Arguments instead of Parameters.

Example:

Step name:
  Type: Task
  Resource: arn:aws:states:::lambda:invoke
  Output: '{% $states.result.Payload %}'
- Parameters:
+ Arguments:
    FunctionName: <function ARN goes here>
    Payload: '{% $states.input %}'

That leads to the error below

Deploying "project-name" to stage "staging" (us-east-1)
Layer sharp is already uploaded.
✖ Stack staging-project-name failed to deploy (7s)

✖ TypeError: Cannot read properties of undefined (reading 'FunctionName')
    at ServerlessStepFunctions.getLambdaPermissions (/home/edvaldo/project-name/node_modules/serverless-step-functions/lib/deploy/stepFunctions/compileIamRole.js:365:41)
    at /home/edvaldo/project-name/node_modules/serverless-step-functions/lib/deploy/stepFunctions/compileIamRole.js:775:47
    at arrayMap (/home/edvaldo/project-name/node_modules/lodash/lodash.js:653:23)
    at map (/home/edvaldo/project-name/node_modules/lodash/lodash.js:9622:14)
    at Function.flatMap (/home/edvaldo/project-name/node_modules/lodash/lodash.js:9325:26)
    at ServerlessStepFunctions.getIamPermissions (/home/edvaldo/project-name/node_modules/serverless-step-functions/lib/deploy/stepFunctions/compileIamRole.js:714:12)
    at /home/edvaldo/project-name/node_modules/serverless-step-functions/lib/deploy/stepFunctions/compileIamRole.js:873:56
    at Array.forEach (<anonymous>)
    at ServerlessStepFunctions.compileIamRole (/home/edvaldo/project-name/node_modules/serverless-step-functions/lib/deploy/stepFunctions/compileIamRole.js:861:32)
    at ServerlessStepFunctions.tryCatcher (/home/edvaldo/project-name/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/edvaldo/project-name/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/home/edvaldo/project-name/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromiseCtx (/home/edvaldo/project-name/node_modules/bluebird/js/release/promise.js:641:10)
    at _drainQueueStep (/home/edvaldo/project-name/node_modules/bluebird/js/release/async.js:97:12)
    at _drainQueue (/home/edvaldo/project-name/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/home/edvaldo/project-name/node_modules/bluebird/js/release/async.js:102:5)

Serverless Framework Version: 4.9.1
Serverless Step Function Version: ^3.22.0
Operating System: Windows with WSL

@edvaldoszy edvaldoszy changed the title Resolve lambda function name from Arguments when using JSONata fix: correctly resolve lambda function name from Arguments instead of Parameters property when using JSONata Mar 28, 2025
@edvaldoszy edvaldoszy changed the title fix: correctly resolve lambda function name from Arguments instead of Parameters property when using JSONata fix: correctly resolve lambda function name from Arguments instead of Parameters property when the query language is JSONata Mar 28, 2025
@edvaldoszy
edvaldoszy marked this pull request as ready for review March 28, 2025 17:25
@edvaldoszy
edvaldoszy force-pushed the master branch 2 times, most recently from 2eee05a to 73cc27b Compare March 28, 2025 17:52
@edvaldoszy edvaldoszy closed this Mar 28, 2025
@edvaldoszy edvaldoszy reopened this Mar 31, 2025
@edvaldoszy edvaldoszy changed the title fix: correctly resolve lambda function name from Arguments instead of Parameters property when the query language is JSONata feat: support Arguments for Lambda when query language is JSONata Mar 31, 2025
Comment thread lib/deploy/stepFunctions/compileIamRole.test.js Outdated
@PaulBanusIAD

Copy link
Copy Markdown

Hello, any idea when this change will be released ?

@zirkelc

zirkelc commented Apr 17, 2025

Copy link
Copy Markdown
Collaborator

@PaulBanusIAD that is up to @horike37

Comment thread lib/deploy/stepFunctions/compileIamRole.js Outdated
@zirkelc

zirkelc commented May 1, 2025

Copy link
Copy Markdown
Collaborator

Hey @edvaldoszy I found one more mistake, please correct this then we can get this merged

@zirkelc
zirkelc self-requested a review May 1, 2025 05:00
@zirkelc

zirkelc commented May 3, 2025

Copy link
Copy Markdown
Collaborator

I extended the test should support variable FunctionName to also include JSONata and noticed there is an issue with the resolved IAM template. Since JSONata uses the key FunctionName without .$ suffix, I had to re-order how this is checked. Now it first checks for JSONPath and JSONata strings and then goes to check for intrinsic functions

@zirkelc
zirkelc merged commit c7e7eaf into serverless-operations:master May 3, 2025
@mikewongblinx

Copy link
Copy Markdown

HI just wonder any plan to release it PR as new version?

@zirkelc

zirkelc commented May 8, 2025

Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 3.23.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

olivierto pushed a commit to olivierto/serverless-step-functions that referenced this pull request Nov 14, 2025
…erverless-operations#645)

* fix: correctly resolve lambda function name from Arguments or Parameters

* test: use itParam to test both JSONPath and JSONata scenarios

* fix: lambda permissions for jsonata

---------

Co-authored-by: zirkelc <chris.zirkel@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants