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
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 the
variableis defined or not.
- Also check if there is mismatch in the
Read More -
- Install terraform on Ubuntu 20.04, CentOS 8, MacOS, Windows 10, Fedora 33, Red hat 8 and Solaris 11
- How to setup Virtual machine on Google Cloud Platform using terraform
- Create EC2 Instance on AWS using terraform
- How to use Terraform Input Variables
- What is variable.tf and terraform.tfvars?
- How to use Terraform locals?
- How to use Terraform output values?
- Understanding terraform count, for_each and for loop?
- Cloud-nuke : How to nuke AWS resources and save additional AWS infrastructure cost?
- How to use Terraform Dynamic blocks?