Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

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

like image 792
Joyce Avatar asked Sep 08 '25 18:09

Joyce


2 Answers

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.

like image 119
Mircea Avatar answered Sep 10 '25 07:09

Mircea


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
like image 29
MarcG Avatar answered Sep 10 '25 08:09

MarcG