-
Notifications
You must be signed in to change notification settings - Fork 0
/
bastion.tf
60 lines (51 loc) · 1.58 KB
/
bastion.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
resource "digitalocean_droplet" "bastion" {
image = var.image
name = "${var.identifier}-bastion"
region = var.region
size = var.bastion_size
ssh_keys = concat(var.ssh_keys, [digitalocean_ssh_key.terraform_cloud.fingerprint])
vpc_uuid = var.vpc_id
tags = [digitalocean_tag.db_access.id, digitalocean_tag.instellar_bastion.id]
connection {
type = "ssh"
user = "root"
host = self.ipv4_address
private_key = tls_private_key.terraform_cloud.private_key_openssh
}
provisioner "file" {
content = tls_private_key.bastion_key.private_key_openssh
destination = "/root/.ssh/id_ed25519"
}
provisioner "remote-exec" {
inline = [
"chmod 600 /root/.ssh/id_ed25519"
]
}
}
# tfsec:ignore:digitalocean-compute-no-public-egress
resource "digitalocean_firewall" "bastion_firewall" {
name = "${var.identifier}-instellar-bastion"
droplet_ids = digitalocean_droplet.bastion[*].id
# SSH from any where
# tfsec:ignore:digitalocean-compute-no-public-ingress[port_range=22]
inbound_rule {
protocol = "tcp"
port_range = "22"
source_addresses = ["0.0.0.0/0", "::/0"]
}
# Enable all outbound traffic
outbound_rule {
protocol = "icmp"
destination_addresses = ["0.0.0.0/0", "::/0"]
}
outbound_rule {
protocol = "udp"
port_range = "1-65535"
destination_addresses = ["0.0.0.0/0", "::/0"]
}
outbound_rule {
protocol = "tcp"
port_range = "1-65535"
destination_addresses = ["0.0.0.0/0", "::/0"]
}
}