--
You received this message because you are subscribed to the Google Groups "Terraform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to terraform-too...@googlegroups.com.
To post to this group, send email to terrafo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/166ef031-10c6-42c0-8529-9c4c513b69ec%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I have nearly identical infrastructure in development, test, staging, and production environments. I'm assuming it's a common configuration pattern to have to support multiple, nearly identical, environments. Often the differences are rather small, e.g. host count, AWS account, hosted zone id, etc.As it is currently, I've created a terraform configuration directory per-env, but a good bit of duplicity will ensue if I continue down this path. Joel in IRC recommended abstracting the commonalities to a module. Is that a normal approach? Is that the long term approach for sanely configuring multiple environments? Does anyone have an example set of configuration that is used for multiple environments?
~/repos/terraform (master●●)$ tree .├── dev│ ├── main.tf│ ├── provider.tf│ ├── terraform.tfstate│ ├── terraform.tfstate.backup│ ├── terraform.tfvars -> ../terraform.tfvars│ └── variables.tf -> ../variables.tf├── int│ ├── main.tf│ ├── provider.tf│ ├── terraform.tfvars -> ../terraform.tfvars│ └── variables.tf -> ../variables.tf├── modules│ └── upload│ ├── main.tf│ └── variables.tf├── terraform.tfvars├── user_data.txt└── variables.tf
4 directories, 15 files~/repos/terraform (master●●)$ cat dev/main.tf
// variables that vary by env are kept local to env dirvariable "region" { description = "AWS region to host your network" default = "us-east-1"}
variable "domain" { default = "sub.domain.tld"}
module "upload" { source = "../modules/upload" region = "${var.region}" instance_type = "m3.medium" key_name = "${lookup(var.ec2_keys, var.region)}" zone_id = "${lookup(var.hosted_zone_ids, var.domain)}" ami = "${lookup(var.amis, var.region)}" environment = "dev" domain = "${var.domain}" number_of_instances = "3"}