Hi All,
I have a lambda that needs to call another lambda in AWS. We'll call these lambda1 and lambda2.
Lambda1 is called by the UI through the API Gateway and has an authenticator. The header information that comes into lambda1 has the principalId, etc.
Lambda1 now needs to call lambda2. I want to pass it the same header information that I received from the call to lambda1.
Currently in development, I am using the AWS aws-java-sdk-lambda jar and do something like:
InvokeRequest request = new InvokeRequest()
.withFunctionName("lambda2")
.withPayload(mapper.writeValueAsString(input));
AWSLambda awsLambda = AWSLambdaClientBuilder.standard()
.withCredentials(new ProfileCredentialsProvider())
.withRegion(Regions.US_EAST_2).build();
invokeResult = awsLambda.invoke(request);
Unfortunately, this library cannot be compiled into a native image. I get a whole bunch of errors that starts with:
Error: Detected an instance of Random/SplittableRandom class in the image heap. Instances created during image generation have cached seed values and don't behave as expected. To see how this object got instantiated use --trace-object-instantiation=java.util.Random. The object was probably created by a class initializer and is reachable from a static field. You can request class initialization at image runtime by using the option --initialize-at-run-time=<class-name>. Or you can write your own initialization methods and call them explicitly from your main entry point.
Trace: Object was reached by
reading field com.amazonaws.retry.PredefinedBackoffStrategies$EqualJitterBackoffStrategy.random of
constant com.amazonaws.retry.PredefinedBackoffStrategies$EqualJitterBackoffStrategy@60fb8363 reached by
reading field com.amazonaws.retry.PredefinedBackoffStrategies$SDKDefaultBackoffStrategy.equalJitterBackoffStrategy of
constant com.amazonaws.retry.PredefinedBackoffStrategies$SDKDefaultBackoffStrategy@164bb23c reached by
scanning method com.amazonaws.retry.PredefinedRetryPolicies.getDefaultBackoffStrategy(PredefinedRetryPolicies.java:110)
This usually means I can't use the library. Is there a way to get this library to compile?
If not, any thoughts on how I can directly invoke an AWS lambda function without using the API Gateway? I looked at the Funky documentation, but not sure if that will give me what I am looking for. I would like the entry point into Lambda2 to be the same regardless of whether the lambda is being executed through the API gateway or privately by another lambda not using the API gateway. It looks like Funky wants me to export a function on the target.
Thanks,
Tom