IBM-Cloud / terraform-provider-ibm

https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs
Mozilla Public License 2.0
339 stars 663 forks source link

ibm_event_streams_topic: unexpected state change kafka_brokers_sasl #3199

Open willholley opened 2 years ago

willholley commented 2 years ago

Community Note

Terraform CLI and Terraform IBM Provider Version

Terraform v1.0.7
on darwin_amd64
+ provider registry.terraform.io/hashicorp/cloudinit v2.2.0
+ provider registry.terraform.io/hashicorp/external v2.1.0
+ provider registry.terraform.io/hashicorp/helm v2.3.0
+ provider registry.terraform.io/hashicorp/kubernetes v2.5.0
+ provider registry.terraform.io/hashicorp/local v2.1.0
+ provider registry.terraform.io/hashicorp/null v3.1.0
+ provider registry.terraform.io/hashicorp/time v0.7.2
+ provider registry.terraform.io/ibm-cloud/ibm v1.33.1

Affected Resource(s)

Terraform Configuration Files

Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.


locals {
  topics = {
    "connect-status-es-dbcore" : {
      "partitions" : 10
      "cleanup_policy" : "delete"
    },
  }
}

resource "ibm_event_streams_topic" "topics" {
  for_each = local.topics

  resource_instance_id = module.cloudant_logs_es.instance.id
  name                  = each.key
  partitions           = each.value.partitions
  config = {
    "cleanup.policy"  = each.value.cleanup_policy
    "retention.ms"    = "86400000"
    "retention.bytes" = "1073741824"
    "segment.bytes"   = "536870912"
  }
}

Debug Output

Panic Output

Expected Behavior

When refreshing the Terraform state for ibm_event_streams_topic.topics["connect-status-es-dbcore"], nothing should change.

Actual Behavior

When refreshing the Terraform state, the ibm_event_streams_topic::kafka_brokers_sasl field has changed. This appears to be due to the brokers being returned in a different order by the API.

# ibm_event_streams_topic.topics["connect-status-es-dbcore"] has been changed
  ~ resource "ibm_event_streams_topic" "topics" {
        id                   = "crn:v1:bluemix:public:messagehub:us-south:a/a91c1b53a636460796d46543a1dd4af5:25d0c04f-db7a-4501-ade3-088405b0897b:topic:connect-status-es-dbcore"
      ~ kafka_brokers_sasl   = [
          - "kafka-1.mh-gxwkmmzrsqbgsrxyxnbz-4c201a12d7add7c99d2b22e361c6f175-0000.us-south.containers.appdomain.cloud:9093",
          - "kafka-0.mh-gxwkmmzrsqbgsrxyxnbz-4c201a12d7add7c99d2b22e361c6f175-0000.us-south.containers.appdomain.cloud:9093",
            "kafka-2.mh-gxwkmmzrsqbgsrxyxnbz-4c201a12d7add7c99d2b22e361c6f175-0000.us-south.containers.appdomain.cloud:9093",
          + "kafka-0.mh-gxwkmmzrsqbgsrxyxnbz-4c201a12d7add7c99d2b22e361c6f175-0000.us-south.containers.appdomain.cloud:9093",
          + "kafka-1.mh-gxwkmmzrsqbgsrxyxnbz-4c201a12d7add7c99d2b22e361c6f175-0000.us-south.containers.appdomain.cloud:9093",
        ]
        name                 = "connect-status-es-dbcore"
        # (4 unchanged attributes hidden)
    }

I expect the property should be represented as schema.TypeSet instead of schema.TypeList at https://github.com/IBM-Cloud/terraform-provider-ibm/blob/6176948f027e7c2ca170a438d6c3b12c6e5c555c/ibm/resource_ibm_event_streams_topic.go#L65.

Steps to Reproduce

Important Factoids

References

n/a

kavya498 commented 2 years ago

@willholley , As a workaround please add below block in your ibm_event_streams_topic resource..

 lifecycle {
    ignore_changes = [
      kafka_brokers_sasl,
    ]
  }

We shall look into the issue..

Thanks

willholley commented 4 months ago

I don't think this workaround ever worked. With recent Terraform versions it explicitly fails with:

Warning: Redundant ignore_changes element

...

The attribute kafka_brokers_sasl is decided by the provider alone and
therefore there can be no configured value to compare with. Including this
attribute in ignore_changes has no effect. Remove the attribute from
ignore_changes to quiet this warning.