-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstance-passive.tf
131 lines (108 loc) · 3.96 KB
/
instance-passive.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
// FGTVM active instance
resource "aws_network_interface" "passiveeth0" {
description = "passive-port1"
subnet_id = aws_subnet.publicsubnetaz2.id
private_ips = [var.passiveport1]
}
resource "aws_network_interface" "passiveeth1" {
description = "passive-port2"
subnet_id = aws_subnet.privatesubnetaz2.id
private_ips = [var.passiveport2]
source_dest_check = false
}
resource "aws_network_interface" "passiveeth2" {
description = "passive-port3"
subnet_id = aws_subnet.hasyncsubnetaz2.id
private_ips = [var.passiveport3]
source_dest_check = false
}
resource "aws_network_interface" "passiveeth3" {
description = "passive-port4"
subnet_id = aws_subnet.hamgmtsubnetaz2.id
private_ips = [var.passiveport4]
}
resource "aws_network_interface_sg_attachment" "passivepublicattachment" {
depends_on = [aws_network_interface.passiveeth0]
security_group_id = aws_security_group.public_allow.id
network_interface_id = aws_network_interface.passiveeth0.id
}
resource "aws_network_interface_sg_attachment" "passivemgmtattachment" {
depends_on = [aws_network_interface.passiveeth3]
security_group_id = aws_security_group.public_allow.id
network_interface_id = aws_network_interface.passiveeth3.id
}
resource "aws_network_interface_sg_attachment" "passiveinternalattachment" {
depends_on = [aws_network_interface.passiveeth1]
security_group_id = aws_security_group.allow_all.id
network_interface_id = aws_network_interface.passiveeth1.id
}
resource "aws_network_interface_sg_attachment" "passivehasyncattachment" {
depends_on = [aws_network_interface.passiveeth2]
security_group_id = aws_security_group.allow_all.id
network_interface_id = aws_network_interface.passiveeth2.id
}
resource "aws_instance" "fgtpassive" {
depends_on = [aws_instance.fgtactive]
//it will use region, architect, and license type to decide which ami to use for deployment
ami = var.fgtami[var.region][var.arch][var.license_type]
instance_type = var.size
availability_zone = var.az2
key_name = var.keyname
user_data = chomp(templatefile("${var.bootstrap-passive}", {
type = "${var.license_type}"
license_file = var.licenses[1]
format = "${var.license_format}"
port1_ip = "${var.passiveport1}"
port1_mask = "${var.passiveport1mask}"
port2_ip = "${var.passiveport2}"
port2_mask = "${var.passiveport2mask}"
port3_ip = "${var.passiveport3}"
port3_mask = "${var.passiveport3mask}"
port4_ip = "${var.passiveport4}"
port4_mask = "${var.passiveport4mask}"
active_peerip = "${var.activeport3}"
mgmt_gateway_ip = "${var.passiveport4gateway}"
defaultgwy = "${var.passiveport1gateway}"
privategwy = "${var.passiveport2gateway}"
vpc_ip = cidrhost(var.vpccidr, 0)
vpc_mask = cidrnetmask(var.vpccidr)
adminsport = "${var.adminsport}"
}))
iam_instance_profile = var.iam
root_block_device {
volume_type = "standard"
volume_size = "2"
}
ebs_block_device {
device_name = "/dev/sdb"
volume_size = "30"
volume_type = "standard"
}
network_interface {
network_interface_id = aws_network_interface.passiveeth0.id
device_index = 0
}
network_interface {
network_interface_id = aws_network_interface.passiveeth1.id
device_index = 1
}
network_interface {
network_interface_id = aws_network_interface.passiveeth2.id
device_index = 2
}
network_interface {
network_interface_id = aws_network_interface.passiveeth3.id
device_index = 3
}
# New network interfaces
dynamic "network_interface" {
for_each = aws_network_interface.public_eni_2
content {
network_interface_id = network_interface.value.id
device_index = 4 + network_interface.key
}
}
tags = {
Name = "FortiGateVM Passive"
}
}