Skip to content

Cloud9 - How to pass an arg used in a dynamodb query to a GET Lambda function using launch.json

1

Normally I'd pass this info in a SAM local invoke > sam local invoke getAllTracksFunction -e events/event-get-all-tracks.json in an event. But I want to use the Cloud9 debugger, hence the need to use the launch.json, right? Here's the launch.json: { "type": "aws-sam", "request": "direct-invoke", "name": "API lambda:tracks", "invokeTarget": { "target": "api", "templatePath": "/home/ec2-user/environment/lambda-nodejs16/template.yaml", "logicalId": "getTracksFunction" }, "api": { "path": "/tracks", "httpMethod": "get" }, "lambda": { "runtime": "nodejs16.x", } } I haven't found this question ever being asked here, so I'm assuming that it's obvious, but not to me. A link to the documentation on this would be great! Thanks for any help.

asked 2 years ago348 views
2 Answers
2
Accepted Answer

Hi,

These pages have additional information about configuring launch.json :

  1. https://docs.aws.amazon.com/cloud9/latest/user-guide/sam-debug-config-ref.html
  2. https://docs.aws.amazon.com/cloud9/latest/user-guide/serverless-apps-toolkit.html#sam-run-debug

In the lambda configuration properties, you can configure the payload option to reference your events/event-get-all-tracks.json file

Excerpt from Configuration options for debugging serverless applications

payload Provides two options for the event payload that you provide to your Lambda function as input.
"json": JSON-formatted key-value pairs that define the event payload.
"path": A path to the file that's used as the event payload.

AWS
answered 2 years ago
0

Thanks Edward S! I added >> "payload": { "pathParameters": { "conferenceId": "confz4444", "trackId": "trackz98281" } },

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.