oracle / terraform-provider-oci

Terraform Oracle Cloud Infrastructure provider
https://www.terraform.io/docs/providers/oci/
Mozilla Public License 2.0
754 stars 672 forks source link

dynamic block does not detect (some) changes when variable is updated #2058

Open dev-null-loop opened 6 months ago

dev-null-loop commented 6 months ago

I've created an oci_disaster_recovery_dr_protection_group resource using dynamic block:

variable "members" {
  description = "(Optional) (Updatable) A list of DR protection group members."
  type = list(object({
    is_movable             = optional(bool)
    is_retain_fault_domain = optional(bool)
    is_start_stop_enabled  = optional(bool)
    id                     = optional(string)
    type                   = optional(string)
  }))
  default = [
    {
      is_movable             = false
      is_retain_fault_domain = false
      is_start_stop_enabled  = false
      id                     = "ocid1.volumegroup.oc1.eu-frankfurt-1.abtheljryhtexs6jsjzyedljwhns5i6kmfmqllrn25enutxselgfqhftyf7a"
      type                   = "VOLUME_GROUP"
    }
  ]
}

resource "oci_disaster_recovery_dr_protection_group" "this" {
  compartment_id = var.compartment_id
  display_name   = var.display_name

  log_location {
    bucket    = var.bucket
    namespace = var.namespace
  }

  dynamic "members" {
    for_each = var.members != null ? var.members : []
    iterator = mbr

    content {
      is_movable             = mbr.value.is_movable
      is_retain_fault_domain = mbr.value.is_retain_fault_domain
      is_start_stop_enabled  = mbr.value.is_start_stop_enabled
      member_id              = mbr.value.id
      member_type            = mbr.value.type
    }
  }
}

The member (VOLUME_GROUP type) is attached to the resource as supposed. The problem is that if I remove(comment) it from configuration( set members to []) and run terraform apply the code does not do anything.

Debug Output

$ terraform apply
oci_disaster_recovery_dr_protection_group.this: Refreshing state... [id=ocid1.drprotectiongroup.oc1.eu-frankfurt-1.aaaaaaaappcjjp3oqv6umc6jr5av5g4cbej2eavtncnk2v4kiephexvexqbq]

No changes. Your infrastructure matches the configuration.

Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed.

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

Expected Behavior

Member should be deleted and should not appear in the list of members of the Disaster Recovery group.

Actual Behavior

No changes are detected. The member is still there.

Steps to Reproduce

  1. terraform apply

Affected Resources

oci_disaster_recovery_dr_protection_group

References

https://registry.terraform.io/providers/oracle/oci/5.31.0/docs/resources/disaster_recovery_dr_protection_group

tf-oci-pub commented 6 months ago

Thank you for reporting the issue. We observed the affected resources are not provided in the description or it's incorrect. We request you to add it in issue description as mentioned in below format. Example: affected_resources = oci_core_instance , oci_core_instances

If it's not related to any particular resource then mention affected resource as terraform. Example: affected_resources = terraform

As this works through automation, request you to follow exact syntax.

dev-null-loop commented 6 months ago

Affected_resource = oci_disaster_recovery_dr_protection_group

bogdan-m-darie commented 4 weeks ago

Fixed.