Terraform - 如何启用 API 网关执行日志记录?
Terraform - How to enable API Gateway execution logging?
问题
如何使用 Terraform 设置 API 网关级执行日志记录?还不支持吗?
背景
API 网关阶段编辑器具有 execution logging configurations. However, it seems there is no parameter to set them in aws_api_gateway_stage although it has access loggging 配置参数。
想知道是否还有其他资源可以使用,或者只是这些参数尚未实现。
你必须使用 aws_api_gateway_method_settings
...
resource "aws_api_gateway_method_settings" "YOUR_settings" {
rest_api_id = "${aws_api_gateway_rest_api.YOUR.id}"
stage_name = "${aws_api_gateway_stage.YOUR.stage_name}"
method_path = "*/*"
settings {
logging_level = "INFO"
data_trace_enabled = true
metrics_enabled = true
}
}
CloudWatch 日志组应如下所示
API-Gateway-Execution-Logs_{YOU_API_ID}/{YOU_STAGENAME}
...也许您必须设置所有 IAM 角色内容...
您可以在整个“阶段”级别设置这些日志记录级别,或者覆盖阶段级别并在方法级别定义它,如本例所示:(注意此处的“method_path”值)
resource "aws_api_gateway_method_settings" "s" {
rest_api_id = aws_api_gateway_rest_api.test.id
stage_name = aws_api_gateway_stage.test.stage_name
method_path =
"${aws_api_gateway_resource.test.path_part}/${aws_api_gateway_method.test.http_method}"
settings {
metrics_enabled = true
logging_level = "INFO"
}
}
在此处找到:
另见此处:
问题
如何使用 Terraform 设置 API 网关级执行日志记录?还不支持吗?
背景
API 网关阶段编辑器具有 execution logging configurations. However, it seems there is no parameter to set them in aws_api_gateway_stage although it has access loggging 配置参数。
想知道是否还有其他资源可以使用,或者只是这些参数尚未实现。
你必须使用 aws_api_gateway_method_settings
...
resource "aws_api_gateway_method_settings" "YOUR_settings" {
rest_api_id = "${aws_api_gateway_rest_api.YOUR.id}"
stage_name = "${aws_api_gateway_stage.YOUR.stage_name}"
method_path = "*/*"
settings {
logging_level = "INFO"
data_trace_enabled = true
metrics_enabled = true
}
}
CloudWatch 日志组应如下所示
API-Gateway-Execution-Logs_{YOU_API_ID}/{YOU_STAGENAME}
...也许您必须设置所有 IAM 角色内容...
您可以在整个“阶段”级别设置这些日志记录级别,或者覆盖阶段级别并在方法级别定义它,如本例所示:(注意此处的“method_path”值)
resource "aws_api_gateway_method_settings" "s" {
rest_api_id = aws_api_gateway_rest_api.test.id
stage_name = aws_api_gateway_stage.test.stage_name
method_path =
"${aws_api_gateway_resource.test.path_part}/${aws_api_gateway_method.test.http_method}"
settings {
metrics_enabled = true
logging_level = "INFO"
}
}
在此处找到:
另见此处: