Skip to content
This repository has been archived by the owner on Jul 28, 2023. It is now read-only.

Debug the Lambda function on AWS-SAM-LOCAL in Eclipse #92

Closed
addictedanshul opened this issue Dec 22, 2017 · 7 comments
Closed

Debug the Lambda function on AWS-SAM-LOCAL in Eclipse #92

addictedanshul opened this issue Dec 22, 2017 · 7 comments
Labels
bug We can reproduce the issue and confirmed it is a bug.

Comments

@addictedanshul
Copy link

Followed below steps:

  1. In the Eclipse Project Explorer, open HelloWorldHandler.java.
  2. Right-click in your Eclipse code window, choose Debug As, and then choose AWS SAM Local.
  3. For this example, leave the Project and Template as they are.
  4. Choose Lambda Function in the Run as field.
  5. Choose GetHelloWorld in the Function identifier field.
  6. For this example, we will provide an Amazon S3 event. Choose Generate next to the Event input box.
  7. Choose a region that has your Amazon S3 bucket.
  8. Enter a valid Amazon S3 bucket name.
  9. Enter a valid Amazon S3 object key, and then choose OK.
  10. On the Save As page, select the current project and enter a name for the event file. In this example, we used s3-event.json.
  11. Choose OK to save the event file and get back to the main dialog box.
  12. Leave the advanced settings as they are. See Advanced Settings to learn more about those fields.
  13. Choose Apply, and then choose Debug.
  14. Had also created docker connection in Eclipse Docker Explorer, which connects successfully

Eclipse lambda project not able to connect to docker image on my windows system
lambci/lambda:java8

Got below error in eclipse:

[AWS Toolkit] Running command: C:\Users\XXXXXXX\AppData\Roaming\npm\sam.exe local invoke ExampleFunction --debug-port 5858 --event D:\Projects\lambda-worker\src\test\resources\s3-event.put.json --profile default --template D:\Projects\lambda-worker.serverless.template
[AWS Toolkit] Waiting for SAM Local to attach the port 5858
2017/12/22 15:35:56 Successfully parsed D:\Projects\lambda-worker.serverless.template
2017/12/22 15:35:56 Running AWS SAM projects locally requires Docker. Have you got it installed?
2017/12/22 15:35:56 error during connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/_ping: open //./pipe/docker_engine: The system cannot find the file specified. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running.
[AWS Toolkit] SAM Local invocation done.

@zhangzhx
Copy link
Contributor

Hey @addictedanshul, thanks for reaching out to us. From the error message, it seems that you are not running your docker. SAM Local asks for docker to be running as a daemon. See here for detail.

Let me know if you still have this problem after trying running docker in the backend.

@addictedanshul
Copy link
Author

Hi zhangzhx

My docker daemon is definitely running as I ran it using Docker Quickstart Terminal.

But when I ran "docker ps" from cmd, it gave same error
"//./pipe/docker_engine: The system cannot find the file specified"

I resolved it by running command as below
@for /f "tokens=*" %i IN ('docker-machine env') DO @%i

and "docker ps" started giving output
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

Now eclipse is also giving same error but I don't know how to resolve it there (screenshot attached).
In eclipse docker explore, I created a connection to my docker daemon as well and it says ping successful.

aws_error

@zhangzhx
Copy link
Contributor

Hey @addictedanshul, I found a similar issue reported here aws/aws-sam-cli#158. I'm wondering what docker version and SAM version you are using? Can you upgrade to the latest version and try again?

@addictedanshul
Copy link
Author

addictedanshul commented Dec 27, 2017

Hi @zhangzhx I am using latest SAM 0.2.4 and
Docker version 17.10.0-ce, build f4ffd25

The issue which you referenced aws/aws-sam-cli#158 has two issues reported.
The second one ('invalid bind mount spec') has been marked resolved in 0.2.3. And I am not getting this one.

I am getting first one "open //./pipe/docker_engine: The system cannot find the file specified".
But I am able to resolve the error when running from cmd, using below command
@for /f "tokens=*" %i IN ('docker-machine env') DO @%i

It is in Eclipse where I am still getting the same error (screenshot attached in previous post.)

@kpjofficial
Copy link

kpjofficial commented Jan 23, 2019

Hi, I am facing the same error in MacOS. I can see the command with docker ps but Eclipse still gives the error.

Logs attached.

image

@zhangzhx zhangzhx added the bug We can reproduce the issue and confirmed it is a bug. label Feb 18, 2019
@phijacobs
Copy link
Contributor

@kpjofficial When I received the exception above, the console output in Eclipse contained the attached sam error:

error.txt

To resolve it, I created a ~/.aws/config file with the desired region.

@zhangzhx it seems like issue #86 has been addressed but requires the ~/.aws/config file now.

@phijacobs phijacobs mentioned this issue Mar 26, 2019
@phijacobs
Copy link
Contributor

@kpjofficial it looks like this exception happens even when the ~/.aws/config file exists, so I created a pull request.

zhangzhx added a commit that referenced this issue Apr 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug We can reproduce the issue and confirmed it is a bug.
Projects
None yet
Development

No branches or pull requests

4 participants