I have a few lambdas working together through SNS. One lambda receives a request and sends data to SNS. Another lambda is subscribed to SNS. It was easy to do in JavaScript as the incoming message just a JS object. Now I am rewriting the lambda to Java. I am looking for the type to use in the handler.
Here's what the lambda looks like. SNSMessage is the placeholder for the type.
public class ArchiveRequestHandler implements RequestHandler<SNSMessage?, Void> {
@Override public Void handleRequest(SNSMessage? input, Context context) {
// do something with the message
return null;
}
}
This is how an example message looks like:
{
"Records": [
{
"EventVersion": "1.0",
"EventSubscriptionArn": "arn:aws:sns:EXAMPLE",
"EventSource": "aws:sns",
"Sns": {
"SignatureVersion": "1",
"Timestamp": "1970-01-01T00:00:00.000Z",
"Signature": "EXAMPLE",
"SigningCertUrl": "EXAMPLE",
"MessageId": "1234567-ee98-5cb9-9903-4c221d41eb5e",
"Message": "Hello from SNS!",
"MessageAttributes": {
"Test": {
"Type": "String",
"Value": "TestString"
},
"TestBinary": {
"Type": "Binary",
"Value": "TestBinary"
}
},
"Type": "Notification",
"UnsubscribeUrl": "EXAMPLE",
"TopicArn": "arn:aws:sns:EXAMPLE",
"Subject": "TestInvoke"
}
}
]
}
Now I am sure I can create my own type to parse this, but I was hoping there is a more standard way of doing this. However, I haven't found anything in the lambda nor SNS SDK dependencies that looks like this object.