how would one run aws lambda locally (java) for testing

我的梦境 提交于 2019-12-23 06:48:11

问题


How would one run aws lambda locally (java) for testing.

I was able to find some information for node, but not for java.


回答1:


AFAIK there is no magic to actually triggering the lambda function locally. Take a look at: http://docs.aws.amazon.com/lambda/latest/dg/java-programming-model-req-resp.html
and
http://docs.aws.amazon.com/lambda/latest/dg/java-gs.html

Depending what your lambda code does you need to build the input and (possibly the context) and pass them into the function writing your own small test wrapper.

Unless you are doing this for unit testing it does not make sense to go through the trouble though. If you are doing this for testing you will probably need to mock out other external AWS services that your lambda might use.




回答2:


For those searching to test locally with Python, we created a tool for that:

https://github.com/sportarchive/aws-lambda-python-local

It lets you run, test, and deploy your functions to Lambda using a Makefile. Pretty handy.

cheers nico




回答3:


SAM Local - http://docs.aws.amazon.com/lambda/latest/dg/test-sam-local.html and docker-lambda - https://github.com/lambci/docker-lambda have worked well for APIs that need only javaee and project sources. I am still trying to figure out how to set to set the classpath to include the gradle dependencies.




回答4:


You can use AWS Toolkit for Eclipse if you want to perform local testing for Amazon Lambda functions, and build serverless applications in Amazon.

But since Aug 11, 2017, Amazon provides the AWS SAM Local, a CLI tool that allows us to locally test and debug our AWS Lambda functions. SAM Local supports Lambda functions written in Node.js, Java, and Python.

Please vote for implementing Intellij IDEA support for Amazon Lambda here:

  • https://youtrack.jetbrains.com/issue/IDEA-180070



回答5:


There are a number of projects going on to run the entire AWS stack locally.

Java I believe the main option is Localstack

If you're on Javascript you can go Serverless




回答6:


I have been using these docker images https://github.com/lambci/docker-lambda



来源:https://stackoverflow.com/questions/33259952/how-would-one-run-aws-lambda-locally-java-for-testing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!