From 9133979318c19bd797f9509b7f14e19231c7fd7f Mon Sep 17 00:00:00 2001 From: Jacob McSwain Date: Mon, 17 Jul 2023 17:33:16 -0500 Subject: [PATCH] docs: api_gateway_method_settings: Document Cloudwatch Logging Examples --- .../api_gateway_method_settings.html.markdown | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/website/docs/r/api_gateway_method_settings.html.markdown b/website/docs/r/api_gateway_method_settings.html.markdown index e7d33182fcf5..32737d42ba2a 100644 --- a/website/docs/r/api_gateway_method_settings.html.markdown +++ b/website/docs/r/api_gateway_method_settings.html.markdown @@ -14,8 +14,12 @@ Manages API Gateway Stage Method Settings. For example, CloudWatch logging and m ## Example Usage +### End-to-end + An end-to-end example of a REST API configured with OpenAPI can be found in the [`/examples/api-gateway-rest-api-openapi` directory within the GitHub repository](https://github.com/hashicorp/terraform-provider-aws/tree/main/examples/api-gateway-rest-api-openapi). +### Basic Usage + ```terraform resource "aws_api_gateway_rest_api" "example" { body = jsonencode({ @@ -82,6 +86,72 @@ resource "aws_api_gateway_method_settings" "path_specific" { } ``` +### CloudWatch Logging and Tracing + +The AWS Console API Gateway Editor displays multiple options for CloudWatch Logs that don't directly map to the options in the AWS API and Terraform. These examples show the `settings` blocks that are equivalent to the options the AWS Console gives for CloudWatch Logs. + +#### Off + +```terraform +resource "aws_api_gateway_method_settings" "path_specific" { + rest_api_id = aws_api_gateway_rest_api.example.id + stage_name = aws_api_gateway_stage.example.stage_name + method_path = "path1/GET" + + settings { + logging_level = "OFF" + } +} +``` + +#### Errors Only + +```terraform +resource "aws_api_gateway_method_settings" "path_specific" { + rest_api_id = aws_api_gateway_rest_api.example.id + stage_name = aws_api_gateway_stage.example.stage_name + method_path = "path1/GET" + + settings { + logging_level = "ERROR" + metrics_enabled = true + data_trace_enabled = false + } +} +``` + +#### Errors and Info Logs + +```terraform +resource "aws_api_gateway_method_settings" "path_specific" { + rest_api_id = aws_api_gateway_rest_api.example.id + stage_name = aws_api_gateway_stage.example.stage_name + method_path = "path1/GET" + + settings { + logging_level = "INFO" + metrics_enabled = true + data_trace_enabled = false + } +} +``` + +#### Full Request and Response Logs + +```terraform +resource "aws_api_gateway_method_settings" "path_specific" { + rest_api_id = aws_api_gateway_rest_api.example.id + stage_name = aws_api_gateway_stage.example.stage_name + method_path = "path1/GET" + + settings { + logging_level = "INFO" + metrics_enabled = true + data_trace_enabled = true + } +} +``` + ## Argument Reference The following arguments are supported: