Terraform - Resolve "input variable is not set"
                
            
            
            
             
            
            
                           
                
            
            
            
                
    
    
     
            
                
                    by
                    Jeremy Canfield  |  
                    Updated: August 01 2023
                    
                          |  Terraform articles
                    
                    
                    
                
            
            Let's say you define an input variable that does not have a default value.
variable "foo" {
  type = string
}
Since the "foo" variable does not have a default value, the terraform refresh, terraform output, terrafrom plan, and terraform apply commands should prompt you to enter a value for the foo variable.
var.foo
  Enter a value:
However, let's say you use the -input=false option.
terraform refresh -input=false
This should cause the following error to be returned.
~]$ terraform refresh -input=false
╷
│ Error: No value for required variable
│
│   on variables.tf line 13:
│   13: variable "foo" {
│
│ The root module input variable "foo" is not set, and has no default value. Use a -var or -var-file command line argument to provide a value for this variable.
This can be resolved by not using the -input=false option, or using the -var or -var-file options.
Did you find this article helpful?
If so, consider buying me a coffee over at 