How to enable execution logs for a http api gateway

Viewed 1233

I am using serverless framework https://www.serverless.com/

I have created a http api gateway - https://www.serverless.com/framework/docs/providers/aws/events/http-api/

And enabled logging like so

provider:
  name: aws
  runtime: nodejs12.x
  logs:
    httpApi: true

Im looking for execution logs but im unable to see it in cloudwatch log groups.

From this documentation - https://www.serverless.com/framework/docs/providers/aws/guide/serverless.yml/ it suggests execution logs are enabled by default when its a restApi: true but there is no mention of execution logs when you have a httpApi

2 Answers

Execution logs are not available with HTTP APIs because they only support proxy integrations with Lambda and HTTP endpoint. So ideally there would be no transformation in request/response going in/out of API Gateway. Whatever request parameters client sends can be seen at the integration - so enable logging on Lambda/HTTP side to see the request details.

If you want to use access logs to troubleshoot errors for HTTP API, there is a new context variable $context.integrationErrorMessage that will give the error message in a similar format we see in execution logs for the traditional REST API.

Related