p.magalhaes
p.magalhaes

Reputation: 8374

Amazon SES - Lambda Function in Java

I am trying to execute a Lambda function triggered by an email.

I could not find the Java class that represents an SES Email Event. (https://github.com/aws/aws-lambda-java-libs/tree/master/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events)

Does anyone knows where can i find it?

Upvotes: 2

Views: 2428

Answers (1)

Gonfva
Gonfva

Reputation: 1468

I don't think you can find it anywhere. From

https://aws.amazon.com/blogs/aws/aws-lambda-update-run-java-code-in-response-to-events/

We provide you with two libraries specific to Lambda: aws-lambda-java-core with interfaces for Lambda function handlers and the context object, and aws-lambda-java-events containing type definitions for AWS event sources (Amazon Simple Storage Service (S3), Amazon Simple Notification Service (SNS), Amazon DynamoDB, Amazon Kinesis, and Amazon Cognito)

But in that page, you can find an alternative approach.

If you do not want to use POJOs or if Lambda’s serialization model does not meet your needs, you can use the Stream model. This is a bit lower-level:

public void lambdaHandler(InputStream input, OutputStream output, Context context) throws IOException;

EDIT: I was also in need to use an SES Event inside a Lambda function, so I created my own class. It turns out the event has an object with name "Records" (with capital R). Capitalised fields are not OK in POJOs. And you cannot use annotations. In fact in this gist, you can find the Event, and two examples: WorkingCheckUser works, but NonWorkingCheckUser doesn't.

Upvotes: 4

Related Questions