Search code examples
javaamazon-web-servicesexceptionaws-lambdaaws-java-sdk

AWS Lambda invoke exception "No LambdaFunction annotation for method invoke"


I am invoking a Lambda function from my Java code that is running inside Spark process.

The invocation is failing with following exception:

23:22:50,043 ERROR com.gravty.batch.process.BitProcessImpl - com.amazonaws.services.lambda.invoke.LambdaSerializationException: No LambdaFunction annotation for method invoke

Does anyone has any idea about this error?


Solution

  • Resolved it by using interface with @LambdaFunction annotation.

    my lambda interface:

    public interface MyLambdaService {
        @LambdaFunction
        ApiGatewayProxyResponse execute(ApiGatewayRequest bit);
    }
    

    this is how I created the lambda client:

    MyLambdaService lambdaService = LambdaInvokerFactory.builder().lambdaClient(AWSLambdaClientBuilder.defaultClient())
                        .lambdaFunctionNameResolver((method, annotation, config) -> "ENV_SPECIFIC_FUNCTION_NAME").build(MyLambdaService.class);