diff --git a/docs/runtimes/fpm-runtime.mdx b/docs/runtimes/fpm-runtime.mdx index b0b6aea7f..2f868aa6c 100644 --- a/docs/runtimes/fpm-runtime.mdx +++ b/docs/runtimes/fpm-runtime.mdx @@ -70,6 +70,8 @@ Here is an example to retrieve it: $lambdaContext = json_decode($_SERVER['LAMBDA_INVOCATION_CONTEXT'], true); ``` +The request ID of the invocation is also available directly in `$_SERVER['LAMBDA_REQUEST_ID']`, like in [the other runtimes](./runtimes-details.mdx#environment-variables). + ### Request context API Gateway integrations can add information to the HTTP request via the *request context*. diff --git a/src/FpmRuntime/FpmHandler.php b/src/FpmRuntime/FpmHandler.php index 6931b9caa..c1b0049fd 100644 --- a/src/FpmRuntime/FpmHandler.php +++ b/src/FpmRuntime/FpmHandler.php @@ -253,6 +253,8 @@ private function eventToFastCgiRequest(HttpRequestEvent $event, Context $context $request->setCustomVar('PATH_INFO', $event->getPath()); $request->setCustomVar('QUERY_STRING', $event->getQueryString()); $request->setCustomVar('LAMBDA_INVOCATION_CONTEXT', json_encode($context, JSON_THROW_ON_ERROR)); + // Same variable as in the other runtimes, see LambdaRuntime::processNextEvent() + $request->setCustomVar('LAMBDA_REQUEST_ID', $context->getAwsRequestId()); $request->setCustomVar('LAMBDA_REQUEST_CONTEXT', json_encode($event->getRequestContext(), JSON_THROW_ON_ERROR)); $contentType = $event->getContentType(); diff --git a/tests/FpmRuntime/FpmHandlerTest.php b/tests/FpmRuntime/FpmHandlerTest.php index bbfbea5c9..840e8ba0a 100644 --- a/tests/FpmRuntime/FpmHandlerTest.php +++ b/tests/FpmRuntime/FpmHandlerTest.php @@ -1325,6 +1325,7 @@ private function assertCommonServerVariables(array $response, array $expectedGlo 'SCRIPT_FILENAME' => __DIR__ . '/fixtures/request.php', 'GATEWAY_INTERFACE' => 'FastCGI/1.0', 'FCGI_ROLE' => 'RESPONDER', + 'LAMBDA_REQUEST_ID' => 'abc', ]; // Allow to override some keys