Kong / terraform-provider-konnect

16 stars 3 forks source link

Updating tags causes resource destruction/recreation #40

Open gordon-writer opened 5 days ago

gordon-writer commented 5 days ago

Updating the tags of a resource should be possible as an update in-place (for example you can edit the tags in Konnect console).

However when using this provider it forces a destroy/recreate instead of an update in-place. I have observed this for the service and route resources (see output below) when trying to use import blocks to make terraform claim existing Konnect resources.

This has a knock-on effect to any dependent resources: if a service is destroyed and recreated, then it also forces destruction/recreation of resources that reference it in their ID (such as routes).

This makes it more challenging to migrate existing infra seamlessly to be managed by this provider.

terraform plan

<snip>

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
~ update in-place
-/+ destroy and then create replacement

<snip>

  # Warning: this will destroy the imported resource
-/+ resource "konnect_gateway_service" "my_service" {
    ...
      ~ created_at         = 1719263955 -> (known after apply)
      ~ id                 = "foo123" -> (known after apply)
      ~ tags               = [ # forces replacement
          + "tag1",
          + "tag2",
          + "tag3",
        ]
      ~ updated_at         = 1719263955 -> (known after apply)
    ...
    }

  # Warning: this will destroy the imported resource
-/+ resource "konnect_gateway_route" "my_route" {
    ...
      ~ created_at                 = 1719263961 -> (known after apply)
      ~ id                         = "bar987" -> (known after apply)
      ~ service                    = { # forces replacement
          ~ id = "baz567" # forces replacement -> (known after apply) # forces replacement
        }
      ~ tags                       = [ # forces replacement
          + "tag1",
          + "tag2",
          + "tag3",
        ]
      ~ updated_at                 = 1719263961 -> (known after apply)
    ...
    }