IBM-Cloud / terraform-provider-ibm

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

last_operation is reported as change, and can not be applied #3131

Closed dpittner closed 2 years ago

dpittner commented 3 years ago

Community Note

Terraform CLI and Terraform IBM Provider Version

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.

# Copy-paste your Terraform configurations here - for large Terraform configs,
# please share a link to the ZIP file.

Debug Output

Panic Output

Expected Behavior

No change should be reported.

Actual Behavior

No matter if I apply the change, the plan will report as:

ibm_resource_instance.sysdig_instance will be updated in-place

~ resource "ibm_resource_instance" "sysdig_instance" { id = "crn:v1:bluemix:public:sysdig-monitor:us-south:a/...:...::"

Steps to Reproduce

Need an instance of a service created with a backlevel TF provider (e.g. march)

  1. terraform apply

Important Factoids

Current provider version 0.32.1

References

kavya498 commented 3 years ago

@dpittner ,

resource "ibm_resource_instance" "resource_instance" {
  name              = "test"
  service           = "sysdig-monitor"
  plan              = "lite"
  location          = "us-south"
  tags              = ["tag1", "tag2"]
}

Tested with this template.. but we are not able to reproduce the issue.. Can you please share your template?

bhepburn commented 3 years ago

We are seeing similar results after moving from provider version 1.22 -> 1.33.1. Our activity loggers and COS instances are all reporting changes related to last_operation that are not being applied.

  #  ibm_resource_instance.cluster_platform_logger_eu_de will be updated in-place
  ~ resource "ibm_resource_instance" "cluster_platform_logger_eu_de" {
      + last_operation          = (known after apply)
  # ibm_resource_instance.cluster_platform_logger_us_south will be updated in-place
  ~ resource "ibm_resource_instance" "cluster_platform_logger_us_south" {
      + last_operation          = (known after apply)
  # ibm_resource_instance.rhm_commerce_cos will be updated in-place
  ~ resource "ibm_resource_instance" "rhm_commerce_cos" {
     + last_operation          = (known after apply)
  # ibm_resource_instance.rhm_commerce_stage_cos will be updated in-place
  ~ resource "ibm_resource_instance" "rhm_commerce_stage_cos" {
      + last_operation          = (known after apply)
  # ibm_resource_instance.rhm_metering_cos will be updated in-place
  ~ resource "ibm_resource_instance" "rhm_metering_cos" {
      + last_operation          = (known after apply)
  # ibm_resource_instance.rhm_multicloud_provisioning_cos will be updated in-place
  ~ resource "ibm_resource_instance" "rhm_multicloud_provisioning_cos" {
      + last_operation          = (known after apply)
  # ibm_resource_instance.rhm_multicloud_provisioning_cos_sandbox will be updated in-place
  ~ resource "ibm_resource_instance" "rhm_multicloud_provisioning_cos_sandbox" {
      + last_operation          = (known after apply)
  # ibm_resource_instance.rhm_platform_operations_cos will be updated in-place
  ~ resource "ibm_resource_instance" "rhm_platform_operations_cos" {
      + last_operation          = (known after apply)
  # ibm_resource_instance.rhm_seo_cos will be updated in-place
  ~ resource "ibm_resource_instance" "rhm_seo_cos" {
      + last_operation          = (known after apply)

Example template:

resource "ibm_resource_instance" "cluster_platform_logger_us_south" {
  name              = "cluster-platform-logger"
  resource_group_id = data.ibm_resource_group.resource_group.id
  service           = "logdnaat"
  plan              = "14-day"
  location          = "us-south"
}

Our state file shows the last_operation field on the resource as null (I removed most of the data to make sure out instance ID and such is not exposed via the state file):

 {
      "mode": "managed",
      "type": "ibm_resource_instance",
      "name": "cluster_platform_logger_us_south",
      "provider": "provider[\"registry.terraform.io/ibm-cloud/ibm\"]",
      "instances": [
        {
          "schema_version": 0,
          "attributes": {
            ...
            "last_operation": null,
            "location": "us-south",
            "locked": false,
            "name": "cluster-platform-logger",
            "parameters": null,
            "plan": "14-day",
            ...
            "service": "logdnaat",
            "service_endpoints": null,
            "state": "active",
            "status": "active",
            ...
            "type": "service_instance",
            ...
        }
      ]
    }
dpittner commented 3 years ago

@kavya498 please contact me through Slack, I can share some more details there. The thing is that the template will not help. We're only seeing this on resources that have been created a while ago.

pnagleIBM commented 3 years ago

We are seeing the same issue with an AppID instance that we are managing through Terraform.

On every terraform plan there is a change proposed for last_operation even though there have been no changes to the AppID instance.

Presumably, when the AppID service is in production the last_operation will change every time the AppID service is used.

This is what the Terraform plan shows, even though there have been no changes to the App ID service itself

  ~ resource "ibm_resource_instance" "resource_instance" {
        id                      = "crn:v1:bluemix:public:appid:us-south:a/xxxxxxxxxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx::"
      + last_operation          = (known after apply)
        name                    = "appid-instance_name"
        tags                    = [
            "tag1",
            "tag2",
            "tag3",
        ]
        # (32 unchanged attributes hidden)
        # (1 unchanged block hidden)
    }

I tried adding an ignore_changes block, but that didn't work either

lifecycle {
   ignore_changes= [
    last_operation,
    parameters
  ]
}
kavya498 commented 2 years ago

@dpittner ,

There was a bug in 1.22.0 last_operation was marked as optional and hence you are seeing a diff while migrating from 1.22.0.. This is been fixed in 1.24.0 release https://github.com/IBM-Cloud/terraform-provider-ibm/pull/2532 Kindly, let us know if you still see this issue.. Thanks.

kavya498 commented 2 years ago

Closing this issue due to inactivity, Kindly open a new issue and tag this issue, if this issue still persits Thanks..