Access logging should be configured for API Gateway V2 Stages¶
This control checks if AWS API Gateway V2 stages have access logging configured. This control fails if access log settings aren't defined.
How to fix¶
Attribute access_log_settings[0].destination_arn of aws_apigatewayv2_stage must be non-empty.
Implementation options¶
Choose the option that matches how you manage Terraform. All options satisfy this control.
Option 1: Compliance.tf module (recommended)¶
Use the compliance.tf registry module to get this control enforced by default. This control is mapped to the frameworks shown in the tabs above. To begin, see get started with compliance.tf.
module "apigateway_v2" {
source = "acscessentialeight.compliance.tf/terraform-aws-modules/apigateway-v2/aws"
version = ">=6.0.0"
name = "abc123"
protocol_type = "HTTP"
}
module "apigateway_v2" {
source = "pcidss.compliance.tf/terraform-aws-modules/apigateway-v2/aws"
version = ">=6.0.0"
name = "abc123"
protocol_type = "HTTP"
}
Option 2: Open source module (terraform-aws-modules)¶
If you use terraform-aws-modules/apigateway-v2/aws, configure the required module inputs to satisfy this control. You can later migrate to the compliance.tf module with minimal changes because it is compatible by design.
module "apigateway_v2" {
source = "terraform-aws-modules/apigateway-v2/aws"
version = ">=6.0.0"
name = "abc123"
protocol_type = "HTTP"
}
Option 3: Terraform AWS provider resources¶
If you manage resources directly, configure the relevant Terraform AWS provider resources to meet this control. See docs for the resources involved: aws_apigatewayv2_stage.
resource "aws_apigatewayv2_api" "this" {
name = "pofix-example-api"
protocol_type = "HTTP"
}
resource "aws_apigatewayv2_stage" "this" {
access_log_settings {
destination_arn = "arn:aws:logs:us-east-1:123456789012:log-group:example-log-group"
format = "$context.requestId"
}
api_id = "abc123"
name = "example"
}
Which option should I choose?
- Compliance.tf module (recommended): controls enforced by default and mapped to frameworks.
- Open source module (
terraform-aws-modules): compatible by design with compliance.tf. Same variable names for an easy, low-change migration path when you are ready. - Terraform AWS provider resources: manage Terraform resources directly.
Tool mappings¶
Use these identifiers to cross-reference this control across tools, reports, and evidence.
Compliance.tf (CTF) Control:
gatewayv2_stage_access_logging_enabledAWS Config Managed Rule:
API_GWV2_ACCESS_LOGS_ENABLEDCheckov Check:
CKV_AWS_76Powerpipe Control:
aws_compliance.control.gatewayv2_stage_access_logging_enabled