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_api_gateway_method_settings resource produced new value for was present but now absent #12638

Closed
DavidTanner opened this issue Apr 2, 2020 · 4 comments · Fixed by #12651
Labels
bug Addresses a defect in current functionality. service/apigateway Issues and PRs that pertain to the apigateway service.
Milestone

Comments

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

Using Terraform version 0.12.24

Affected Resource(s)

  • aws_api_gateway_method_settings

Terraform Configuration Files

resource "aws_api_gateway_rest_api" "rest_api" {
  name        = "ProviderBugGateway"
  description = "This is my API for demonstration purposes"
}

resource "aws_api_gateway_integration" "integration" {
  rest_api_id = aws_api_gateway_rest_api.rest_api.id
  resource_id = aws_api_gateway_resource.resource.id
  http_method = aws_api_gateway_method.method.http_method
  type        = "MOCK"

  request_templates = {
    "application/xml" = <<EOF
{
   "body" : $input.json('$')
}
EOF
  }
}

resource "aws_api_gateway_deployment" "deployment" {
  depends_on  = [aws_api_gateway_integration.integration]
  rest_api_id = aws_api_gateway_rest_api.rest_api.id
  stage_name  = "dev"
}

resource "aws_api_gateway_stage" "stage" {
  stage_name    = "prod"
  rest_api_id   = aws_api_gateway_rest_api.rest_api.id
  deployment_id = aws_api_gateway_deployment.deployment.id
}

resource "aws_api_gateway_resource" "resource" {
  rest_api_id = aws_api_gateway_rest_api.rest_api.id
  parent_id   = aws_api_gateway_rest_api.rest_api.root_resource_id
  path_part   = "{proxy+}"
}

resource "aws_api_gateway_method" "method" {
  rest_api_id   = aws_api_gateway_rest_api.rest_api.id
  resource_id   = aws_api_gateway_resource.resource.id
  http_method   = "ANY"
  authorization = "NONE"
}

resource "aws_api_gateway_method_settings" "method_settings" {
  rest_api_id = aws_api_gateway_rest_api.rest_api.id
  stage_name  = aws_api_gateway_stage.stage.stage_name
  method_path = "${aws_api_gateway_resource.resource.path_part}/${aws_api_gateway_method.method.http_method}"

  settings {
    caching_enabled = false
    cache_ttl_in_seconds = 0
  }
}

Debug Output

