Attempting to debug a go lambda with sam cli start-api/invoke makes the lambda code fail to start
-----------------------
Generating application:
-----------------------
Name: test113sam
Runtime: go1.x
Dependency Manager: mod
Application Template: hello-world
Output Directory: .
Next steps can be found in the README file at ./test113sam/README.md
sam buildsam local invoke it works fine:$ sam local invoke
Invoking hello-world (go1.x)
Skip pulling image and use local one: amazon/aws-sam-cli-emulation-image-go1.x:rapid-1.13.2.
Mounting /private/tmp/test113sam/.aws-sam/build/HelloWorldFunction as /var/task:ro,delegated inside runtime container
START RequestId: d1f12116-37df-4127-9b64-36aacdccea8c Version: $LATEST
END RequestId: d1f12116-37df-4127-9b64-36aacdccea8c
REPORT RequestId: d1f12116-37df-4127-9b64-36aacdccea8c Init Duration: 1.57 ms Duration: 785.02 ms Billed Duration: 800 ms Memory Size: 128 MB Max Memory Used: 128 MB
{"statusCode":200,"headers":null,"multiValueHeaders":null,"body":"Hello, 72.21.198.67\n"}
Now, try invoking with Devle debugger args:
sam local invoke --debug-args -delveAPI=2 --debugger-path /Users/werlla/IdeaProjects/go1sam/ --debug-port 59394 --debug
2020-12-07 13:10:50,211 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2020-12-07 13:10:50,418 | local invoke command is called
2020-12-07 13:10:50,427 | No Parameters detected in the template
2020-12-07 13:10:50,454 | 2 resources found in the template
2020-12-07 13:10:50,455 | Found Serverless function with name='HelloWorldFunction' and CodeUri='HelloWorldFunction'
2020-12-07 13:10:50,464 | Found one Lambda function with name 'HelloWorldFunction'
2020-12-07 13:10:50,464 | Invoking hello-world (go1.x)
2020-12-07 13:10:50,464 | Environment variables overrides data is standard format
2020-12-07 13:10:50,464 | Loading AWS credentials from session with profile 'None'
2020-12-07 13:10:51,929 | Resolving code path. Cwd=/private/tmp/test113sam/.aws-sam/build, CodeUri=HelloWorldFunction
2020-12-07 13:10:51,929 | Resolved absolute path to code is /private/tmp/test113sam/.aws-sam/build/HelloWorldFunction
2020-12-07 13:10:51,930 | Code /private/tmp/test113sam/.aws-sam/build/HelloWorldFunction is not a zip/jar file
2020-12-07 13:10:53,185 | Failed to download image with name amazon/aws-sam-cli-emulation-image-go1.x:debug-1.13.2
2020-12-07 13:10:53,185 | Failed to download a new amazon/aws-sam-cli-emulation-image-go1.x:debug-1.13.2 image. Invoking with the already downloaded image.
2020-12-07 13:10:53,186 | Mounting /private/tmp/test113sam/.aws-sam/build/HelloWorldFunction as /var/task:ro,delegated inside runtime container
2020-12-07 13:10:53,859 | Setting up SIGTERM interrupt handler
2020/12/07 21:10:53 Error starting mock server: fork/exec /var/rapid/init: no such file or directory
2020-12-07 13:10:54,710 | No response from invoke container for HelloWorldFunction
2020-12-07 13:10:54,711 | Sending Telemetry: {'metrics': [{'commandRun': {'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam local invoke', 'duration': 4498, 'exitReason': 'success', 'exitCode': 0, 'requestId': 'fd63fac1-9b23-4de9-a4ab-e6b76e979b13', 'installationId': '8e36c82e-d3f0-45b7-9e48-1e6f0ad535a6', 'sessionId': '10201463-def2-41d3-97ea-e2c5b3ee5e6f', 'executionEnvironment': 'CLI', 'pyversion': '3.8.6', 'samcliVersion': '1.13.2'}}]}
2020-12-07 13:10:54,880 | Telemetry response: 200
2020/12/07 21:10:53 Error starting mock server: fork/exec /var/rapid/init: no such file or directory
And it does not start.
sam local invoke --debug-args "-delveAPI=2" --debugger-path /Users/werlla/IdeaProjects/go1sam/ --debug-port 59394 --debug
Quoting debug args results in the same output, and single quoting debug args leads to some more strange output without it running
sam local invoke --debug-args '-delveAPI=2' --debugger-path /Users/werlla/IdeaProjects/go1sam/ --debug-port 59394 --debug
2020-12-07 13:15:41,148 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2020-12-07 13:15:41,541 | local invoke command is called
2020-12-07 13:15:41,548 | No Parameters detected in the template
2020-12-07 13:15:41,589 | 2 resources found in the template
2020-12-07 13:15:41,589 | Found Serverless function with name='HelloWorldFunction' and CodeUri='HelloWorldFunction'
2020-12-07 13:15:41,608 | Found one Lambda function with name 'HelloWorldFunction'
2020-12-07 13:15:41,608 | Invoking hello-world (go1.x)
2020-12-07 13:15:41,608 | Environment variables overrides data is standard format
2020-12-07 13:15:41,609 | Loading AWS credentials from session with profile 'None'
2020-12-07 13:15:43,363 | Resolving code path. Cwd=/private/tmp/test113sam/.aws-sam/build, CodeUri=HelloWorldFunction
2020-12-07 13:15:43,363 | Resolved absolute path to code is /private/tmp/test113sam/.aws-sam/build/HelloWorldFunction
2020-12-07 13:15:43,363 | Code /private/tmp/test113sam/.aws-sam/build/HelloWorldFunction is not a zip/jar file
2020-12-07 13:15:44,558 | Failed to download image with name amazon/aws-sam-cli-emulation-image-go1.x:debug-1.13.2
2020-12-07 13:15:44,558 | Failed to download a new amazon/aws-sam-cli-emulation-image-go1.x:debug-1.13.2 image. Invoking with the already downloaded image.
2020-12-07 13:15:44,558 | Mounting /private/tmp/test113sam/.aws-sam/build/HelloWorldFunction as /var/task:ro,delegated inside runtime container
2020-12-07 13:15:45,629 | Setting up SIGTERM interrupt handler
2020-12-07 13:15:46,391 | No response from invoke container for HelloWorldFunction
2020-12-07 13:15:46,392 | Sending Telemetry: {'metrics': [{'commandRun': {'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam local invoke', 'duration': 5242, 'exitReason': 'success', 'exitCode': 0, 'requestId': '61ed57b7-4d4d-4081-b4b7-88af18a3ec2f', 'installationId': '8e36c82e-d3f0-45b7-9e48-1e6f0ad535a6', 'sessionId': 'a568cab5-a111-40a0-bfef-a9800ec0a2a4', 'executionEnvironment': 'CLI', 'pyversion': '3.8.6', 'samcliVersion': '1.13.2'}}]}
2020-12-07 13:15:46,521 | Telemetry response: 200
Running with the same arguments starts correctly with sam cli 1.12.0
sam --version: SAM CLI, version 1.13.2I'm also seeing this issue. I've set up the hello-world via sam init and pretty much did the same commands as above.
So that is exactly the usecase which is described in the docs on how to debug with go.
Downgrading to v1.12.0 worked for me(Had to reinstall via pip pip3 install --user 'aws-sam-cli==1.12.0')
Most helpful comment
I'm also seeing this issue. I've set up the hello-world via sam init and pretty much did the same commands as above.
So that is exactly the usecase which is described in the docs on how to debug with go.
Downgrading to v1.12.0 worked for me(Had to reinstall via pip
pip3 install --user 'aws-sam-cli==1.12.0')