-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloud.tf
58 lines (47 loc) · 1.23 KB
/
cloud.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
data "digitalocean_ssh_key" "terraform" {
# Name should match the entry uploaded (can be viewed in the Digital Ocean dashboard)
name = "terraform do"
}
resource "digitalocean_droplet" "vps" {
image = var.image
name = var.name
region = var.region
size = var.server_size
ssh_keys = [
data.digitalocean_ssh_key.terraform.id
]
connection {
host = self.ipv4_address
user = "root"
type = "ssh"
timeout = "2m"
}
user_data = data.cloudinit_config.cloud_config_vps.rendered
}
resource "digitalocean_firewall" "vps" {
name = "only-22-80-and-443"
//lifecycle {
//prevent_destroy = true #protects firewall from being `terraform destroy`ed
//}
droplet_ids = [digitalocean_droplet.vps.id]
inbound_rule {
protocol = "tcp"
port_range = "22"
source_addresses = ["0.0.0.0/0", "::/0"]
}
inbound_rule {
protocol = "tcp"
port_range = "80"
source_addresses = ["0.0.0.0/0", "::/0"]
}
inbound_rule {
protocol = "tcp"
port_range = "443"
source_addresses = ["0.0.0.0/0", "::/0"]
}
outbound_rule {
protocol = "tcp"
port_range = "all"
destination_addresses = ["0.0.0.0/0", "::/0"]
}
}