terraform

Terraform: Providing list input values from command line?


Is there a way to provide list values from the command line? There is variable merging for maps, but it doesn't seem to be working for lists. I was hoping for something like, but no luck... Thanks

terraform apply -var "listvar=abc1" -var "listvar=abc2"

or possibly

terraform apply -var "listvar=[abc1, abc2]"

Solution

  • I was able to get this to work as follow:

    1) Your variable file should reflect as follow:

     variable "listvar" {
          description = "some varaible to list"
          type = "list"
        }
    

    2) Then run the apply command as exactly as follow:

    terraform apply -var 'listvar=["abc1", "abc2", "abc3"]'

    I hope that helps

    https://www.terraform.io/intro/getting-started/variables.html