Terraform: providing list input values ​​from the command line?

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

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

      

or maybe

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

      

+3


source to share


1 answer


I managed to get it to work like this:

1) Your variable file should look like this:

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

      

2) Then run the apply command as follows:



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

I hope this helps

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

+1


source







All Articles