terraform-provider-null icon indicating copy to clipboard operation
terraform-provider-null copied to clipboard

null_resource.bootstrap: doesn't support update

Open hashibot opened this issue 7 years ago • 1 comments

This issue was originally opened by @bernadinm as hashicorp/terraform#13349. It was migrated here as part of the provider split. The original body of the issue is below.


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

hashibot avatar Jun 13 '17 20:06 hashibot

I think the issue is the triggers list, I have this following case:

resource local_file istio_profile {
  content = templatefile("templates/hello.tpl", {
    me = "Emmanuel Gelati"
  //  my = "name"
  })
  filename = "/tmp/hello.txt"
}

resource null_resource install_istio {
  triggers = {
   md5 = filemd5(local_file.istio_profile.filename)
  }
  provisioner "local-exec" {
    command = "echo ${uuid()}"
  }
}

when you are creating the resource it works, but if you add a variable to the local_file resource it will crash:

resource local_file istio_profile {
  content = templatefile("templates/hello.tpl", {
    me = "Emmanuel Gelati"
    my = "name"
  })
  filename = "/tmp/hello.txt"
}

resource null_resource install_istio {
  triggers = {
   md5 = filemd5(local_file.istio_profile.filename)
  }
  provisioner "local-exec" {
    command = "echo ${uuid()}"
  }

  depends_on = [
    local_file.istio_profile
  ]
}

terraform apply --auto-approve terraform apply --auto-approve local_file.istio_profile: Refreshing state... [id=5912e45936c38904cc62f826d1984772b787ee40] null_resource.install_istio: Refreshing state... [id=6097749122409586362] null_resource.install_istio: Destroying... [id=6097749122409586362] null_resource.install_istio: Destruction complete after 0s local_file.istio_profile: Destroying... [id=5912e45936c38904cc62f826d1984772b787ee40] local_file.istio_profile: Destruction complete after 0s local_file.istio_profile: Creating... local_file.istio_profile: Creation complete after 0s [id=121fb6c82b03ef39118463167307b0b3dcd92714]

Error: Provider produced inconsistent final plan

When expanding the plan for null_resource.install_istio to include new values learned so far during apply, provider "registry.terraform.io/-/null" produced an invalid new value for .triggers["md5"]: was cty.StringVal("558eb0e8c5fabaf490b3c4260fadbf20"), but now cty.StringVal("34c9b1e7db965908514bea6761bec8db").

This is a bug in the provider, which should be reported in the provider's own issue tracker.

terraform version Terraform v0.12.29

  • provider.local v1.3.0
  • provider.null v2.1.2

c4m4 avatar Oct 13 '20 20:10 c4m4

Terraform 1.4 will contain a new terraform_data resource which can accept input data of any type, reflections of that data into an unknown output of the same type, and value updates. Terraform prereleases are available if anyone wants to try out the upcoming functionality.

Reference: https://github.com/hashicorp/terraform/blob/main/website/docs/language/resources/terraform-data.mdx

bflad avatar Feb 15 '23 17:02 bflad

Terraform 1.4.0 has been released today with the new terraform_data resource. It should support value updates. If there are any feature requests or bug reports with the terraform_data resource, please create an issue in the Terraform core issue tracker.

bflad avatar Mar 08 '23 20:03 bflad

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.

github-actions[bot] avatar May 23 '24 11:05 github-actions[bot]