I want to have one lambda function tat can be triggered by multiple sources
- When I upload an xml document in S3 bucket
- Via APIGateway request
I tried the following
public class MultiTriggerLambda implements RequestHandler<Object, Object> {
private final AmazonS3 s3Client = AmazonS3ClientBuilder.defaultClient();
@Override
public Object handleRequest(Object event, Context context) {
if (event instanceof S3Event) {
// S3 Trigger
return handleS3Event((S3Event) event, context);
} else if (event instanceof APIGatewayProxyRequestEvent) {
// API Gateway Trigger
return handleApiGatewayRequest((APIGatewayProxyRequestEvent) event, context);
} else {
// Unknown Event
return "Unknown event source";
}
}
The issue is the event coming from S3 is not an instance of S3Event but its a map.
Can I somehow configure my lambda or S3 event so that I get the event as of type S3Event and APIGatewayProxyRequestEvent and not Map?
Thanks
Recognized by AWS
1