Reputation: 11
I am trying to debug my \event
endpoint using AWS SAM in VSCode and I'm having issues with two of the configurations I've tried. The Direct Invoke Configuration I've used successfully in a different project, but in my current project it returns this error even though template.yaml and package.json are both in the EventsApi project directory.
{
"type": "aws-sam",
"request": "direct-invoke",
"name": "Direct Invoke Config",
"invokeTarget": {
"target": "api",
"templatePath": "template.yaml",
"logicalId": "AddEventFunction"
},
"api": {
"path": "/event",
"httpMethod": "post",
"payload": {
}
}
}
which produces this error
[ERROR]: SamLaunchRequestError: Failed to run launch configuration
-> Error: Cannot find package.json for: C:/aws/EventsApi/template.yaml
And the second configuration, which I attach in the SAM CLI to my AddEventFunction lambda in debug mode, then the debugger catches exceptions but won't hit any endpoints with this configuration. Please note that stopOnEntry
is unable to be added to the attach configuration for some reason.
{
"name": "Attach to SAM CLI Config",
"type": "node",
"request": "attach",
"address": "localhost",
"port": 5858,
"localRoot": "${workspaceRoot}/src/handlers",
"remoteRoot": "",
"sourceMaps": true,
},
I expect the first configuration to find package.json just fine, and the second configuration to hit a breakpoint.
Upvotes: 1
Views: 2890
Reputation: 11
You need to be sure for your template.yaml to have the CodeUri: path/here param, so it can find the package.json in your folder, i was having the same problem, and have adding this solved it, hope this helps!
AWSTemplateFormatVersion: 2010-09-09
Description: A simple project using SAM
Transform: AWS::Serverless-2016-10-31
Resources:
OrchestratorSqs:
Type: AWS::Serverless::Function
Properties:
CodeUri: ./ # Same level as the package.json file
Handler: app.runner
...
Upvotes: 1
Reputation: 1
The same problem. It turns out to start debugging only when invokeTarget.target is "code".
Upvotes: 0