Skip to content

Commit 5fc69f2

Browse files
author
Achille Roussel
committed
default AZ for the region
1 parent 50c4cde commit 5fc69f2

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

main.tf

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,25 @@ variable "external_subnets" {
5656
}
5757

5858
variable "availability_zones" {
59-
description = "a comma-separated list of availability zones"
60-
default = "us-west-2a,us-west-2b,us-west-2c"
59+
description = "a comma-separated list of availability zones, defaults to all AZ of the region"
60+
default = ""
61+
}
62+
63+
variable "default_availability_zones" {
64+
description = "a mapping of the default availability zones for each AWS region"
65+
66+
default = {
67+
us-east-1 = "us-east-1a,us-east-1b,us-east-1c,us-east-1e"
68+
us-west-1 = "us-west-1a,us-west-1b"
69+
us-west-2 = "us-west-2a,us-west-2b,us-west-2c"
70+
eu-west-1 = "eu-west-1a,eu-west-1b,eu-west-1c"
71+
eu-central-1 = "eu-central-1a,eu-central-1b"
72+
ap-southeast-1 = "ap-southeast-1a,ap-southeast-1b"
73+
ap-southeast-2 = "ap-southeast-2a,ap-southeast-2b,ap-southeast-2c"
74+
ap-northeast-1 = "ap-northeast-1a,ap-northeast-1c"
75+
ap-northeast-2 = "ap-northeast-2a,ap-northeast-2c"
76+
sa-east-1 = "sa-east-1a,sa-east-1b,sa-east-1c"
77+
}
6178
}
6279

6380
variable "ecs_instance_type" {
@@ -132,16 +149,13 @@ variable "default_ecs_ami" {
132149
}
133150

134151
module "vpc" {
135-
source = "./vpc"
136-
name = "${var.name}"
137-
138-
cidr = "${var.cidr}"
139-
internal_subnets = "${var.internal_subnets}"
140-
external_subnets = "${var.external_subnets}"
141-
142-
availability_zones = "${var.availability_zones}"
143-
144-
environment = "${var.environment}"
152+
source = "./vpc"
153+
name = "${var.name}"
154+
cidr = "${var.cidr}"
155+
internal_subnets = "${var.internal_subnets}"
156+
external_subnets = "${var.external_subnets}"
157+
availability_zones = "${coalesce(var.availability_zones, lookup(var.default_availability_zones, var.region))}"
158+
environment = "${var.environment}"
145159
}
146160

147161
module "security_groups" {

0 commit comments

Comments
 (0)