terraform-linters / tflint

A Pluggable Terraform Linter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error on undeclared variables

bendrucker opened this issue · comments

Introduction

When tflint is invoked with variables, it should check that those variables exist in the target module. If they don't, it should error immediately, before invoking any rule plugins. There should be no option to ignore these errors, because they will be fatal to terraform plan and apply.

Proposal

Given the following configuration:

variable "foo" {}

Invoking the following should error:

tflint --var fo=bar

Invoking terraform plan -var fo=bar outputs:

╷
│ Error: Value for undeclared variable
│
│ A variable named "fo" was assigned on the command line, but the root module does not declare a variable of that name. To use this value, add a "variable" block to the configuration.
╵

References