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

null_resource.bootstrap: doesn't support update #13349

Closed
bernadinm opened this issue Apr 4, 2017 · 3 comments
Closed

null_resource.bootstrap: doesn't support update #13349

bernadinm opened this issue Apr 4, 2017 · 3 comments

Comments

@bernadinm
Copy link

Hi there,

Thank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests. For general usage questions, please see: https://www.terraform.io/community.html.

Terraform Version

Run terraform -v to show the version. If you are not running the latest version of Terraform, please upgrade because your issue may have already been fixed.

Terraform v0.9.2

Affected Resource(s)

  • null_resource

Terraform Configuration Files

resource "null_resource" "bootstrap" {
  # Changes to any instance of the cluster requires re-provisioning
  triggers {
    cluster_instance_ids = "${aws_instance.bootstrap.id}"
    dcos_version = "${var.dcos_version}"
    dcos_security = "${var.dcos_security}"
    num_of_masters = "${var.num_of_masters}"
  }

lifecycle {
    ignore_changes = ["data.template_file.cluster-name.rendered", "triggers.%", "triggers.dcos_security"]
  }
}

For example I removed dcos_security = "${var.dcos_security}" because I no longer want to track this but I get the error null_resource.bootstrap: doesn't support update

Expected Behavior

What should have happened?

Terraform should have made the change to the state but ignore deploying the change on the actually null_resource and all external dependencies like master and agent.

Actual Behavior

What actually happened?

It gave an error of null_resource.bootstrap: doesn't support update

Steps to Reproduce

  1. terraform apply
@bernadinm
Copy link
Author

I went in terraform.tfstate and modified triggers.% by subtracting 1 from it and I also deleted triggers.dcos_security manually and got the desired result.

Is there a way in terraform to ignore a resource, but continue to modify its state?

@apparentlymart
Copy link
Member

Hi @bernadinm! Sorry for the weird behavior here.

It looks like you've found a funny edge-case in Terraform here. It is true that null_resource doesn't support update, because the intent is that it will re-create itself each time the triggers values change. It looks like you've attempted to override this behavior using ignore_changes.

As you said, the expected behavior in that case is that Terraform would not take any action at all when you make changes to triggers, so it's weird that it ended up trying to run the update function. I'd be curious to see what output terraform plan produces in this case, to see what exactly Terraform thinks it's updating.

With all of that said, I'm curious as to what you are trying to achieve here since ignoring changes to triggers defeats the purpose of the null_resource resource. If you want to ignore changes to this attribute then the better approach would be to not include it in the triggers map in the first place. While the error you received is likely a bug, I expect the fix for that bug would not actually get you the result you were looking for, so I'm curious to learn more context about your use-case in case I can suggest a different way to do it that won't get tripped up by this issue.

@ghost
Copy link

ghost commented Apr 9, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants