Every invocation of an AWS Lambda function is associated with a request ID. Searching the CloudWatch logs with the request ID is the quickest way to find the logs of a given invocation.
To get the request ID when using the JavaScript AWS SDK, you can access the $response
property of the response:
const AWS = require('aws-sdk');
const lambda = new AWS.Lambda();
const response = await lambda.invoke({
...
}).promise();
const requestId = response.$response.requestId;
The entire response object from the HTTP request is available to you via the $response
object. Also, the $response
object is available across almost all API calls, not just lambda.invoke().promise()
.
If you ever want to track down the results of a single invocation among many, consider logging the response ID.
Top comments (0)