I currently have an S3 bucket configured to enable EventBridge events and I have an EventBridge rule that triggers a step function that in turn triggers a lambda.
I want to map the input I'm getting in the lambda to one of the event classes in the AWS Java SDK (com.amazonaws:aws-lambda-java-events) but I'm not having much luck.
Here is the signature of my lambda in my Java code:
public class DeviceAssociationLambda implements RequestHandler<S3Event, OutputObject> {
@Override
public OutputObject handleRequest(S3Event input, Context context) {
When my step function invokes this lambda, it's sending a payload that looks like this:
{
"version": "0",
"id": "e31fcb40-aa08-11ec-b909-0242ac120002",
"detail-type": "Object Created",
"source": "aws.s3",
"account": "123456789098",
"time": "2022-03-22T17:07:44Z",
"region": "eu-central-1",
"resources": [
"arn:aws:s3:::my-test-bucket"
],
"detail": {
"version": "0",
"bucket": {
"name": "my-test-bucket"
},
"object": {
"key": "foo/bar.json",
"size": 685,
"etag": "af87c63487cc2ff6323e67ddd234f44",
"sequencer": "00827F2232287F2343"
},
"request-id": "LK63256WW7E66YCC4",
"requester": "123456789098",
"source-ip-address": "123.123.123.123",
"reason": "PutObject"
}
}
After trying to debug this, I see that the S3Event parameter into my lambda is always empty. This is probably because it is expecting the input JSON in some different format (probably this: https://docs.aws.amazon.com/AmazonS3/latest/userguide/notification-content-structure.html)
So, my question is, is there any standard event object in the Java SDK that would handle the JSON I'm getting from EventBridge? I can, of course, manipulate the JSON a bit in the step function, such as limiting the lambda input to the "detail" block if that helps.
Or will I just have to create my own input class that maps to this JSON structure that I'm getting as input?