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

Unexpected provider exception when creating "aws_api_gateway_method_settings" #13985

Closed
ghost opened this issue Jun 29, 2020 · 3 comments · Fixed by #17234
Closed

Unexpected provider exception when creating "aws_api_gateway_method_settings" #13985

ghost opened this issue Jun 29, 2020 · 3 comments · Fixed by #17234
Assignees
Labels
bug Addresses a defect in current functionality. service/apigateway Issues and PRs that pertain to the apigateway service.
Milestone

Comments

@ghost
Copy link

ghost commented Jun 29, 2020

This issue was originally opened by @FlokiOo as hashicorp/terraform#25404. It was migrated here as a result of the provider split. The original body of the issue is below.


Hey,

we try to enable Logging and Metrics for our API-Gateway and added the following resource:

resource "aws_api_gateway_method_settings" "settings" {
  rest_api_id = aws_api_gateway_rest_api.rest_api.id
  stage_name = var.api_gateway_stage
  method_path = "${aws_api_gateway_resource.resource.path_part}/${aws_api_gateway_method.method.http_method}"
  settings {
    metrics_enabled = true
    logging_level = "ERROR"
    data_trace_enabled = true
  }
}

Unfortunately this throws the following exception when it gets executed:

module.datalake_zendesk.module.apigateway_instances.aws_api_gateway_method_settings.settings,
provider "aws" produced an unexpected new value for was present, but now
absent.

Any idea what could cause this issue and how we can fix it?

Greetings Dave

@ghost ghost added the service/apigateway Issues and PRs that pertain to the apigateway service. label Jun 29, 2020
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Jun 29, 2020
@breathingdust breathingdust added question A question about existing functionality; most questions are re-routed to discuss.hashicorp.com. and removed needs-triage Waiting for first response or review from a maintainer. labels Jul 7, 2020
@bflad
Copy link
Contributor

bflad commented Jan 22, 2021

Hi @FlokiOo 👋 Thank you for raising this and sorry you ran into trouble here.

There are likely two things going on here. For the confusing error message, its related to #16796 which we will plan on fixing more broadly across Terraform AWS Provider resources in the near future. As for the cause of the confusing error message, my best guess is that in another part of your configuration you have something like the following:

resource "aws_api_gateway_deployment" "example" {
  # ... other configuration ...
  stage_name = var.api_gateway_stage
}

If that is the case, this is likely the cause. We are now recommending (and documenting) to not use the aws_api_gateway_deployment resource stage_name argument and instead using the aws_api_gateway_stage resource by itself. There's a long writeup over in #11344 (comment) with more explanation and recommended configurations if you need them.

I'm going to relabel this issue though to fix the d.IsNewResource() issue. It won't mitigate the actual problem, but it will at least give operators a slightly better error message.

@bflad bflad added bug Addresses a defect in current functionality. and removed question A question about existing functionality; most questions are re-routed to discuss.hashicorp.com. labels Jan 22, 2021
@bflad bflad self-assigned this Jan 22, 2021
bflad added a commit that referenced this issue Jan 22, 2021
…uring creation and deletion

Reference: #13985
Reference: #16796

Fixing this as part of API Gateway service spike work. As mentioned in the issue this will not help mitigate the cause of the problem, but will at least give a better error message.

Output from acceptance testing:

```
--- PASS: TestAccAWSAPIGatewayMethodSettings_basic (25.35s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_disappears (247.81s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_Settings_CacheDataEncrypted (147.06s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_Settings_CacheTtlInSeconds (340.17s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_Settings_CachingEnabled (448.46s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_Settings_DataTraceEnabled (216.61s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_Settings_LoggingLevel (55.96s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_Settings_MetricsEnabled (397.43s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_Settings_Multiple (692.67s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_Settings_RequireAuthorizationForCacheControl (178.96s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_Settings_ThrottlingBurstLimit (118.97s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_Settings_ThrottlingBurstLimitDisabledByDefault (86.39s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_Settings_ThrottlingRateLimit (515.72s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_Settings_ThrottlingRateLimitDisabledByDefault (484.35s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_Settings_UnauthorizedCacheControlHeaderStrategy (312.16s)
```
bflad added a commit that referenced this issue Feb 3, 2021
…uring creation and deletion (#17234)

Reference: #13985
Reference: #16796

Fixing this as part of API Gateway service spike work. As mentioned in the issue this will not help mitigate the cause of the problem, but will at least give a better error message.

Output from acceptance testing:

```
--- PASS: TestAccAWSAPIGatewayMethodSettings_basic (25.35s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_disappears (247.81s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_Settings_CacheDataEncrypted (147.06s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_Settings_CacheTtlInSeconds (340.17s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_Settings_CachingEnabled (448.46s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_Settings_DataTraceEnabled (216.61s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_Settings_LoggingLevel (55.96s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_Settings_MetricsEnabled (397.43s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_Settings_Multiple (692.67s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_Settings_RequireAuthorizationForCacheControl (178.96s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_Settings_ThrottlingBurstLimit (118.97s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_Settings_ThrottlingBurstLimitDisabledByDefault (86.39s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_Settings_ThrottlingRateLimit (515.72s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_Settings_ThrottlingRateLimitDisabledByDefault (484.35s)
--- PASS: TestAccAWSAPIGatewayMethodSettings_Settings_UnauthorizedCacheControlHeaderStrategy (312.16s)
```
@github-actions github-actions bot added this to the v3.27.0 milestone Feb 3, 2021
@ghost
Copy link
Author

ghost commented Feb 5, 2021

This has been released in version 3.27.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
Author

ghost commented Mar 5, 2021

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 Mar 5, 2021
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/apigateway Issues and PRs that pertain to the apigateway service.
Projects
None yet
2 participants