I would like to enable execution logging on an aws_apigatewayv2_api
resource. I can simply click the below checkbox to do so.
Since I know it is possible via AWS GUI, what is the terraform equivalent?
I already have logging enabled on each individual integration lambda, but this checkbox stays unchecked.
CodePudding user response:
This setting is on the stage itself i.e. aws_apigatewayv2_stage
under the default_route_settings
argument.
To replicate the UI:
Enable CloudWatch Logs & Log level - these 2 options are combined in Terraform under
logging_level
. Logging is disabled by default aslogging_level
is set toOFF
. To enable logging, you will need to simply specify thelogging_level
to any other supported value other thanOFF
, which has the effect of turning logging on & setting the level at the same time.Log full message data - this is in Terraform under
detailed_metrics_enabled
.
This results in the below config:
resource "aws_apigatewayv2_stage" "example" {
api_id = aws_apigatewayv2_api.example.id
name = "example-stage"
default_route_settings {
logging_level = "INFO"
detailed_metrics_enabled = true
}
}