-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdigitalocean.tf
90 lines (77 loc) · 1.92 KB
/
digitalocean.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
variable "DO" {}
variable "PRIVATE_VPN" {}
variable "PUBLIC_VPN" {}
terraform {
required_providers {
digitalocean = {
source = "digitalocean/digitalocean"
}
}
}
provider "digitalocean" {
token = var.DO
}
resource "digitalocean_ssh_key" "vpn-main" {
name = "DO VPN MAIN"
public_key = file(var.PUBLIC_VPN)
}
resource "digitalocean_droplet" "vpn" {
image = "centos-7-x64"
name = "the-vpn-main"
region = "sfo3"
size = "s-1vcpu-2gb"
monitoring = false
ipv6 = false
private_networking = true
ssh_keys = [digitalocean_ssh_key.vpn-main.fingerprint]
connection {
host = self.ipv4_address
user = "root"
type = "ssh"
private_key = file(var.PRIVATE_VPN)
timeout = "2m"
}
provisioner "remote-exec" {
scripts = [
"bin/vpn-install.sh"
]
}
}
resource "digitalocean_firewall" "wireguard" {
name = "ssh-and-wireguard-current"
droplet_ids = [digitalocean_droplet.vpn.id]
inbound_rule {
protocol = "tcp"
port_range = "22"
source_addresses = ["0.0.0.0/0"]
}
inbound_rule {
protocol = "udp"
port_range = "51194"
source_addresses = ["0.0.0.0/0"]
}
outbound_rule {
protocol = "tcp"
port_range = "443"
destination_addresses = ["0.0.0.0/0", "::/0"]
}
outbound_rule {
protocol = "tcp"
port_range = "80"
destination_addresses = ["0.0.0.0/0", "::/0"]
}
outbound_rule {
protocol = "tcp"
port_range = "53"
destination_addresses = ["0.0.0.0/0", "::/0"]
}
outbound_rule {
protocol = "udp"
port_range = "53"
destination_addresses = ["0.0.0.0/0", "::/0"]
}
outbound_rule {
protocol = "icmp"
destination_addresses = ["0.0.0.0/0", "::/0"]
}
}