Skip to content

restapi_object resource is recreated on every apply due to state drift detection #319

@jor2

Description

@jor2

Description

The restapi_object resource is being recreated on every terraform apply, even when there are no changes to the configuration or state. This causes unnecessary HTTP requests and can lead to instability or unexpected behavior in deployments.

This issue appears to be related to how the provider handles state comparison between the API response and the expected state, causing Terraform to always detect a diff.

Expected Behavior

After the initial apply, the resource should remain stable and not be recreated unless there is a change in the relevant input variables or configuration.

Actual Behavior

Every time terraform apply is run, Terraform detects a change and recreates the restapi_object resource, even though nothing has changed in the configuration.

Environment

  • Terraform Provider Version: [Please specify the version you're using]
  • Terraform Version: [Please specify]
  • HTTP Method: PATCH
  • API Response Format: JSON

Example Configuration

resource "restapi_object" "enable_cspm" {
  path         = "/api/v1/cspm/enable"
  data         = jsonencode(var.cspm_config)
  update_method = "PATCH"
  # Other configuration...
}

Can be recreated in this example - https://github.com/terraform-ibm-modules/terraform-ibm-scc-workload-protection/blob/main/examples/advanced/main.tf.

We're currently using lifecycle { ignore_changes = [...] } as a temporary workaround, but this is not ideal as it may mask legitimate changes.

Would appreciate any guidance on proper configuration or if this is a known limitation that's being addressed.

Our issue: terraform-ibm-modules/terraform-ibm-scc-workload-protection#243.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions