Skip to content

Commit

Permalink
r/aws_apigatewayv2_stage: Change 'route_setting.logging_level' to com…
Browse files Browse the repository at this point in the history
…puted to address different defaults for WebSocket vs. HTTP.
  • Loading branch information
ewbankkit committed Jul 21, 2020
1 parent e735282 commit 659a511
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 22 deletions.
18 changes: 2 additions & 16 deletions aws/resource_aws_apigatewayv2_stage.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,12 @@ func resourceAwsApiGatewayV2Stage() *schema.Resource {
"logging_level": {
Type: schema.TypeString,
Optional: true,
Default: apigatewayv2.LoggingLevelOff,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{
apigatewayv2.LoggingLevelError,
apigatewayv2.LoggingLevelInfo,
apigatewayv2.LoggingLevelOff,
}, false),
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
// Not set for HTTP APIs.
if d.Id() != "" && old == "" && new == apigatewayv2.LoggingLevelOff {
return true
}
return false
},
},
"throttling_burst_limit": {
Type: schema.TypeInt,
Expand Down Expand Up @@ -158,19 +151,12 @@ func resourceAwsApiGatewayV2Stage() *schema.Resource {
"logging_level": {
Type: schema.TypeString,
Optional: true,
Default: apigatewayv2.LoggingLevelOff,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{
apigatewayv2.LoggingLevelError,
apigatewayv2.LoggingLevelInfo,
apigatewayv2.LoggingLevelOff,
}, false),
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
// Not set for HTTP APIs.
if d.Id() != "" && old == "" && new == apigatewayv2.LoggingLevelOff {
return true
}
return false
},
},
"route_key": {
Type: schema.TypeString,
Expand Down
5 changes: 1 addition & 4 deletions aws/resource_aws_apigatewayv2_stage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ func TestAccAWSAPIGatewayV2Stage_DefaultRouteSettingsWebSocket(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "default_route_settings.#", "1"),
resource.TestCheckResourceAttr(resourceName, "default_route_settings.0.data_trace_enabled", "false"),
resource.TestCheckResourceAttr(resourceName, "default_route_settings.0.detailed_metrics_enabled", "false"),
resource.TestCheckResourceAttr(resourceName, "default_route_settings.0.logging_level", "OFF"),
resource.TestCheckResourceAttr(resourceName, "default_route_settings.0.logging_level", "INFO"), // No drift detection if not configured
resource.TestCheckResourceAttr(resourceName, "default_route_settings.0.throttling_burst_limit", "0"),
resource.TestCheckResourceAttr(resourceName, "default_route_settings.0.throttling_rate_limit", "0"),
resource.TestCheckResourceAttr(resourceName, "deployment_id", ""),
Expand Down Expand Up @@ -612,7 +612,6 @@ func TestAccAWSAPIGatewayV2Stage_RouteSettingsWebSocket(t *testing.T) {
tfawsresource.TestCheckTypeSetElemNestedAttrs(resourceName, "route_settings.*", map[string]string{
"data_trace_enabled": "false",
"detailed_metrics_enabled": "false",
"logging_level": "OFF",
"route_key": "$default",
"throttling_burst_limit": "1111",
"throttling_rate_limit": "9999",
Expand All @@ -628,7 +627,6 @@ func TestAccAWSAPIGatewayV2Stage_RouteSettingsWebSocket(t *testing.T) {
tfawsresource.TestCheckTypeSetElemNestedAttrs(resourceName, "route_settings.*", map[string]string{
"data_trace_enabled": "false",
"detailed_metrics_enabled": "false",
"logging_level": "OFF",
"route_key": "$disconnect",
"throttling_burst_limit": "0",
"throttling_rate_limit": "0",
Expand Down Expand Up @@ -733,7 +731,6 @@ func TestAccAWSAPIGatewayV2Stage_RouteSettingsHttp(t *testing.T) {
tfawsresource.TestCheckTypeSetElemNestedAttrs(resourceName, "route_settings.*", map[string]string{
"data_trace_enabled": "false",
"detailed_metrics_enabled": "false",
"logging_level": "OFF",
"route_key": "$default",
"throttling_burst_limit": "1111",
"throttling_rate_limit": "9999",
Expand Down
4 changes: 2 additions & 2 deletions website/docs/r/apigatewayv2_stage.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ The `default_route_settings` object supports the following:
Defaults to `false`. Supported only for WebSocket APIs.
* `detailed_metrics_enabled` - (Optional) Whether detailed metrics are enabled for the default route. Defaults to `false`.
* `logging_level` - (Optional) The logging level for the default route. Affects the log entries pushed to Amazon CloudWatch Logs.
Valid values: `ERROR`, `INFO`, `OFF`. Defaults to `OFF`. Supported only for WebSocket APIs.
Valid values: `ERROR`, `INFO`, `OFF`. Defaults to `OFF`. Supported only for WebSocket APIs. Terraform will only perform drift detection of its value when present in a configuration.
* `throttling_burst_limit` - (Optional) The throttling burst limit for the default route.
* `throttling_rate_limit` - (Optional) The throttling rate limit for the default route.

Expand All @@ -62,7 +62,7 @@ The `route_settings` object supports the following:
Defaults to `false`. Supported only for WebSocket APIs.
* `detailed_metrics_enabled` - (Optional) Whether detailed metrics are enabled for the route. Defaults to `false`.
* `logging_level` - (Optional) The logging level for the route. Affects the log entries pushed to Amazon CloudWatch Logs.
Valid values: `ERROR`, `INFO`, `OFF`. Defaults to `OFF`. Supported only for WebSocket APIs.
Valid values: `ERROR`, `INFO`, `OFF`. Defaults to `OFF`. Supported only for WebSocket APIs. Terraform will only perform drift detection of its value when present in a configuration.
* `throttling_burst_limit` - (Optional) The throttling burst limit for the route.
* `throttling_rate_limit` - (Optional) The throttling rate limit for the route.

Expand Down

0 comments on commit 659a511

Please sign in to comment.