[TRACE] dag/walk: visiting "aws_api_gateway_method_settings.method_settings (prepare state)"
[TRACE] vertex "aws_api_gateway_method_settings.method_settings (prepare state)": starting visit (*terraform.NodeApplyableResource)
[TRACE] vertex "aws_api_gateway_method_settings.method_settings (prepare state)": evaluating
[TRACE] [walkApply] Entering eval tree: aws_api_gateway_method_settings.method_settings (prepare state)
[TRACE] <root>: eval: *terraform.EvalWriteResourceState
[TRACE] [walkApply] Exiting eval tree: aws_api_gateway_method_settings.method_settings (prepare state)
[TRACE] vertex "aws_api_gateway_method_settings.method_settings (prepare state)": visit complete
[TRACE] dag/walk: visiting "aws_api_gateway_resource.resource (prepare state)"
[TRACE] vertex "aws_api_gateway_resource.resource (prepare state)": starting visit (*terraform.NodeApplyableResource)
[TRACE] vertex "aws_api_gateway_resource.resource (prepare state)": evaluating
[TRACE] [walkApply] Entering eval tree: aws_api_gateway_resource.resource (prepare state)
[TRACE] <root>: eval: *terraform.EvalWriteResourceState
[TRACE] [walkApply] Exiting eval tree: aws_api_gateway_resource.resource (prepare state)
[TRACE] vertex "aws_api_gateway_resource.resource (prepare state)": visit complete
[TRACE] dag/walk: visiting "aws_api_gateway_method_settings.method_settings"
[TRACE] vertex "aws_api_gateway_method_settings.method_settings": starting visit (*terraform.NodeApplyableResourceInstance)
[TRACE] vertex "aws_api_gateway_method_settings.method_settings": evaluating
[TRACE] [walkApply] Entering eval tree: aws_api_gateway_method_settings.method_settings
[TRACE] <root>: eval: *terraform.EvalSequence
[TRACE] <root>: eval: *terraform.EvalGetProvider
[TRACE] <root>: eval: *terraform.EvalReadDiff
[TRACE] EvalReadDiff: Read Create change from plan for aws_api_gateway_method_settings.method_settings
[TRACE] <root>: eval: *terraform.EvalIf
[TRACE] <root>: eval: terraform.EvalNoop
[TRACE] <root>: eval: *terraform.EvalIf
[TRACE] <root>: eval: *terraform.EvalReadState
[TRACE] EvalReadState: reading state for aws_api_gateway_method_settings.method_settings
[TRACE] EvalReadState: no state present for aws_api_gateway_method_settings.method_settings
[TRACE] <root>: eval: *terraform.EvalReadDiff
[TRACE] EvalReadDiff: Read Create change from plan for aws_api_gateway_method_settings.method_settings
[TRACE] <root>: eval: *terraform.EvalDiff
[TRACE] Re-validating config for "aws_api_gateway_method_settings.method_settings"
[TRACE] GRPCProvider: ValidateResourceTypeConfig
[TRACE] GRPCProvider: PlanResourceChange
[TRACE] <root>: eval: *terraform.EvalCheckPlannedChange
[TRACE] EvalCheckPlannedChange: Verifying that actual change (action Create) matches planned change (action Create)
[TRACE] <root>: eval: *terraform.EvalGetProvider
[TRACE] <root>: eval: *terraform.EvalReadState
[TRACE] EvalReadState: reading state for aws_api_gateway_method_settings.method_settings
[TRACE] EvalReadState: no state present for aws_api_gateway_method_settings.method_settings
[TRACE] <root>: eval: *terraform.EvalReduceDiff
[TRACE] <root>: eval: *terraform.EvalIf
[TRACE] <root>: eval: terraform.EvalNoop
[TRACE] <root>: eval: *terraform.EvalApplyPre
[TRACE] <root>: eval: *terraform.EvalApply
[DEBUG] aws_api_gateway_method_settings.method_settings: applying the planned Create change
[TRACE] GRPCProvider: ApplyResourceChange
[DEBUG] plugin.terraform-provider-aws_v2.55.0: [DEBUG] Updating API Gateway Stage: {
[DEBUG] plugin.terraform-provider-aws_v2.55.0:   PatchOperations: [],
[DEBUG] plugin.terraform-provider-aws_v2.55.0:   RestApiId:
[DEBUG] plugin.terraform-provider-aws_v2.55.0:   StageName: "prod"
[DEBUG] plugin.terraform-provider-aws_v2.55.0: }
[DEBUG] plugin.terraform-provider-aws_v2.55.0: [DEBUG] [aws-sdk-go] DEBUG: Request apigateway/UpdateStage Details:
[DEBUG] plugin.terraform-provider-aws_v2.55.0: ---[ REQUEST POST-SIGN ]-----------------------------
[DEBUG] plugin.terraform-provider-aws_v2.55.0: PATCH /restapis/**********/stages/prod HTTP/1.1
[DEBUG] plugin.terraform-provider-aws_v2.55.0: Host: apigateway.us-east-1.amazonaws.com
[DEBUG] plugin.terraform-provider-aws_v2.55.0: User-Agent: aws-sdk-go/1.29.24 (go1.13.7; linux; amd64) APN/1.0 HashiCorp/1.0 Terraform/0.12.24 (+https://www.terraform.io)
[DEBUG] plugin.terraform-provider-aws_v2.55.0: Content-Length: 22
[DEBUG] plugin.terraform-provider-aws_v2.55.0: Accept: application/json
[DEBUG] plugin.terraform-provider-aws_v2.55.0: Content-Type: application/json
[DEBUG] plugin.terraform-provider-aws_v2.55.0: X-Amz-Date: 
[DEBUG] plugin.terraform-provider-aws_v2.55.0: Accept-Encoding: gzip
[DEBUG] plugin.terraform-provider-aws_v2.55.0: 
[DEBUG] plugin.terraform-provider-aws_v2.55.0: {"patchOperations":[]}
[DEBUG] plugin.terraform-provider-aws_v2.55.0: -----------------------------------------------------
[DEBUG] plugin.terraform-provider-aws_v2.55.0: [DEBUG] [aws-sdk-go] DEBUG: Response apigateway/UpdateStage Details:
[DEBUG] plugin.terraform-provider-aws_v2.55.0: ---[ RESPONSE ]--------------------------------------
[DEBUG] plugin.terraform-provider-aws_v2.55.0: HTTP/1.1 200 OK
[DEBUG] plugin.terraform-provider-aws_v2.55.0: Connection: close
[DEBUG] plugin.terraform-provider-aws_v2.55.0: Content-Length: 241
[DEBUG] plugin.terraform-provider-aws_v2.55.0: Content-Type: application/json
[DEBUG] plugin.terraform-provider-aws_v2.55.0: Date: 
[DEBUG] plugin.terraform-provider-aws_v2.55.0: X-Amz-Apigw-Id:
[DEBUG] plugin.terraform-provider-aws_v2.55.0: X-Amzn-Requestid:
[DEBUG] plugin.terraform-provider-aws_v2.55.0: 
[DEBUG] plugin.terraform-provider-aws_v2.55.0: 
[DEBUG] plugin.terraform-provider-aws_v2.55.0: -----------------------------------------------------
[DEBUG] plugin.terraform-provider-aws_v2.55.0: [DEBUG] [aws-sdk-go] {"cacheClusterEnabled":false,"cacheClusterStatus":"NOT_AVAILABLE","createdDate":**********,"deploymentId":"******","disableExecuteApiEndpoint":false,"lastUpdatedDate":**********,"methodSettings":{},"stageName":"prod","tracingEnabled":false}
[DEBUG] plugin.terraform-provider-aws_v2.55.0: [DEBUG] Reading API Gateway Method Settings **********-prod-{proxy+}/ANY
[DEBUG] plugin.terraform-provider-aws_v2.55.0: [DEBUG] [aws-sdk-go] DEBUG: Request apigateway/GetStage Details:
[DEBUG] plugin.terraform-provider-aws_v2.55.0: ---[ REQUEST POST-SIGN ]-----------------------------
[DEBUG] plugin.terraform-provider-aws_v2.55.0: GET /restapis/**********/stages/prod HTTP/1.1
[DEBUG] plugin.terraform-provider-aws_v2.55.0: Host: apigateway.us-east-1.amazonaws.com
[DEBUG] plugin.terraform-provider-aws_v2.55.0: User-Agent: aws-sdk-go/1.29.24 (go1.13.7; linux; amd64) APN/1.0 HashiCorp/1.0 Terraform/0.12.24 (+https://www.terraform.io)
[DEBUG] plugin.terraform-provider-aws_v2.55.0: Accept: application/json
[DEBUG] plugin.terraform-provider-aws_v2.55.0: Content-Type: application/json
[DEBUG] plugin.terraform-provider-aws_v2.55.0: X-Amz-Date: 
[DEBUG] plugin.terraform-provider-aws_v2.55.0: Accept-Encoding: gzip
[DEBUG] plugin.terraform-provider-aws_v2.55.0: 
[DEBUG] plugin.terraform-provider-aws_v2.55.0: 
[DEBUG] plugin.terraform-provider-aws_v2.55.0: -----------------------------------------------------
[DEBUG] plugin.terraform-provider-aws_v2.55.0: [DEBUG] [aws-sdk-go] DEBUG: Response apigateway/GetStage Details:
[DEBUG] plugin.terraform-provider-aws_v2.55.0: ---[ RESPONSE ]--------------------------------------
[DEBUG] plugin.terraform-provider-aws_v2.55.0: HTTP/1.1 200 OK
[DEBUG] plugin.terraform-provider-aws_v2.55.0: Connection: close
[DEBUG] plugin.terraform-provider-aws_v2.55.0: Content-Length: 241
[DEBUG] plugin.terraform-provider-aws_v2.55.0: Content-Type: application/json
[DEBUG] plugin.terraform-provider-aws_v2.55.0: Date: 
[DEBUG] plugin.terraform-provider-aws_v2.55.0: X-Amz-Apigw-Id:
[DEBUG] plugin.terraform-provider-aws_v2.55.0: X-Amzn-Requestid:
[DEBUG] plugin.terraform-provider-aws_v2.55.0: 
[DEBUG] plugin.terraform-provider-aws_v2.55.0: 
[DEBUG] plugin.terraform-provider-aws_v2.55.0: -----------------------------------------------------
[DEBUG] plugin.terraform-provider-aws_v2.55.0: [DEBUG] [aws-sdk-go] {"cacheClusterEnabled":false,"cacheClusterStatus":"NOT_AVAILABLE","createdDate":**********,"deploymentId":"******","disableExecuteApiEndpoint":false,"lastUpdatedDate":**********,"methodSettings":{},"stageName":"prod","tracingEnabled":false}
[DEBUG] plugin.terraform-provider-aws_v2.55.0: [DEBUG] Received API Gateway Stage: {
[DEBUG] plugin.terraform-provider-aws_v2.55.0:   CacheClusterEnabled: false,
[DEBUG] plugin.terraform-provider-aws_v2.55.0:   CacheClusterStatus: "NOT_AVAILABLE",
[DEBUG] plugin.terraform-provider-aws_v2.55.0:   CreatedDate: 
[DEBUG] plugin.terraform-provider-aws_v2.55.0:   DeploymentId:
[DEBUG] plugin.terraform-provider-aws_v2.55.0:   LastUpdatedDate: 
[DEBUG] plugin.terraform-provider-aws_v2.55.0:   MethodSettings: {
[DEBUG] plugin.terraform-provider-aws_v2.55.0: 
[DEBUG] plugin.terraform-provider-aws_v2.55.0:   },
[DEBUG] plugin.terraform-provider-aws_v2.55.0:   StageName: "prod",
[DEBUG] plugin.terraform-provider-aws_v2.55.0:   TracingEnabled: false
[DEBUG] plugin.terraform-provider-aws_v2.55.0: }
[DEBUG] plugin.terraform-provider-aws_v2.55.0: [WARN] API Gateway Method Settings for "{proxy+}/ANY" not found, removing
[DEBUG] aws_api_gateway_method_settings.method_settings: apply errored, but we're indicating that via the Error pointer rather than returning it: Provider produced inconsistent result after apply: When applying changes to aws_api_gateway_method_settings.method_settings, provider "registry.terraform.io/-/aws" produced an unexpected new value for was present, but now absent.

This is a bug in the provider, which should be reported in the provider's own issue tracker.
[TRACE] <root>: eval: *terraform.EvalMaybeTainted
[TRACE] EvalMaybeTainted: aws_api_gateway_method_settings.method_settings encountered an error during creation, so it is now marked as tainted
[TRACE] <root>: eval: *terraform.EvalWriteState
[TRACE] EvalWriteState: removing state object for aws_api_gateway_method_settings.method_settings
[TRACE] <root>: eval: *terraform.EvalApplyProvisioners
[TRACE] EvalApplyProvisioners: aws_api_gateway_method_settings.method_settings has no state, so skipping provisioners
[TRACE] <root>: eval: *terraform.EvalMaybeTainted
[TRACE] EvalMaybeTainted: aws_api_gateway_method_settings.method_settings encountered an error during creation, so it is now marked as tainted
[TRACE] <root>: eval: *terraform.EvalWriteState
[TRACE] EvalWriteState: removing state object for aws_api_gateway_method_settings.method_settings
[TRACE] <root>: eval: *terraform.EvalIf
[TRACE] <root>: eval: *terraform.EvalIf
[TRACE] <root>: eval: *terraform.EvalWriteDiff
[TRACE] <root>: eval: *terraform.EvalApplyPost
[ERROR] <root>: eval: *terraform.EvalApplyPost, err: Provider produced inconsistent result after apply: When applying changes to aws_api_gateway_method_settings.method_settings, provider "registry.terraform.io/-/aws" produced an unexpected new value for was present, but now absent.

This is a bug in the provider, which should be reported in the provider's own issue tracker.
[ERROR] <root>: eval: *terraform.EvalSequence, err: Provider produced inconsistent result after apply: When applying changes to aws_api_gateway_method_settings.method_settings, provider "registry.terraform.io/-/aws" produced an unexpected new value for was present, but now absent.

This is a bug in the provider, which should be reported in the provider's own issue tracker.

Expected Behavior

An error message maybe about trying to create an invalid resource?

Actual Behavior

The resource isn't created and Terraform crashes with an error for the provider.

Provider produced inconsistent result after apply: When applying changes to aws_api_gateway_method_settings.method_settings, provider "registry.terraform.io/-/aws" produced an unexpected new value for was present, but now absent.

Steps to Reproduce

  1. terraform apply

References

#10549
#11611

hashicorp/terraform#20688

@ghost ghost added the service/apigateway Issues and PRs that pertain to the apigateway service. label Apr 2, 2020
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Apr 2, 2020
@DrFaust92
Copy link
Collaborator

im able to reproduce this in provider tests, i think it stems from setting cache_ttl_in_seconds = 0 when adding new method settings.

looking into it

@ewbankkit ewbankkit added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Jul 25, 2020
@anGie44 anGie44 added this to the v3.1.0 milestone Jul 31, 2020
@anGie44
Copy link
Contributor

anGie44 commented Jul 31, 2020

The bug fix has been merged and will be released in v3.1.0 of the Provider.

@ghost
Copy link

ghost commented Aug 7, 2020

This has been released in version 3.1.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 Aug 31, 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 Aug 31, 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/apigateway Issues and PRs that pertain to the apigateway service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants