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

[Feature Request] - Option to ignore allowed_bandwidth/kvm properties changes #460

Open
thehunmonkgroup opened this issue Jan 20, 2024 · 9 comments
Assignees

Comments

@thehunmonkgroup
Copy link

Describe the bug
When upgrading Terraform versions, and running terraform apply on a Vultr instance that has had no changes to its configuration, the allowed_bandwidth and kvm properties are reported as having changed outside of Terraform.

Running terraform apply again after the upgrade results in No changes as expected, but having to manually confirm these erroneous changes across many servers is a bit tedious :)

To Reproduce
Steps to reproduce the behavior:

  1. Install latest version of provider (2.19.0 as of this writing)
  2. Upgrade Terraform
  3. Run terraform init -reconfigure -upgrade && terraform apply on an existing Vultr instance which has not had any configuration changes since last terraform apply
  4. Note the following output or similar:
Note: Objects have changed outside of Terraform

Terraform detected the following changes made outside of Terraform since the last "terraform apply" which may have affected this plan:

  # module.role.module.instance-vultr.vultr_instance.gw[0] has changed
  ~ resource "vultr_instance" "gw" {
      ~ allowed_bandwidth   = 699 -> 723
        id                  = "xxxxxxxxxxxxxxxxx"
      ~ kvm                 = "https://my.vultr.com/subs/vps/novnc/api.php?data=xxxxxxxx" -> "https://my.vultr.com/subs/vps/novnc/api.php?data=xxxxxxx"
        tags                = []
        # (27 unchanged attributes hidden)
    }

Expected behavior

No changes should be reported.

@thehunmonkgroup
Copy link
Author

These spurious changes appear to no longer happen once I got to Terraform v1.3.10.

Guessing this is an incompatibility between the newer version of the provider and older versions of Terraform.

I'll leave the issue open in case you want to adjust the provider for backwards compat.

@thehunmonkgroup
Copy link
Author

It appears I spoke too soon, the behavior appeared again at Terraform v1.4.7.

@optik-aper
Copy link
Member

@thehunmonkgroup Thanks for the report. Both of those are "computed" fields so aside from removing them, I'm not sure of a way to avoid these periodic updates. But, for your case, you could use the lifecycle argument in your terraform config to ensure that these changes stop interrupting your workflow.

@thehunmonkgroup
Copy link
Author

@optik-aper thanks for the sensible workaround

@thehunmonkgroup
Copy link
Author

But, for your case, you could use the lifecycle argument in your terraform config to ensure that these changes stop interrupting your workflow.

Sadly, this does not work, adding this to my resource config:

  lifecycle {
    ignore_changes = [
      allowed_bandwidth,
      kvm,
    ]
  }

Produces these errors:

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.\n\nThe attribute allowed_bandwidth 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.
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.\n\nThe attribute kvm 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.

I should also add that these are not 'periodic' updates -- they seem to happen quite a bit.

Is there any real value in storing these in the Terraform state? As far as I understand, they are computed values and cannot be controlled by the user, nor managed by Terraform. Can't they be suppressed from inclusion in the state?

@optik-aper
Copy link
Member

@thehunmonkgroup Oh shoot, you're right. It's only for changes you don't want to sync up to the remote for whatever reason. I'm looking at other options but, ultimately, I don't think removing the attributes is the correct course since some folks might be using them as values for other operations. There are a lot of purely computed values in the data which don't change as often, so are not as bothersome, but are still important for some use-cases. In general, the idea is to expose anything that the API returns for the sake of consistency.

If you know that your configuration hasn't changed when you're applying these changes, perhaps using the -auto-approve flag would make this less annoying? It should automatically apply the remote changes to your tfstate without asking you to approve. The danger there is if you accidentally auto-approve a forced replacement, you could inadvertently wipe out a resource with one command and no warning.

@thehunmonkgroup
Copy link
Author

If you know that your configuration hasn't changed when you're applying these changes, perhaps using the -auto-approve flag would make this less annoying? It should automatically apply the remote changes to your tfstate without asking you to approve. The danger there is if you accidentally auto-approve a forced replacement, you could inadvertently wipe out a resource with one command and no warning.

Yeah, I'm not quite that much of a cowboy ;)

Maybe add a plugin specific arg that allows users to list values they DON'T want stored in the state?

@optik-aper optik-aper self-assigned this Feb 5, 2024
@optik-aper optik-aper added enhancement and removed bug labels Feb 5, 2024
@optik-aper optik-aper changed the title [BUG] - allowed_bandwidth/kvm properties marked as changed on Terraform version upgrade [Feature Request] - Option to ignore allowed_bandwidth/kvm properties changes Feb 5, 2024
@optik-aper
Copy link
Member

@optik-aper
Copy link
Member

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

No branches or pull requests

2 participants