How to fix error value for undeclared variable a variable named was assigned on the command line?
In this article we are going to fix
Error Value for undeclared variable A variable named 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
The above mentioned issue very common with terraform and 99% of the case you might have forgotten -
- Either declaring variable
- Or did not create a
variable.tffile.
Here is the pic which might help you to understand this issue visually -

How to fix?
- Look for the
variablewhich you are trying to create. - Create that
variableinside your terraform file. - Check your
variable.tfand see if thevariableis defined or not. - Also check if there is mismatch in the
variablename.
Read More - Terragrunt -