Description
API Gateway v2 stage access logs record the fields you select for each request. Including the request ID and response status helps you find a failed call.
Potential impact
Metrics may reveal a rise in errors. Without request records, it is harder to identify the individual calls.
Remediation
Set accessLogSettings on the stage. Supply the CloudWatch log group ARN and a format that includes $context.requestId. Configure delivery permissions and retention, and exclude fields that contain credentials or secrets. Send a test request and look it up by ID.
Examples
The excerpts reference an existing exampleApi and exampleLogGroup. The stage name and deployment settings are omitted.
Before
resources:
example:
type: aws:apigatewayv2:Stage
properties:
apiId: ${exampleApi.id}
After
resources:
example:
type: aws:apigatewayv2:Stage
properties:
apiId: ${exampleApi.id}
accessLogSettings:
destinationArn: ${exampleLogGroup.arn}
format: '{"requestId":"$context.requestId","status":"$context.status"}'
The stage is configured to send the request ID and response status as JSON to the group selected by destinationArn.