terraform
Terraform failing with Invalid for_each argument / The given “for_each” argument value is unsuitable
Explanation This error is often caused by passing a list to for_each, but for_each only works with unordered data-types, i.e. with sets and maps. Solution The resolution depends on the situation. List of strings If the list is just a list of strings, the easiest fix is to add a toset()-call to transform the list … Read more
How to reference a resource created by a Terraform module
Since you’re using a module, you need to change the format of the reference slightly. Module Outputs use the form ${module.<module name>.<output name>}. It’s also important to note, you can only reference values outputted from a module. In your specific case, this would become ${module.vpc.vpc_id} based on the VPC Module’s Outputs.
How to append to a list in Terraform?
You can use the concat function for this. Expanding upon the example in your question: variable “foo” { type = “list” default = [ 1,2,3 ] } # assume a value of 4 of type number is the additional value to be appended resource “bar_type” “bar” { bar_field = “${concat(var.foo, [4])}” } which appends to … Read more
Terraform will damage your computer on macOS Intel
Looks like the rotated signing key was the issue for me too (and probably every mac user of terraform) Reinstall with brew solved this for me. I keep previous versions in case I need them so I have a symlink to the current version. Remove that first which terraform #remove my symlink so brew can … Read more
Getting an Environment Variable in Terraform configuration?
I would try something more like this, which seems closer to the documentation. variable “UN” { type = string } variable “PW” { type = string } resource “google_container_cluster” “primary” { name = “marcellus-wallace” zone = “us-central1-a” initial_node_count = 3 master_auth { username = var.UN password = var.PW } node_config { oauth_scopes = [ “https://www.googleapis.com/auth/compute”, … Read more
Experimenting Locally with Terraform
Terraform supports a bunch of providers, but the vast majority of them are public cloud based. However, you could set up a local VMware vSphere cluster and use the vSphere provider to interact with that to get you going. There’s also a provider for OpenStack if you want to set up an OpenStack cluster. Alternatively … Read more