amazon-web-servicesdockeraws-lambdaaws-toolkit

Running AWS Lambda with Java in IntelliJ locally - No response from invoke container for Function (Problem with Docker?)


I get this error when running my AWS Lambda No response from invoke container for Function. I would expect it to return the "hello world" String that I defined as output:

the error

I also tried it with this simplier Lambda function, but I get the same error:

public class App implements RequestHandler<String, String> {

    public String handleRequest(final String input, final Context context) {
            return "H";
    }
    
}

I started Docker locally to run this Lambda with the Docker Quickstart Terminal:

my docker quickstart terminal

Do I maybe need to do anything else in Docker?

This is how I created the new AWS Lambda project with the IntelliJ Plugin AWS Toolkit:

  1. File -> New Project:

new project

and selected following settings:

settings

  1. The created project had a lot of errors, (Cannot resolve symbol 'String' etc.). I was able to resolve the errors by deleting the .idea folder, then click on File -> Invalidate Caches and Restart:

errors

Then the project loads properly, but I don't get that Lambda symbol next to my App class:

missing Lambda symbol

  1. So I go to pom.xml, right click and then Import as Maven project. This works and I see the Lambda symbol now:

with Lambda Symbol

But I get a new Error in the AppTest class, and when I try to run it, it says can't find the app handler. 5. I resolved this by changing APIGatewayProxyRequestEvent in the RequestHandler to 'Object':

resolved error

enter image description here


Solution

  • I have never tried to build and execute a Lambda function in the manner that you described. Personally, I use IntelliJ and the Java Lambda runtime API to build a Lambda function and then use Maven to package it up and deploy it by using the AWS Management Console at:

    https://console.aws.amazon.com/lambda/home

    You can test it from the console and see the output in Cloudwatch logs. This works without issues. For more information about how to package a Lambda function using Maven and deploy it using the AWS Management Console, see this AWS Tutorial:

    https://github.com/awsdocs/aws-doc-sdk-examples/tree/master/javav2/usecases/creating_workflows_stepfunctions

    If you built your example Lambda function in the manner specified in this tutorial, you will have no issues:

    public class App implements RequestHandler<String, String> {
    
        public String handleRequest(final String input, final Context context) {
                return "H";
        }
        
    }