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

aws_apigatewayv2_stage failing to update when no changes #12893

Closed
LaurenceGA opened this issue Apr 20, 2020 · 17 comments · Fixed by #12904
Closed

aws_apigatewayv2_stage failing to update when no changes #12893

LaurenceGA opened this issue Apr 20, 2020 · 17 comments · Fixed by #12904
Labels
bug Addresses a defect in current functionality. service/apigatewayv2 Issues and PRs that pertain to the apigatewayv2 service.
Milestone

Comments

@LaurenceGA
Copy link

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

@ghost ghost added the service/apigatewayv2 Issues and PRs that pertain to the apigatewayv2 service. label Apr 20, 2020
@bflad bflad added the needs-triage Waiting for first response or review from a maintainer. label Apr 20, 2020
@ewbankkit
Copy link
Contributor

Submitted #12904 to correct this.

@sc250024
Copy link

Ran into the same problem. Thanks @ewbankkit !

@virgofx
Copy link

virgofx commented May 19, 2020

Any chance this could get merged?

@anGie44 anGie44 added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Jun 1, 2020
@anGie44 anGie44 added this to the v2.65.0 milestone Jun 3, 2020
@anGie44
Copy link
Contributor

anGie44 commented Jun 3, 2020

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.

@ghost
Copy link

ghost commented Jun 5, 2020

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!

@reyescameron17
Copy link

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?

@ewbankkit
Copy link
Contributor

@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

@reyescameron17
Copy link

reyescameron17 commented Jun 17, 2020

That's correct.

 Successfully configured the backend "s3"! Terraform will automatically
16:31:13  use this backend unless the backend configuration changes.�[0m
16:31:14  
16:31:14  �[0m�[1mInitializing provider plugins...�[0m
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  �[31m
16:31:32  �[1m�[31mError: �[0m�[0m�[1merror creating API Gateway v2 stage: BadRequestException: Execution logs are not supported on protocolType HTTP�[0m
16:31:32  

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

@ewbankkit
Copy link
Contributor

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

@reyescameron17
Copy link

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
  }
}

@anGie44
Copy link
Contributor

anGie44 commented Jun 17, 2020

@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)

@reyescameron17
Copy link

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.

@ewbankkit
Copy link
Contributor

@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.

@ewbankkit
Copy link
Contributor

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.

@reyescameron17
Copy link

Will do.

@ewbankkit
Copy link
Contributor

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

@ghost
Copy link

ghost commented Jul 3, 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 and limited conversation to collaborators Jul 3, 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
7 participants