https://www.terraform.io/

terraform apply input array parameters

variables.tf

1
2
3
4
variable "brands" {
type = "list"
default = []
}

To pass in variable via command line

1
$ terraform apply -var='brands=["apple","samsung","huawei"]'
References:

Run terraform directly from docker container

Pull the image

1
$ docker pull hashicorp/terraform:light

Then run it this way

1
2
$ cd /path/to/tf_scripts
$ docker run -i -t -v "$PWD:/tf_scripts" hashicorp/terraform:light plan /tf_scripts/
References:

Run terraform in detached state

Can be used for debugging

1
2
$ docker run -d -it --name terraform --entrypoint "/usr/bin/tail" -v $(pwd):/workspace -w /workspace hashicorp/terraform:${TAG} sh tail -f /dev/null
$ docker exec -it terraform sh

To remove the container

1
2
$ docker stop terraform
$ docker rm terraform
References: