Skip to content

Commit

Permalink
Merge pull request #32554 from USA-RedDragon/tf-support/docs/api_gate…
Browse files Browse the repository at this point in the history
…way_method_settings-cloudwatch-examples

docs: api_gateway_method_settings: Document Cloudwatch Logging Examples
  • Loading branch information
justinretzolk authored Jul 24, 2023
2 parents 2f0f9a6 + 9133979 commit 5ed6d78
Showing 1 changed file with 70 additions and 0 deletions.
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

This resource supports the following arguments:
Expand Down

0 comments on commit 5ed6d78

Please sign in to comment.