Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
152 views
in Technique[技术] by (71.8m points)

amazon web services - How to test lambda function against a localhost running application?

I am playing around with AWS and my main goal is to use a java lambda function to send a SOAP request to a SOAP UI mocking project.

At the moment, if I run the code in Eclipse I do manage to send a request successfully since I'm getting a SOAP response.

However, if I upload the code to the lambda funcion, I got a Connection refused error:

java.net.ConnectException: Connection refused (Connection refused)

Btw, my lambda function has no VPC configuration.

Anyone have any clue how can i test my lambda function code against my SOAP UI mock project?

Thank you so much in advance for any tip :)

question from:https://stackoverflow.com/questions/66051933/how-to-test-lambda-function-against-a-localhost-running-application

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Unless there is a hard requirement for you to run the lambda in AWS for testing purposes and @luk2302 already mentioned it is quite some effort to get the networking going in the right direction.

You can actually run your lambda locally and test with your UI.

There is a lambda docker image for java runtime published by AWS in gallery.ecr.aws

Package your code locally using the provided base image:

docker build -t <image name> .

To run your image locally:

docker run -p 9000:8080 <image name>

In a separate terminal, you can then locally invoke the function using cURL:

curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{"payload":"hello world!"}'

Another option would be to use LocalStack - A fully functional local AWS cloud stack


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...