Newer
Older
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#
# Create the VPC
# using directions from https://clouddocs.f5.com/cloud/public/v1/aws/AWS_multiNIC.html
#
module "vpc_min" {
count = var.create_min && !var.create_max ? 1 : 0
source = "terraform-aws-modules/vpc/aws"
name = format("%s-min-%s", var.tags.prefix, var.tags.random)
cidr = var.aws_vpc_parameters.cidr
enable_dns_hostnames = true
enable_dns_support = true
azs = var.aws_vpc_parameters.azs
# vpc public subnet used for external interface
public_subnets = [for num in range(length(var.aws_vpc_parameters.azs)) :
cidrsubnet(var.aws_vpc_parameters.cidr, 8, num + var.external_subnet_offset)
]
# vpc private subnet used for internal
private_subnets = [
for num in range(length(var.aws_vpc_parameters.azs)) :
cidrsubnet(var.aws_vpc_parameters.cidr, 8, num + var.internal_subnet_offset)
]
enable_nat_gateway = true
# using the database subnet method since it allows a public route
database_subnets = [
for num in range(length(var.aws_vpc_parameters.azs)) :
cidrsubnet(var.aws_vpc_parameters.cidr, 8, num + var.management_subnet_offset)
]
create_database_subnet_group = true
create_database_subnet_route_table = true
create_database_internet_gateway_route = true
tags = {
Name = format("%s-min-%s", var.tags.prefix, var.tags.random)
Terraform = "true"
Environment = var.tags.environment
}
}
module "vpc_max_public" {
count = var.create_max ? 1 : 0
source = "terraform-aws-modules/vpc/aws"
name = format("%s-max-%s", var.tags.prefix, var.tags.random)
cidr = var.aws_vpc_parameters.cidr
enable_dns_hostnames = true
enable_dns_support = true
azs = var.aws_vpc_parameters.azs
# vpc public subnet used for external interface
public_subnets = [for num in range(length(var.aws_vpc_parameters.azs)) :
cidrsubnet(var.aws_vpc_parameters.cidr, 8, num + var.external_subnet_offset)
]
tags = {
Name = format("%s-max-public-%s", var.tags.prefix, var.tags.random)
Terraform = "true"
Environment = var.tags.environment
}
}
module "vpc_max_private" {
count = var.create_max ? 1 : 0
source = "terraform-aws-modules/vpc/aws"
name = format("%s-max-%s", var.tags.prefix, var.tags.random)
cidr = var.aws_vpc_parameters.cidr
enable_dns_hostnames = true
enable_dns_support = true
azs = var.aws_vpc_parameters.azs
# vpc private subnet used for internal
private_subnets = [
for num in range(length(var.aws_vpc_parameters.azs)) :
cidrsubnet(var.aws_vpc_parameters.cidr, 8, num + var.internal_subnet_offset)
]
tags = {
Name = format("%s-max-private-%s", var.tags.prefix, var.tags.random)
Terraform = "true"
Environment = var.tags.environment
}
}
module "vpc_max_management" {
count = var.create_max ? 1 : 0
source = "terraform-aws-modules/vpc/aws"
name = format("%s-max-%s", var.tags.prefix, var.tags.random)
cidr = var.aws_vpc_parameters.cidr
enable_dns_hostnames = true
enable_dns_support = true
azs = var.aws_vpc_parameters.azs
public_subnets = [for num in range(length(var.aws_vpc_parameters.azs)) :
cidrsubnet(var.aws_vpc_parameters.cidr, 8, num + var.management_subnet_offset)
]
tags = {
Name = format("%s-max-mgmt-%s", var.tags.prefix, var.tags.random)
Terraform = "true"
Environment = var.tags.environment
}
}