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

API Gateway v2 cutom route settings update fails #16094

Closed
vynaloze opened this issue Nov 9, 2020 · 4 comments · Fixed by #16133
Closed

API Gateway v2 cutom route settings update fails #16094

vynaloze opened this issue Nov 9, 2020 · 4 comments · Fixed by #16133
Assignees
Labels
bug Addresses a defect in current functionality. service/apigatewayv2 Issues and PRs that pertain to the apigatewayv2 service.
Milestone

Comments

@vynaloze
Copy link

vynaloze commented Nov 9, 2020

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform CLI and Terraform AWS Provider Version

Terraform v0.12.26

provider.aws v3.14.1

Affected Resource(s)

  • apigatewayv2_stage

Terraform Configuration Files

Minimal configuration to reproduce:

resource "aws_apigatewayv2_api" "this" {
  name          = "example"
  protocol_type = "HTTP"
}

resource "aws_apigatewayv2_stage" "test" {
  api_id = aws_apigatewayv2_api.this.id
  name   = "test"

  route_settings {
    route_key              = "GET ${local.path}"
    throttling_burst_limit = 1
  }

  depends_on = [
    aws_apigatewayv2_route.example,
  ]
}

resource "aws_apigatewayv2_route" "example" {
  api_id    = aws_apigatewayv2_api.this.id
  route_key = "GET ${local.path}"
  target    = "integrations/${aws_apigatewayv2_integration.example.id}"
}

resource "aws_apigatewayv2_integration" "example" {
  api_id             = aws_apigatewayv2_api.this.id
  integration_type   = "HTTP_PROXY"
  integration_method = "GET"
  integration_uri    = "https://google.com/"
}

Initial locals:

locals {
  path = "/first"
}

Updated locals:

locals {
  path = "/second"
}

Expected Behavior

Custom route settings in stage should be updated.

Actual Behavior

aws_apigatewayv2_stage.test: Modifying... [id=test]

Error: error updating API Gateway v2 stage (test): NotFoundException: Unable to find Route by key GET /first within the provided RouteSettings

In AWS, route is updated but not route settings. Any consequential applys fail until custom route setting is deleted manually.

I cannot use explicit dependency as I need it in opposite direction - see below

Steps to Reproduce

  1. terraform apply with provided configuration & initial locals
  2. terraform apply with updated locals

Important Factoids

Why this explicit dependency?

  depends_on = [
    aws_apigatewayv2_route.example,
  ]

Without this block, during fresh apply, provided configuration will fail with the same error (Error: error creating API Gateway v2 stage (test): NotFoundException: Unable to find Route by key GET /first within the provided RouteSettings) as stage can be created before route.

@ghost ghost added the service/apigatewayv2 Issues and PRs that pertain to the apigatewayv2 service. label Nov 9, 2020
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Nov 9, 2020
@ewbankkit ewbankkit self-assigned this Nov 9, 2020
@ewbankkit ewbankkit added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Nov 10, 2020
@ewbankkit
Copy link
Contributor

At the API level:

2020-11-10T14:48:51.280-0500 [DEBUG] plugin.terraform-provider-aws: 2020/11/10 14:48:51 [DEBUG] [aws-sdk-go] DEBUG: Request ApiGatewayV2/UpdateStage Details:
2020-11-10T14:48:51.280-0500 [DEBUG] plugin.terraform-provider-aws: ---[ REQUEST POST-SIGN ]-----------------------------
2020-11-10T14:48:51.280-0500 [DEBUG] plugin.terraform-provider-aws: PATCH /v2/apis/he2m0n1md2/stages/test HTTP/1.1
2020-11-10T14:48:51.280-0500 [DEBUG] plugin.terraform-provider-aws: Host: apigateway.us-west-2.amazonaws.com
2020-11-10T14:48:51.280-0500 [DEBUG] plugin.terraform-provider-aws: User-Agent: aws-sdk-go/1.35.23 (go1.14.6; linux; amd64) APN/1.0 HashiCorp/1.0 Terraform/0.12.26 (+https://www.terraform.io)
2020-11-10T14:48:51.280-0500 [DEBUG] plugin.terraform-provider-aws: Content-Length: 115
2020-11-10T14:48:51.280-0500 [DEBUG] plugin.terraform-provider-aws: Content-Type: application/json
2020-11-10T14:48:51.280-0500 [DEBUG] plugin.terraform-provider-aws: X-Amz-Date: 20201110T194851Z
2020-11-10T14:48:51.280-0500 [DEBUG] plugin.terraform-provider-aws: Accept-Encoding: gzip
2020-11-10T14:48:51.280-0500 [DEBUG] plugin.terraform-provider-aws: 
2020-11-10T14:48:51.280-0500 [DEBUG] plugin.terraform-provider-aws: {"routeSettings":{"GET /second":{"detailedMetricsEnabled":false,"throttlingBurstLimit":1,"throttlingRateLimit":0}}}
2020-11-10T14:48:51.280-0500 [DEBUG] plugin.terraform-provider-aws: -----------------------------------------------------
2020-11-10T14:48:51.688-0500 [DEBUG] plugin.terraform-provider-aws: 2020/11/10 14:48:51 [DEBUG] [aws-sdk-go] DEBUG: Response ApiGatewayV2/UpdateStage Details:
2020-11-10T14:48:51.688-0500 [DEBUG] plugin.terraform-provider-aws: ---[ RESPONSE ]--------------------------------------
2020-11-10T14:48:51.688-0500 [DEBUG] plugin.terraform-provider-aws: HTTP/1.1 404 Not Found
2020-11-10T14:48:51.688-0500 [DEBUG] plugin.terraform-provider-aws: Connection: close
2020-11-10T14:48:51.688-0500 [DEBUG] plugin.terraform-provider-aws: Content-Length: 92
2020-11-10T14:48:51.688-0500 [DEBUG] plugin.terraform-provider-aws: Content-Type: application/json
2020-11-10T14:48:51.688-0500 [DEBUG] plugin.terraform-provider-aws: Date: Tue, 10 Nov 2020 19:48:51 GMT
2020-11-10T14:48:51.688-0500 [DEBUG] plugin.terraform-provider-aws: X-Amz-Apigw-Id: Vzo5jEaTvHcFY1Q=
2020-11-10T14:48:51.688-0500 [DEBUG] plugin.terraform-provider-aws: X-Amzn-Errortype: NotFoundException
2020-11-10T14:48:51.688-0500 [DEBUG] plugin.terraform-provider-aws: X-Amzn-Requestid: ab7bb248-248b-410b-904e-022533cb9777
2020-11-10T14:48:51.688-0500 [DEBUG] plugin.terraform-provider-aws: X-Amzn-Trace-Id: Root=1-5faaeea3-7ede40a8389763f62e10dac3
2020-11-10T14:48:51.688-0500 [DEBUG] plugin.terraform-provider-aws: 
2020-11-10T14:48:51.689-0500 [DEBUG] plugin.terraform-provider-aws: 
2020-11-10T14:48:51.689-0500 [DEBUG] plugin.terraform-provider-aws: -----------------------------------------------------
2020-11-10T14:48:51.689-0500 [DEBUG] plugin.terraform-provider-aws: 2020/11/10 14:48:51 [DEBUG] [aws-sdk-go] {
2020-11-10T14:48:51.689-0500 [DEBUG] plugin.terraform-provider-aws:   "message" : "Unable to find Route by key GET /first within the provided RouteSettings"
2020-11-10T14:48:51.689-0500 [DEBUG] plugin.terraform-provider-aws: }
hin the provided RouteSettings
2020-11-10T14:48:51.689-0500 [DEBUG] plugin.terraform-provider-aws: {
2020-11-10T14:48:51.689-0500 [DEBUG] plugin.terraform-provider-aws:   RespMetadata: {
2020-11-10T14:48:51.689-0500 [DEBUG] plugin.terraform-provider-aws:     StatusCode: 404,
2020-11-10T14:48:51.689-0500 [DEBUG] plugin.terraform-provider-aws:     RequestID: "ab7bb248-248b-410b-904e-022533cb9777"
2020-11-10T14:48:51.689-0500 [DEBUG] plugin.terraform-provider-aws:   },
2020-11-10T14:48:51.689-0500 [DEBUG] plugin.terraform-provider-aws:   Message_: "Unable to find Route by key GET /first within the provided RouteSettings"
2020-11-10T14:48:51.689-0500 [DEBUG] plugin.terraform-provider-aws: }

@ewbankkit
Copy link
Contributor

ewbankkit commented Nov 10, 2020

It looks like a call to DeleteRouteSettings is required.

I can reproduce this with a new acceptance test:

$ make testacc TEST=./aws/ TESTARGS='-run=TestAccAWSAPIGatewayV2Stage_RouteSettingsHttp_WithRoute' ACCTEST_PARALLELISM=3
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 3 -run=TestAccAWSAPIGatewayV2Stage_RouteSettingsHttp_WithRoute -timeout 120m
=== RUN   TestAccAWSAPIGatewayV2Stage_RouteSettingsHttp_WithRoute
=== PAUSE TestAccAWSAPIGatewayV2Stage_RouteSettingsHttp_WithRoute
=== CONT  TestAccAWSAPIGatewayV2Stage_RouteSettingsHttp_WithRoute
    resource_aws_apigatewayv2_stage_test.go:849: Step 2/3 error: Error running apply: 2020/11/10 16:22:59 [DEBUG] Using modified User-Agent: Terraform/0.12.26 HashiCorp-terraform-exec/0.10.0
        
        Error: error updating API Gateway v2 stage (tf-acc-test-4420389067278823664): NotFoundException: Unable to find Route by key GET /first within the provided RouteSettings
        {
          RespMetadata: {
            StatusCode: 404,
            RequestID: "dc32f839-82c7-48a1-91cb-6cd68b2dd751"
          },
          Message_: "Unable to find Route by key GET /first within the provided RouteSettings"
        }
        
        
--- FAIL: TestAccAWSAPIGatewayV2Stage_RouteSettingsHttp_WithRoute (26.77s)
FAIL
FAIL	github.com/terraform-providers/terraform-provider-aws/aws	26.822s
FAIL
GNUmakefile:27: recipe for target 'testacc' failed
make: *** [testacc] Error 1

@ghost
Copy link

ghost commented Nov 18, 2020

This has been released in version 3.16.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

@ghost
Copy link

ghost commented Dec 19, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators Dec 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/apigatewayv2 Issues and PRs that pertain to the apigatewayv2 service.
Projects
None yet
3 participants