Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to ignore changes in read-only attributes #237

Open
mohitatsafe opened this issue Sep 23, 2023 · 2 comments
Open

Add support to ignore changes in read-only attributes #237

mohitatsafe opened this issue Sep 23, 2023 · 2 comments

Comments

@mohitatsafe
Copy link

The state of the "restapi_object" resource changes when there is any change to the read-only attributes like api_data and api_response outside of Terraform, and it shows up in terraform plan/apply output.

For example:

~ resource "restapi_object" "check" {
      ~ api_response = jsonencode(
          ~ {
              ~ check = {
                  ~ lastdownend              = 1695240733 -> 1695314473
                }
            }
        )
    }

I tried to ignore these changes using the lifecycle block's ignore_changes argument as follows, which I think has no effect (see warning below):

resource "restapi_object" "check" {
  lifecycle {
    ignore_changes = [ api_response ]
  }
}

After adding the above changes, I see the following warning in Terraform plan/apply output:

 Warning: Redundant ignore_changes element
│
│   39: resource "restapi_object" "check" {
│
│ Adding an attribute name to ignore_changes tells Terraform to ignore future changes to the argument in
│ configuration after the object has been created, retaining the value originally configured.
│
│ The attribute api_response is decided by the provider alone and therefore there can be no configured value to
│ compare with. Including this attribute in ignore_changes has no effect. Remove the attribute from
│ ignore_changes to quiet this warning.

Versions

Terraform v1.4.6
Mastercard/restapi v1.18.0

@kladiv
Copy link

kladiv commented Nov 24, 2023

+1 how can we overcome this behavior?

@farnoy
Copy link

farnoy commented Nov 27, 2023

Also seeing this. You can't use anything dynamic in ignore_changes, so something like this is impossible:

  lifecycle {
    ignore_changes = [jsondecode(api_response).status]
  }

I don't understand why this provider outputs api_data as a string formatted with Go syntax instead of giving us a decoded object

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants