Terraform-provider-aws: aws_apigatewayv2_stage failing to update when no changes

Created on 20 Apr 2020  ·  17Comments  ·  Source: hashicorp/terraform-provider-aws

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 Version

Terraform v0.12.24
+ provider.archive v1.3.0
+ provider.aws v2.58.0
+ provider.random v2.2.1
+ provider.template v2.1.2

Affected Resource(s)

aws_apigatewayv2_stage

Terraform Configuration Files

resource "aws_apigatewayv2_stage" "default_stage" {
  api_id      = aws_apigatewayv2_api.api.id
  name        = "$default"
  auto_deploy = true

  tags = {
    Project     = var.project_name
    Environment = var.env
  }
}

Expected Behavior

As no changes have been made to the configuration, terraform shouldn't be trying to update the stage with new values

Actual Behavior

Apply fails with:

Error: error updating API Gateway v2 stage ($default): BadRequestException: Execution logs are not supported on protocolType HTTP

The plan says:

default_route_settings {
        data_trace_enabled       = false
        detailed_metrics_enabled = false
      + logging_level            = "OFF"
        throttling_burst_limit   = 0
        throttling_rate_limit    = 0
}

(This is running terraform apply immediately after the resources is created without changing the config in between)

If make an aws cli call to get info on the current state of this stage, it shows DefaultRouteSettings as:

"DefaultRouteSettings": {
    "DetailedMetricsEnabled": false
},

with no other settings.

Steps to Reproduce

  1. Add stage to terraform config
  2. terraform apply (resource created fine)
  3. terraform apply (error shows up)

References

  • #9232 (resource introduced)
bug servicapigatewayv2

Most helpful comment

All 17 comments

Ran into the same problem. Thanks @ewbankkit !

Any chance this could get merged?

The fix for this has been merged and will release with version 2.65.0 of the Terraform AWS Provider, expected in this week's release.

This has been released in version 2.65.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!

I upgraded to aws provider "2.65.0" but I am still running into this issue when trying to use aws_apigatewayv2_stage resource. Is there also a configuration I need to make in the route_settings block to resolve this?

@reyescameron17 Do you get the same error as in the original comment?

Error: error updating API Gateway v2 stage ($default): BadRequestException: Execution logs are not supported on protocolType HTTP

That's correct.

 Successfully configured the backend "s3"! Terraform will automatically
16:31:13  use this backend unless the backend configuration changes.
16:31:14  
16:31:14  Initializing provider plugins...
16:31:14  - Checking for available provider plugins...
16:31:15  - Downloading plugin for provider "aws" (hashicorp/aws) 2.65.0...
16:31:17  - Downloading plugin for provider "archive" (hashicorp/archive) 1.3.0...

Running terraform version 0.12.25

16:31:32  
16:31:32  Error: error creating API Gateway v2 stage: BadRequestException: Execution logs are not supported on protocolType HTTP
16:31:32  

EDIT: Looking at my error, it isn't exactly the same. No $default designation.

@reyescameron17 Do you have logging_level set in your Terraform configuration?

I do not, and it should default to OFF right?

resource "aws_apigatewayv2_stage" "some_name" {
  api_id = aws_apigatewayv2_api.some_name.id
  name   = some_name

  auto_deploy   = true
  deployment_id = aws_apigatewayv2_deployment.some_name.id

  route_settings {
    route_key = aws_apigatewayv2_route.some_name.route_key
  }
}

@ewbankkit could it be that we're sending "OFF" as the default value in the method below and the AWS API validates the&apigatewayv2.RouteSettings{}, checking that setting provided can only be for WebSocket APIs?

func expandApiGatewayV2DefaultRouteSettings(vSettings []interface{}) *apigatewayv2.RouteSettings {
...
if vLoggingLevel, ok := mSettings["logging_level"].(string); ok && vLoggingLevel != "" {
        routeSettings.LoggingLevel = aws.String(vLoggingLevel)
    }

Edit: just realized the acceptance tests don't cover the case where route_settings are provided for HTTP like in @reyescameron17 's example (only WebSocket)

I am assuming I need route_settings to link the stage to the route? Or is that incorrect? I don't actually know that I NEED it.

@anGie44 @reyescameron17 You are correct that if you have a route_settings block then logging_level will be sent to the API with the default value of OFF. I'm 99% certain that we are testing this case for HTTP APIs and OFF was being accepted when the stage was created. I'll double check.

I can reproduce with a new test case:

$ make testacc TEST=./aws/ TESTARGS='-run=TestAccAWSAPIGatewayV2Stage_RouteSettingsHttp'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws/ -v -count 1 -parallel 20 -run=TestAccAWSAPIGatewayV2Stage_RouteSettingsHttp -timeout 120m
=== RUN   TestAccAWSAPIGatewayV2Stage_RouteSettingsHttp
=== PAUSE TestAccAWSAPIGatewayV2Stage_RouteSettingsHttp
=== CONT  TestAccAWSAPIGatewayV2Stage_RouteSettingsHttp
--- FAIL: TestAccAWSAPIGatewayV2Stage_RouteSettingsHttp (14.87s)
    testing.go:684: Step 0 error: errors during apply:

        Error: error creating API Gateway v2 stage: BadRequestException: Execution logs are not supported on protocolType HTTP

          on /tmp/tf-test367159095/main.tf line 7:
          (source code not available)


FAIL
FAIL    github.com/terraform-providers/terraform-provider-aws/aws   14.926s
FAIL
GNUmakefile:26: recipe for target 'testacc' failed
make: *** [testacc] Error 1

@reyescameron17 Could you please raise another issue, linking to this one? Thanks.

Will do.

BTW we were testing for WebSocket APIs, not HTTP APIs.

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!

Was this page helpful?
0 / 5 - 0 ratings