Terraform tests giving warning "Variable referenced without definition"
👓 What did you see?
When modules created using the terraform-module-boilerplate run the terraform tests, the following warnings are appearing in the output:
╷
│ Warning: Variable referenced without definition
│
│ on tests/main.tftest.hcl line 21, in run "test_deployment":
│ 21: project = var.project
│
│ Variable "project" was referenced without providing a definition.
│ Referencing undefined variables within Terraform Test files is deprecated,
│ please add a `variable` block into the relevant test file to provide a
│ definition for the variable. This will become required in future versions
│ of Terraform.
│
│ (and one more similar warning elsewhere)
╵
tests/main.tftest.hcl... tearing down
╷
│ Warning: Variable referenced without definition
│
│ on tests/main.tftest.hcl line 21, in run "test_deployment":
│ 21: project = var.project
│
│ Variable "project" was referenced without providing a definition.
│ Referencing undefined variables within Terraform Test files is deprecated,
│ please add a `variable` block into the relevant test file to provide a
│ definition for the variable. This will become required in future versions
│ of Terraform.
│
│ (and one more similar warning elsewhere)
╵
tests/main.tftest.hcl... pass
╷
│ Warning: Variable referenced without definition
│
│ on tests/main.tftest.hcl line 2, in provider "google":
│ 2: default_labels = var.default_labels
│
│ Variable "default_labels" was referenced without providing a definition.
│ Referencing undefined variables within Terraform Test files is deprecated,
│ please add a `variable` block into the relevant test file to provide a
│ definition for the variable. This will become required in future versions
│ of Terraform.
│
│ (and 4 more similar warnings elsewhere)
╵
✅ What did you expect to see?
The tests should run cleanly without warnings.
💻 Where does this happen?
This is happening on all Terraform modules created from the boilerplate.
🔬 How do I recreate this?
📚 Any additional information?
Edited by Roy Harrington