I need access to the AWS Lambda's Context for my lambda function. I am using SpringBootRequestHandler to receive the request, which should call a class implementing the Function interface. Below is a code sample of the two classes:
public class A extends SpringBootRequestHandler<S3Event, String> {
@Override
public Object handleRequest(S3Event event, Context context) {
return super.handleRequest(event, context);
}
}
@Component("b")
public class B implements Function<S3Event, String> {
@Override
public String apply(S3Event string) {
// this is where I need the context
// this function should be called by handleRequest
}
}
I am using spring-cloud-starter-function-web to call the apply method in class B running locally, but this only allows directly calling class B, while class A's handleRequest is never executed. I have tried setting a static Context variable in class B and setting it at the start of handleRequest, but given that handleRequest will not execute locally, this does not work.
The three questions I have are:
- In an actual AWS environment, would the idea of setting a static variable work? As in, is the flow for the AWS function truly A::handleRequest -> B::apply?
- If #1 is no, then how might I pass the context to this apply function?
- If neither 1 or 2 is possible, is there a design that is that allows context to be passed?