'Terraform detects changes to availability domain on data lookup

Terraform detects changes to availability_domain and forces a replacement when no change has taken place.

When I run terraform apply a second time with no changes made, terraform forces a replacement of my instance, this is due to the availability_domain lookup, is this a bug, or is my lookup incorrect?

  # module.services.oci_core_volume must be replaced
-/+ resource "oci_core_volume" "disk_res_instance[" {
      + auto_tuned_vpus_per_gb = (known after apply)
      ~ availability_domain    = "REGION" -> (known after apply) # forces replacement
      + backup_policy_id       = (known after apply)
      ~ freeform_tags          = {} -> (known after apply)
      ~ id                     = "ocid1.volume.oc1.me-jeddah-1.abc" -> (known after apply)
      ~ is_auto_tune_enabled   = false -> (known after apply)
      ~ is_hydrated            = true -> (known after apply)
      + kms_key_id             = (known after apply)
      ~ size_in_mbs            = "51200" -> (known after apply)

If I'm reading this correctly, it seems that the replacement is forced by the availability_domain, however, this remains unchanged.

resource "oci_core_volume" "diskinstance" {
  count               = 1
  availability_domain = data.oci_identity_availability_domains.ad_list.availability_domains[0]["name"]
...

data

data "oci_identity_availability_domains" "ad_list" {
  compartment_id = var.compartment_id
}

Is it that each time the data look-up on the availability domains is being done it forces it to be replaced, or something else?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source