-
Notifications
You must be signed in to change notification settings - Fork 1
/
variables.tf
56 lines (44 loc) · 1.87 KB
/
variables.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
variable "network_plan" {
description = "${
"A network plan map in the structure generated by the terraformnet/addr-plan/cidr module."} ${
"Each instance of this module creates network objects only for the region associated with its default (unaliased) AWS provider; Instantiate the module multiple times with different providers to populate multiple regions."} ${
"The region names must correspond with AWS region names and the zone names must be lowercase letters that identify valid VPC availability zones in each region."
}"
type = object({
regions = map(object({
cidr_block = string
subnets = map(object({
zone_name = string
cidr_block = string
subnet_name = string
}))
}))
})
}
variable "tags" {
description = "Map of tags to associated with all created objects. At least a Name tag must be present, and its value will be used as a name prefix for some object types this module creates multiple of."
type = map(string)
}
variable "internet_gateway_subnets" {
description = "Set of subnet type names to connect to an internet gateway. Use the empty string to select an anonymous subnet type."
type = set(string)
default = [""] // Anonymous subnet type gets internet gateway by default
}
data "aws_region" "current" {}
locals {
region_name = data.aws_region.current.name
region_plan = var.network_plan.regions[local.region_name]
name_tag_base = var.tags["Name"]
region_subnets = [
for s in local.region_plan.subnets : {
zone_name = s.zone_name
subnet_name = s.subnet_name
cidr_block = s.cidr_block
availability_zone = "${local.region_name}${s.zone_name}"
}
]
subnet_types = sort(toset([
for s in local.region_subnets : s.subnet_name
]))
internet_gateway_subnets = sort(setintersection(var.internet_gateway_subnets, local.subnet_types))
}