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

Improve error message for references (variables) missing resources. #32181

Open
docwhat opened this issue Nov 7, 2022 · 1 comment
Open

Improve error message for references (variables) missing resources. #32181

docwhat opened this issue Nov 7, 2022 · 1 comment

Comments

@docwhat
Copy link

docwhat commented Nov 7, 2022

Terraform Version

❯ terraform version            
Terraform v1.3.4
on darwin_arm64
+ provider registry.terraform.io/hashicorp/google v4.42.0
+ provider registry.terraform.io/hashicorp/google-beta v4.42.0
+ provider registry.terraform.io/hashicorp/null v3.2.0
+ provider registry.terraform.io/hashicorp/random v3.4.3
+ provider registry.terraform.io/hashicorp/time v0.9.0

Terraform Configuration Files

locals {
  org_id = "123456789"
}

module "frobnitz" {
  source = "modules/frobulator"

  name = "zork"
  organization_id = org_id # Note, this should be local.org_id, but I've made a typo.
}

Debug Output

N/A

Expected Behavior

The error message should clearly point me to the problem, ideally with examples and a guess to what the author meant.

Example message:

The reference org_id is not in a valid <resource>.<attribute> form. Did you mean locals.org_id?

Actual Behavior

A reference to a resource type must be followed by at least one attribute access, specifying the resource name.

❯ terraform plan           
╷
│ Error: Invalid reference
│ 
│   on main.tf line 10:
│   10:   organization_id  = org_id
│ 
│ A reference to a resource type must be followed by at least one attribute access, specifying the resource name.
╵

Steps to Reproduce

  1. terraform init
  2. terraform plan

Additional Context

N/A

References

N/A

@docwhat docwhat added bug new new issue not yet triaged labels Nov 7, 2022
@apparentlymart apparentlymart added enhancement config and removed bug new new issue not yet triaged labels Nov 7, 2022
@crw
Copy link
Collaborator

crw commented Nov 9, 2022

Thanks for this request!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants