oracle / terraform-provider-oci

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

Imported oci_stack_monitoring_discovery_job fails on plan/apply because system_tags "doesn't support update" #2019

Open jeliker opened 9 months ago

jeliker commented 9 months ago

Community Note

Terraform Version and Provider Version

Terraform v1.5.7 on darwin_amd64

Affected Resource(s)

affected_resources = oci_stack_monitoring_discovery_job

Terraform Configuration Files

  # oci_stack_monitoring_discovery_job.the_discovery_job will be updated in-place
  # (imported from "REDACTED")
  ~ resource "oci_stack_monitoring_discovery_job" "the_discovery_job" {
        compartment_id   = "REDACTED"
        discovery_client = "DISCOVERY_UI"
        discovery_type   = "ADD_WITH_RETRY"
        freeform_tags    = {}
        id               = "REDACTED"
        state            = "ACTIVE"
        status           = "SUCCESS"
        status_message   = "Job completed successfully."
      + system_tags      = (known after apply)
        tenant_id        = "REDACTED"
        time_updated     = "2024-01-03 19:37:35 +0000 UTC"
        user_id          = "REDACTED"

        discovery_details {
            agent_id      = "REDACTED"
            resource_name = "REDACTED"
            resource_type = "HOST"

            properties {
                properties_map = {
                    "retry_job_id" = "[REDACTED]"
                }
            }

            tags {
                properties_map = {}
            }
        }

      - timeouts {}
    }

Plan: 1 to import, 0 to add, 1 to change, 0 to destroy.

Here is the output

oci_stack_monitoring_discovery_job.the_discovery_job: Importing... [id=REDACTED]
oci_stack_monitoring_discovery_job.the_discovery_job: Import complete [id=REDACTED]
oci_stack_monitoring_discovery_job.the_discovery_job: Modifying... [id=REDACTED]
╵
â•·
│ Error: doesn't support update

When I try apply again I see this:

  # oci_stack_monitoring_discovery_job.the_discovery_job will be updated in-place
  ~ resource "oci_stack_monitoring_discovery_job" "the_discovery_job" {
        id               = "REDACTED"
      + system_tags      = (known after apply)
        # (10 unchanged attributes hidden)

        # (1 unchanged block hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Note that system_tags (noted above that is triggering the change) is an output attribute not input. Regardless, I added

  lifecycle {
    ignore_changes = [
      system_tags
    ]
  }

…and tried again with the same error/result ("doesn't support update").

Debug Output

Panic Output

Expected Behavior

I expected imported oci_stack_monitoring_discovery_job resources to proper tolerate ongoing apply actions without error and ignore/avoid non-updatable attributes when assessing the need for change. Also, I expected lifecycle ignore_changes to properly override any attribute that is detected as requiring change so as to avoid conflicts when applying to a resource that does not support an update.

Actual Behavior

An imported oci_stack_monitoring_discovery_job resource attempts to update system_tags—which is not an input parameter—when applying the configuration. Even with lifecycle ignore_changes including this attribute name, the apply operation still attempts to affect a change on the resource. Consequently I am unable to proceed without manually removing this resource from my state. Argh!

Steps to Reproduce

  1. terraform apply and all that—see above for details

Important Factoids

References