terraformdevops

Load variable values from the given .tfvars file got an error to many arguments


I run terraform plan commnad with apllo.tfvars file

terraform plan -var-file=apllo.tfvars

│ Error: Too many command line arguments

│ To specify a working directory for the plan, use the global -chdir flag.

my variable.tf

variable "user" {
    type = string
}

# number variable 
variable "age" {
    type = number
}

apllo.tfvars

user = "AWSUSER"
age = 222

output.tf

output "name" {
  value = "hello ${var.user}"
}

output "age" {
    value = "age ${var.age}"
}

Solution

  • If you are using Powershell for running Terraform, try specifying the .tfvar file using single or double quotes, such as:

    terraform plan -var-file="apollo.tfvar"