API Gateway V2 API stage has access logging enabled
API Gateway v2 stages have access logging configured to capture request details and deliver them to a logging destination (e.g., CloudWatch Logs or Firehose). The evaluation looks for logging being enabled at each API stage.
Risk
Without access logs, API calls lack traceability, making it hard to spot credential misuse, route abuse, or anomalous traffic.
This reduces confidentiality and integrity through undetected data access or manipulation, and impacts availability by slowing incident response.
Run this check with Prowler
Run in Prowler Cloudprowler aws --checks apigatewayv2_api_access_logging_enabledRecommendation
Enable stage-level access logging to a centralized destination and use structured formats. Apply appropriate retention and restrict log access per least privilege. Integrate logs with monitoring and alerts to detect anomalies, and complement with defense in depth controls.
Remediation
CLI
aws apigatewayv2 update-stage --api-id <API_ID> --stage-name <STAGE_NAME> --access-log-settings DestinationArn=<LOG_GROUP_ARN>,Format='{"requestId":"$context.requestId"}'Terraform
# Terraform: Enable access logging on API Gateway V2 stage
resource "aws_apigatewayv2_stage" "<example_resource_name>" {
api_id = "<example_resource_id>"
name = "<example_resource_name>"
access_log_settings { # Critical: enables access logging for the stage
destination_arn = "<example_log_group_arn>"
format = "{\"requestId\":\"$context.requestId\"}"
}
}NativeIaC
# CloudFormation: Enable access logging on API Gateway V2 stage
Resources:
<example_resource_name>:
Type: AWS::ApiGatewayV2::Stage
Properties:
ApiId: <example_resource_id>
StageName: <example_resource_name>
AccessLogSettings: # Critical: enables access logging for the stage
DestinationArn: <example_log_group_arn> # CloudWatch Logs log group ARN
Format: '{"requestId":"$context.requestId"}' # Minimal required formatOther
Check Code
from prowler.lib.check.models import Check, Check_Report_AWS
from prowler.providers.aws.services.apigatewayv2.apigatewayv2_client import (
apigatewayv2_client,
)
class apigatewayv2_api_access_logging_enabled(Check):
def execute(self):
findings = []
for api in apigatewayv2_client.apis:
report = Check_Report_AWS(metadata=self.metadata(), resource=api)
for stage in api.stages:
if stage.logging:
report.status = "PASS"
report.status_extended = f"API Gateway V2 {api.name} ID {api.id} in stage {stage.name} has access logging enabled."
report.resource_id = f"{api.name}-{stage.name}"
else:
report.status = "FAIL"
report.status_extended = f"API Gateway V2 {api.name} ID {api.id} in stage {stage.name} has access logging disabled."
report.resource_id = f"{api.name}-{stage.name}"
findings.append(report)
return findingsReferences
- https://docs.aws.amazon.com/apigateway/latest/developerguide/security-monitoring.html
- https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-logging.html
- https://support.icompaas.com/support/solutions/articles/62000229562-ensure-api-gateway-v2-has-access-logging-enabled
- https://www.trendmicro.com/trendaivisiononecloudriskmanagement/knowledge-base/aws/APIGateway/api-gateway-stage-access-logging.html