Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: api_gateway_method_settings: Document Cloudwatch Logging Examples #32554

Merged
merged 1 commit into from
Jul 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions website/docs/r/api_gateway_method_settings.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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:
Expand Down
Loading