简体   繁体   中英

API Gateway resources are creating multiple times with terraform without considering state

I am implementing API Gateway with Terraform.. When I create first time all path parts and integration/methods are creating as expected. When I run terraform apply again, TF re-creating integration and then re-creating all integration responses. TF not considering state file and creating (destroy and create) multiple times which causes lot of issues.

Did anyone faced this similar issue?

 # module.reset-password_options.aws_api_gateway_integration.default must be replaced
-/+ resource "aws_api_gateway_integration" "default" {
      - cache_key_parameters    = [] -> null
      ~ cache_namespace         = "7cpdkv" -> (known after apply)
      ~ id                      = "agi-4ek66g6ej2-7cpdkv-OPTIONS" -> (known after apply)
      + integration_http_method = "OPTIONS" # forces replacement
      - request_parameters      = {} -> null
        # (8 unchanged attributes hidden)
    } 

Like above it is changing on every terraform apply.

Apply complete: Resources, 52 added, 14 changed. 27 destroyed.

I am using below terraform

Terraform v1.0.7, provider registry.terraform.io/hashicorp/aws v3.59.0

If the aws_api_gateway_integration resource is of type "MOCK" AND integration_http_method is set, the AWS API silently ignores the integration_http_method setting. I suppose these combinations are not supported? Then, the next time an apply is run, terraform sees that integration_http_method is not set and recreates the resource. Wash, repeat, because this is never actually set with type == "MOCK".

A solution here is to remove your integration_http_method setting.

See this issue for more info: https://github.com/hashicorp/terraform-provider-aws/issues/11810

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM