yandex-cloud / terraform-provider-yandex

Terraform Yandex provider
https://www.terraform.io/docs/providers/yandex/
Mozilla Public License 2.0
211 stars 116 forks source link

subnet_ids not retained in state upon import for yandex_mdb_kafka_cluster resource #481

Open alexmorbo opened 2 weeks ago

alexmorbo commented 2 weeks ago

When importing a Kafka cluster using the yandex_mdb_kafka_cluster resource, the subnet_ids attribute is not retained in the Terraform state. This results in an in-place update being triggered during a terraform plan, as the state does not reflect the imported resource's subnet_ids.

Steps to Reproduce

1 - Import Kafka cluster:

terraform import yandex_mdb_kafka_cluster.cluster <cluster_id>

2 - Run plan to check the state:

terragrunt plan

Observed Behavior

The following plan is generated:

Terraform will perform the following actions:
  # yandex_mdb_kafka_cluster.cluster will be updated in-place
  ~ resource "yandex_mdb_kafka_cluster" "cluster" {
        id                  = "<cluster_id>"
        name                = "default"
      + subnet_ids          = [
          + "<subnet_id>",
          + "<subnet_id>",
          + "<subnet_id>",
        ]
        # (11 unchanged attributes hidden)
        # (2 unchanged blocks hidden)
    }
Plan: 0 to add, 1 to change, 0 to destroy.

3 - Attempting to apply the changes results in an error:

terraform apply --auto-approve

Error output:

Error: error while requesting API to update Kafka Cluster "<cluster_id>": server-request-id = 29a8624d-4593-48c9-9b8b-252d732130bf server-trace-id = b745c7733b4bf83e:8171927284a3849a:b745c7733b4bf83e:1 client-request-id = c4e1ffe9-bf26-4dc4-af9e-09fc419f4f96 client-trace-id = 0f2a093a-65d1-481e-bbd5-26d7ea27adc1 rpc error: code = FailedPrecondition desc = no changes detected

Expected Behavior

Upon importing yandex_mdb_kafka_cluster, the subnet_ids should be correctly populated in the state, so no in-place update is triggered during a subsequent plan.

Environment: Provider version: 0.130.0 Terraform version: v1.6.6

This issue leads to failed apply attempts, as Terraform identifies no actual changes when calling the Yandex API.