Skip to content

[Bug]: aws_api_gateway_method_settings - reading API Gateway Method Settings empty results #37959

Open
@jkoermer-eqxm

Description

@jkoermer-eqxm

Terraform Core Version

1.8.5

AWS Provider Version

5.53.0

Affected Resource(s)

aws_api_gateway_method_settings
aws_api_gateway_rest_api

Expected Behavior

The terraform plan shows the following:

  # module.api_gateway.aws_api_gateway_method_settings.endpoint_throttle will be created
  + resource "aws_api_gateway_method_settings" "endpoint_throttle" {
      + id          = (known after apply)
      + method_path = "path/{proxy+}/GET"
      + rest_api_id = "xxxxxxxxxx"
      + stage_name  = "develop"

      + settings {
          + cache_data_encrypted                       = (known after apply)
          + cache_ttl_in_seconds                       = (known after apply)
          + caching_enabled                            = (known after apply)
          + data_trace_enabled                         = (known after apply)
          + logging_level                              = (known after apply)
          + metrics_enabled                            = true
          + require_authorization_for_cache_control    = (known after apply)
          + throttling_burst_limit                     = 80
          + throttling_rate_limit                      = 200
          + unauthorized_cache_control_header_strategy = (known after apply)
        }
    }

We should see the settings applied to that path in the associated stage for the api gateway.

Actual Behavior

�[31m╷�[0m�[0m
�[31m│�[0m �[0m�[1m�[31mError: �[0m�[0m�[1mreading API Gateway Method Settings (<gatewayid>-<env>-path/{proxy+}/GET): empty result�[0m
�[31m│�[0m �[0m
�[31m│�[0m �[0m�[0m  with module.api_gateway.aws_api_gateway_method_settings.endpoint_throttle["path_get"],
�[31m│�[0m �[0m  on ../../modules/aws/api_gateway/main.tf line 76, in resource "aws_api_gateway_method_settings" "endpoint_throttle":
�[31m│�[0m �[0m  76: resource "aws_api_gateway_method_settings" "endpoint_throttle" �[4m{�[0m�[0m
�[31m│�[0m �[0m
�[31m╵�[0m�[0m

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

data "aws_api_gateway_rest_api" "api_gateway" {
  name = "${var.environment}-api"
}

resource "aws_api_gateway_method_settings" "endpoint_throttle" {
  rest_api_id = data.aws_api_gateway_rest_api.api_gateway.id
  stage_name  = var.environment
  method_path = "gateway/path/{proxy+}/GET"
  settings {
    metrics_enabled        = true
    throttling_burst_limit = 80
    throttling_rate_limit  = 200
   }
}

Steps to Reproduce

terraform plan shows:

  # module.api_gateway.aws_api_gateway_method_settings.endpoint_throttle will be created
  + resource "aws_api_gateway_method_settings" "endpoint_throttle" {
      + id          = (known after apply)
      + method_path = "gateway/path/{proxy+}/GET"
      + rest_api_id = "xxxxxxxxxx"
      + stage_name  = "develop"

      + settings {
          + cache_data_encrypted                       = (known after apply)
          + cache_ttl_in_seconds                       = (known after apply)
          + caching_enabled                            = (known after apply)
          + data_trace_enabled                         = (known after apply)
          + logging_level                              = (known after apply)
          + metrics_enabled                            = true
          + require_authorization_for_cache_control    = (known after apply)
          + throttling_burst_limit                     = 80
          + throttling_rate_limit                      = 200
          + unauthorized_cache_control_header_strategy = (known after apply)
        }
    }

apply fails with the following error:

Error: reading API Gateway Method Settings (xxxxxxxx-develop-pgateway/path/{proxy+}/GET): empty result with module.api_gateway.aws_api_gateway_method_settings.endpoint_throttle,
on ../../modules/aws/api_gateway/main.tf line 76, in resource "aws_api_gateway_method_settings" "endpoint_throttle":
76: resource "aws_api_gateway_method_settings" "endpoint_throttle"

Debug Output

This is part of a much larger workspace, from what I can tell this is the specifics about the method settings:

2024-06-13T18:06:03.712Z [TRACE] maybeTainted: module.api_gateway.aws_api_gateway_method_settings.endpoint_throttle["path_get"] encountered an error during creation, so it is now marked as tainted
2024-06-13T18:06:03.712Z [TRACE] terraform.contextPlugins: Schema for provider "registry.terraform.io/hashicorp/aws" is in the global cache
2024-06-13T18:06:03.712Z [TRACE] NodeAbstractResouceInstance.writeResourceInstanceState to workingState for module.api_gateway.aws_api_gateway_method_settings.endpoint_throttle["path_get"]
2024-06-13T18:06:03.712Z [TRACE] NodeAbstractResouceInstance.writeResourceInstanceState: writing state object for module.api_gateway.aws_api_gateway_method_settings.endpoint_throttle["path_get"]
2024-06-13T18:06:03.712Z [TRACE] evalApplyProvisioners: module.api_gateway.aws_api_gateway_method_settings.endpoint_throttle["path_get"] is tainted, so skipping provisioning
2024-06-13T18:06:03.712Z [TRACE] maybeTainted: module.api_gateway.aws_api_gateway_method_settings.endpoint_throttle["path_get"] was already tainted, so nothing to do
2024-06-13T18:06:03.712Z [TRACE] terraform.contextPlugins: Schema for provider "registry.terraform.io/hashicorp/aws" is in the global cache
2024-06-13T18:06:03.712Z [TRACE] NodeAbstractResouceInstance.writeResourceInstanceState to workingState for module.api_gateway.aws_api_gateway_method_settings.endpoint_throttle["path_get"]
2024-06-13T18:06:03.712Z [TRACE] NodeAbstractResouceInstance.writeResourceInstanceState: writing state object for module.api_gateway.aws_api_gateway_method_settings.endpoint_throttle["path_get"]
2024-06-13T18:06:03.715Z [DEBUG] State storage *cloud.State declined to persist a state snapshot
2024-06-13T18:06:03.715Z [ERROR] vertex "module.api_gateway.aws_api_gateway_method_settings.endpoint_throttle[\"path_get\"]" error: reading API Gateway Method Settings (<gatewayid>-<env>-path{proxy+}/GET): empty result
2024-06-13T18:06:03.715Z [TRACE] vertex "module.api_gateway.aws_api_gateway_method_settings.endpoint_throttle[\"path_get\"]": visit complete, with errors
2024-06-13T18:06:03.715Z [TRACE] dag/walk: upstream of "module.api_gateway (close)" errored, so skipping']

�[31m╷�[0m�[0m
�[31m│�[0m �[0m�[1m�[31mError: �[0m�[0m�[1mreading API Gateway Method Settings (<gatewayid>-<env>-path/{proxy+}/GET): empty result�[0m
�[31m│�[0m �[0m
�[31m│�[0m �[0m�[0m  with module.api_gateway.aws_api_gateway_method_settings.endpoint_throttle["path_get"],
�[31m│�[0m �[0m  on ../../modules/aws/api_gateway/main.tf line 76, in resource "aws_api_gateway_method_settings" "endpoint_throttle":
�[31m│�[0m �[0m  76: resource "aws_api_gateway_method_settings" "endpoint_throttle" �[4m{�[0m�[0m
�[31m│�[0m �[0m
�[31m╵�[0m�[0m
2024-06-13T18:06:06.115Z [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2024-06-13T18:06:06.130Z [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/hashicorp/aws/5.53.0/linux_amd64/terraform-provider-aws_v5.53.0_x5 pid=29256
2024-06-13T18:06:06.130Z [DEBUG] provider: plugin exited
Operation failed: failed running terraform apply (exit 1)�

Panic Output

No response

Important Factoids

This was working with the following configurations:
Terraform 1.6.3 / AWS Provider 5.39.1
Terraform 1.8.5 / AWS Provider 5.39.1

This failed with:
Terraform 1.8.5 / AWS Provider 5.46.0
Terraform 1.8.5 / AWS Provider 5.53.0

Although this does work, in earlier versions of terraform, the resource is almost always shown as "tainted" and is always replaced.

References

No response

Would you like to implement a fix?

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAddresses a defect in current functionality.service/apigatewayIssues and PRs that pertain to the apigateway service.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions