Loading...
Loading...
<!-- 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. If your issue relates to a specific Terraform provider, please open it in the provider's own repository. The index of providers is at https://github.com/terraform-providers . --> ### Terraform Version <!--- Run `terraform -v` to show the version, and paste the result between the ``` marks below. If you are not running the latest version of Terraform, please try upgrading because your issue may have already been fixed. --> This bug exists from v0.12.0 to v0.12.5. ### Expected Behavior `terraform output` should verify that its argument is a valid identifier and produce an error if not. ``` $ terraform output anything.not.valid Error: Invalid output name An output name must begin with a letter or underscore, and contain only letters, digits, underscores, and dashes. ``` ### Actual Behavior Terraform just tries to look up the given name in the map of outputs and finds nothing, giving the generic error: ``` $ terraform output anything.not.valid The output variable requested could not be found in the state file. If you recently added this to your configuration, be sure to run `terraform apply`, since the state won't be updated with new output variables until that command is run. ``` This is bothersome because it suggests a course of action that won't actually improve the situation. If the root module doesn't have any output values defined at all then the message is instead about that: ``` $ terraform output anything.not.valid The state file either has no outputs defined, or all the defined outputs are empty. Please define an output in your configuration with the `output` keyword and run `terraform refresh` for it to become available. If you are using interpolation, please verify the interpolated value is not empty. You can use the `terraform console` command to assist. ``` While this message is technically correct, it's more important to report that the argument isn't valid because a syntax error on the command line can be indicative of misunderstanding the interface of this command, like running `terraform output output.foo` instead of `terraform output foo`, or of trying to access child module outputs (which are not available) like `terraform output module.foo.output.bar`. ### Steps to Reproduce Run `terraform output invalid.name`. ### References This was originally raised in #22126.
Click on a version to see all relevant bugs
Terraform Integration
Learn more about where this data comes from
Bug Scrub Advisor
Streamline upgrades with automated vendor bug scrubs
BugZero Enterprise
Wish you caught this bug sooner? Get proactive today.