Reputation: 923
I am currently using Terraform to create Azure vdi. My current structure is
main.tf
input.tf
module/ main.tf, var.tf
So whenever a user joined the particular team, I do the following steps Let say user1
Currently I am creating user1 folder with input.tf file and create the resource, Similar when user2 comes I am doing the same process (folder user2).
Is there any better way to handle such requirement ??
Upvotes: 0
Views: 69
Reputation: 238169
There are several possibilities to do that:
Separate config files and folders - you are already doing this, and as the number of users increases, it will be a problem. But it is also most flexible, as you can custom modify TF files for each user separately.
Use a set
of users as an input. So you have one folder and one copy of your TF code, but you maintain set
variable with users. Then use for_each
to create different instance of module
for each user. For example:
variable "users" {
type = set(string)
default = ["user1", "user2"]
}
module "vdi" {
source = "./module"
for_each = var.users
}
Upvotes: 1