blob: ddc27ef879fc36f7bc5781fa3c602f1d4a1ce805 (
plain)
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
|
# EC2 KEY PAIR
resource "aws_key_pair" "ec2_key" {
key_name = "${var.prefix}-${var.key_pair_name}"
public_key = file(var.public_key_path)
tags = {
Name = "${var.prefix}-${var.key_pair_name}"
}
}
# THE LATEST AMAZON VYOS 1.4 IMAGE
data "aws_ami" "vyos" {
most_recent = true
owners = ["679593333241"]
filter {
name = "name"
values = ["VyOS 1.4*"]
}
filter {
name = "virtualization-type"
values = ["hvm"]
}
}
# VYOS INSTANCE
resource "aws_instance" "vyos" {
ami = data.aws_ami.vyos.id
instance_type = var.vyos_instance_type
key_name = "${var.prefix}-${var.key_pair_name}"
availability_zone = var.availability_zone
user_data_base64 = base64encode(templatefile("${path.module}/files/vyos_user_data.tfpl", {}))
depends_on = [
aws_network_interface.vyos_public_nic,
aws_network_interface.vyos_private_nic
]
network_interface {
network_interface_id = aws_network_interface.vyos_public_nic.id
device_index = 0
}
network_interface {
network_interface_id = aws_network_interface.vyos_private_nic.id
device_index = 1
}
tags = {
Name = "${var.prefix}-${var.vyos_instance_name}"
}
}
# NETWORK INTERFACES
resource "aws_network_interface" "vyos_public_nic" {
subnet_id = aws_subnet.public_subnet.id
security_groups = [aws_security_group.public_sg.id]
private_ips = [var.vyos_pub_nic_ip_address]
tags = {
Name = "${var.prefix}-${var.vyos_instance_name}-PublicNIC"
}
}
resource "aws_network_interface" "vyos_private_nic" {
subnet_id = aws_subnet.private_subnet.id
security_groups = [aws_security_group.private_sg.id]
private_ips = [var.vyos_priv_nic_address]
source_dest_check = false
tags = {
Name = "${var.prefix}-${var.vyos_instance_name}-PrivateNIC"
}
}
|