0.7.0 rc2
When a variable is missing but accessed in a module, potentially many modules deep, the error message doesn't mention which file has the issue. This makes troubleshooting difficult when using other modules. Could the error reporting be enhanced to always show the file where the error occurred? Here's what I see:
Error applying plan:
1 error(s) occurred:
- 1:3: unknown variable accessed: var.distribution in:
${var.distribution}
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.
I'm seeing this while using a community module, pretty sure it's from somewhere in this chain:
module "ami" {
source = "github.com/terraform-community-modules/tf_aws_ubuntu_ami/ebs"
instance_type = "${var.instance_type}"
region = "${var.region}"
distribution = "trusty"
}
Please list the resources as a list, for example:
any
If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.
# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file. For
# security, you can also encrypt the files using our GPG public key.
Please provider a link to a GitHub Gist containing the complete debug output: https://www.terraform.io/docs/internals/debugging.html. Please do NOT paste the debug output in the issue; just paste a link to the Gist.
If Terraform produced a panic, please provide a link to a GitHub Gist containing the output of the crash.log.
What should have happened?
What actually happened?
Please list the steps required to reproduce the issue, for example:
terraform applyAre there anything atypical about your accounts that we should know? For example: Running in EC2 Classic? Custom version of OpenStack? Tight ACLs?
Are there any other GitHub issues (open or closed) or Pull Requests that should be linked here? For example:
Hi @trauts2! I agree this would be useful, but currently the information is not retained to be able to include in the error message. I think we can do a better job here, and will leave this issue open to track that work.
This ruins building abstractions in terraform :(
I am seeing this issue in combination with another terraform bug (probably the variables are there but nested modules are not being handled correctly). Due to this I cannot track the bug down to the exact module and report the issue.
+1 I seem to be getting this when issuing terraform plan -destroy
Getting this in 0.7.4 as well with terraform destroy; when running terraform apply, everything is fine.
Getting a bunch of these with the latest version 0.7.9 (never was an issue with 0.7.7). They are pretty confusing as everything works correctly.
Also the amount of output shown is really distracting as it means that i need to scroll up thousands and thousands of lines to see the output of the Terraform run.
If these are for debug purposes only, please consider putting them into a file instead, not the console.
Thanks heaps!
Fotis
Hi all! Sorry for the long silence here.
Although some gradual improvements to this have happened since the last comment here, we recently merged in to the master branch a new error output implementation that now includes full context on source locations in errors like this:
Error: Reference to undeclared input variable
on bad-error-messages.tf line 3, in module "ami":
3: instance_type = "${var.instance_type}"
An input variable with the name "instance_type" has not been declared. This
variable can be declared with a variable "instance_type" {} block.
Error: Reference to undeclared input variable
on bad-error-messages.tf line 4, in module "ami":
4: region = "${var.region}"
An input variable with the name "region" has not been declared. This variable
can be declared with a variable "region" {} block.
This will be included in the forthcoming v0.12.0 release of Terraform. Since this change is already merged, I'm going to close this out now.
Thanks @apparentlymart and all the Terraform team!
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.
Most helpful comment
Getting a bunch of these with the latest version 0.7.9 (never was an issue with 0.7.7). They are pretty confusing as everything works correctly.
Also the amount of output shown is really distracting as it means that i need to scroll up thousands and thousands of lines to see the output of the Terraform run.
If these are for debug purposes only, please consider putting them into a file instead, not the console.
Thanks heaps!
Fotis