forked from rcove/TGW
-
Notifications
You must be signed in to change notification settings - Fork 0
/
subnets.tf
97 lines (76 loc) · 3.13 KB
/
subnets.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
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
##########################################
########### Management VPC ##############
##########################################
# Create subnets to launch our instances into
resource "aws_subnet" "management_subnet" {
vpc_id = "${aws_vpc.management_vpc.id}"
cidr_block = "${cidrsubnet(var.management_cidr_vpc, 8, 1 )}"
availability_zone = "ap-southeast-2a"
tags {
Name = "${var.project_name}-Management"
}
}
########################################
########### Outbound VPC ##############
########################################
data "aws_subnet_ids" "outbound_subnet_ids" {
vpc_id = "${data.aws_vpc.data_outbound_asg_vpc.id}"
tags = {
Name = "Public subnet*"
}
depends_on = ["aws_cloudformation_stack.checkpoint_tgw_cloudformation_stack"]
}
data "aws_subnet" "outbound_subnet" {
count = "${length(data.aws_availability_zones.azs.names)}"
id = "${data.aws_subnet_ids.outbound_subnet_ids.ids[count.index]}"
}
#######################################
########### Inbound VPC ##############
#######################################
# Create subnets to launch our instances into
resource "aws_subnet" "inbound_subnet" {
count = "${length(data.aws_availability_zones.azs.names)}"
availability_zone = "${element(data.aws_availability_zones.azs.names, count.index)}"
vpc_id = "${aws_vpc.inbound_vpc.id}"
cidr_block = "${cidrsubnet(var.inbound_cidr_vpc, 8, count.index+100 )}"
tags {
Name = "${var.project_name}-Inbound-${count.index+1}"
}
}
#####################################
########### Spoke-1 VPC ############
#####################################
# Create a subnet to launch our instances into
resource "aws_subnet" "spoke_1_external_subnet" {
count = "${length(data.aws_availability_zones.azs.names)}"
availability_zone = "${element(data.aws_availability_zones.azs.names, count.index)}"
vpc_id = "${aws_vpc.spoke_1_vpc.id}"
cidr_block = "${cidrsubnet(var.spoke_1_cidr_vpc, 8, count.index+100 )}"
tags {
Name = "${var.project_name}-Spoke-1-External-${count.index+1}"
}
}
######################################
########### Spoke-2 VPC #############
######################################
# Create a subnet to launch our instances into
resource "aws_subnet" "spoke_2_external_subnet" {
vpc_id = "${aws_vpc.spoke_2_vpc.id}"
cidr_block = "${var.spoke_2_cidr_vpc}"
tags {
Name = "${var.project_name}-Spoke-2-External"
}
}
#####################################
########### Spoke-1a VPC ############
#####################################
# Create a subnet to launch our instances into
resource "aws_subnet" "spoke_1a_external_subnet" {
count = "${length(data.aws_availability_zones.azs.names)}"
availability_zone = "${element(data.aws_availability_zones.azs.names, count.index)}"
vpc_id = "${aws_vpc.spoke_1a_vpc.id}"
cidr_block = "${cidrsubnet(var.spoke_1a_cidr_vpc, 8, count.index+100 )}"
tags {
Name = "${var.project_name}-Spoke-1a-External-${count.index+1}"
}
}