-
Notifications
You must be signed in to change notification settings - Fork 8
/
vpc.tf
90 lines (84 loc) · 2.24 KB
/
vpc.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
data "ibm_is_vpc" "vpc1" {
name = var.VPC
}
//Subnets for primary (ACTIVE) FortiGate
data "ibm_is_subnet" "subnet1" {
identifier = var.SUBNET_1
}
data "ibm_is_subnet" "subnet2" {
identifier = var.SUBNET_2
}
data "ibm_is_subnet" "subnet3" {
identifier = var.SUBNET_3
}
data "ibm_is_subnet" "subnet4" {
identifier = var.SUBNET_4
}
data "ibm_is_security_group" "fgt_security_group" {
name = var.SECURITY_GROUP
}
locals {
active = {
"interface1" = {
ip = var.FGT1_STATIC_IP_PORT1,
subnet = var.SUBNET_1
},
"interface2" = {
ip = var.FGT1_STATIC_IP_PORT2,
subnet = var.SUBNET_2
},
"interface3" = {
ip = var.FGT1_STATIC_IP_PORT3,
subnet = var.SUBNET_3
},
"interface4" = {
ip = var.FGT1_STATIC_IP_PORT4,
subnet = var.SUBNET_4
},
}
passive = {
"interface1" = {
ip = var.FGT2_STATIC_IP_PORT1,
subnet = var.SUBNET_1
},
"interface2" = {
ip = var.FGT2_STATIC_IP_PORT2,
subnet = var.SUBNET_2
},
"interface3" = {
ip = var.FGT2_STATIC_IP_PORT3,
subnet = var.SUBNET_3
},
"interface4" = {
ip = var.FGT2_STATIC_IP_PORT4,
subnet = var.SUBNET_4
},
}
}
resource "ibm_is_virtual_network_interface" "vni-active" {
for_each = local.active
name = "${var.CLUSTER_NAME}-fgt1-${each.key}-${random_string.random_suffix.result}"
allow_ip_spoofing = false
auto_delete = false
enable_infrastructure_nat = true
security_groups = [data.ibm_is_security_group.fgt_security_group.id]
resource_group = data.ibm_resource_group.rg.id
primary_ip {
auto_delete = false
address = each.value.ip
}
subnet = each.value.subnet
}
resource "ibm_is_virtual_network_interface" "vni-passive" {
for_each = local.passive
name = "${var.CLUSTER_NAME}-fgt2-${each.key}-${random_string.random_suffix.result}"
allow_ip_spoofing = false
auto_delete = false
enable_infrastructure_nat = true
resource_group = data.ibm_resource_group.rg.id
primary_ip {
auto_delete = false
address = each.value.ip
}
subnet = each.value.subnet
}