-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
Terraform destroy fails "variable ... is nil, but no error was reported" #18197
Comments
It looks like depending on an external data source will cause errors during destroy. Could we make a simple test case to demonstrate this? |
Sure. /module/main.tfresource "null_resource" "execute_command" {
provisioner "local-exec" {
command = "echo hi"
}
}
data "external" "external" {
program = ["jq", "-n", "{\"buckets_list\" : \" \"}"]
depends_on = ["null_resource.execute_command"]
}
output "output" {
value = "${data.external.external.result["buckets_list"]}"
} /main.tfmodule "module" {
source = "module"
}
output "output_f_module" {
value = "${module.module.output}"
} First destroy:[root@localhost bug]# terraform destroy -force
null_resource.execute_command: Refreshing state... (ID: 2995243002782748572)
module.module.null_resource.execute_command: Destroying... (ID: 2995243002782748572)
module.module.null_resource.execute_command: Destruction complete after 0s
Error: Error applying plan:
1 error(s) occurred:
* module.module.output.output: Resource 'data.external.external' does not have attribute 'result' for variable 'data.external.external.result'
Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure. Second destroy:[root@localhost bug]# terraform destroy -force
Error: Error applying plan:
1 error(s) occurred:
* module.module.output.output: variable "external" is nil, but no error was reported
Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure. |
Hi @angelzamir, Thanks for filing the issue. This is essentially the same as #17862, but I'll leave this open as a reminder that it applies to variables too. |
Just encountered this as well, just to add to the report: Versions:
Errors:
|
Running into this as well, when destroying an aws bucket (that was also created by TF). Versions:
The bucket is created in a module, with SSE, and a couple of locals for the bucket name and the SSE kind, and a bucket policy. Creation works as expected, destructions fails every time with the same error as above:
Even though destruction fails, the buckets are actually gone from AWS, so it does work as intended, it errors out for no apparent reason. |
This also affects this version as well:
|
still present in v0.11.10. |
While Without suppression
With suppression
|
Thanks, @aaomoware
|
Yes, this bug exists in v0.11.11. The work around of setting |
happened in v0.11.14. I would not use the export of TF_WARN_OUTPUT_ERRORS as a proper fix. Tbh the error message looks also very un-meaningful (an error which says "no error was reported"?!), and not be able to destroy an empty tf state is really bad
|
I verified that once updated to 0.12, the examples here no longer present an error. |
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. |
Terraform version:
Hello, I'm having trouble with a module, it does the following:
Module's resources are:
Module's outputs are:
The outputs.tf where I call the module is as follows:
Steps:
terraform plan
andterraform apply
steps work wellterraform destroy
at first time fails and the output is:Then when I try to perform
terraform destroy
again, the output changes but error remains:Note: the external data source script always returns a json like:
or with contents on the property
Thanks!
The text was updated successfully, but these errors were encountered: