Terraform

There is a module to create a compute instance. How would you use the module to create three separate instances?

Difficulty: unrated

Source: bregman-arie/devops-exercises by Arie Bregman

Answer

starting with Terraform 0.13, the count meta-argument can be used with modules. So you could use something like this:

module "instances" {
  source = "/some/module/path"

  count = 3
}

You can also use it in outputs vars: value = module.instances[*]