Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You can obtain access to lambda.runtime.Context by injecting an instance of io.quarkus.amazon.lambda.runtime.LambdaContext into your bean. Here's an example:

import io.quarkus.amazon.lambda.runtime.LambdaContext;
import javax.inject.Inject;

public class MyBean {

    @Inject
    LambdaContext lambdaContext;

    public void doSomething() {
        // you can now access the lambda runtime context
        String awsRequestId = lambdaContext.getAwsRequestId();
        System.out.println("AWS Request ID: " + awsRequestId);
    }

}

In the above example, we inject an instance of LambdaContext and use it to retrieve the AWS request ID. Note that this will only work if your bean is executed in the context of an AWS Lambda function. If you need a more generic solution, you should consider abstracting the LambdaContext interface and injecting that instead.