-
Notifications
You must be signed in to change notification settings - Fork 0
/
terraria.tf
68 lines (56 loc) · 1.56 KB
/
terraria.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
variable "do_token" {}
provider "digitalocean" {
token = var.do_token
}
variable "ssh_public_key_file" {
type = string
default = "id_terraria.pub"
description = "A path to an SSH public key file to use"
}
resource "digitalocean_ssh_key" "terraria" {
name = "id_terraria"
public_key = file(var.ssh_public_key_file)
}
resource "digitalocean_droplet" "terraria" {
image = "ubuntu-18-04-x64"
name = "terraria"
region = "sgp1"
size = "s-2vcpu-2gb"
monitoring = true
ssh_keys = [digitalocean_ssh_key.terraria.fingerprint]
user_data = templatefile("cloud-init.yaml", {
ssh_public_key : digitalocean_ssh_key.terraria.public_key,
tshock_service_file : filebase64("tshock.service")
})
}
resource "digitalocean_firewall" "terraria" {
name = "terraria"
droplet_ids = [digitalocean_droplet.terraria.id]
inbound_rule {
protocol = "tcp"
port_range = "22"
source_addresses = ["0.0.0.0/0", "::/0"]
}
inbound_rule {
protocol = "tcp"
port_range = "7777"
source_addresses = ["0.0.0.0/0", "::/0"]
}
outbound_rule {
protocol = "icmp"
destination_addresses = ["0.0.0.0/0", "::/0"]
}
outbound_rule {
protocol = "tcp"
port_range = "1-65535"
destination_addresses = ["0.0.0.0/0", "::/0"]
}
outbound_rule {
protocol = "udp"
port_range = "1-65535"
destination_addresses = ["0.0.0.0/0", "::/0"]
}
}
output "ip" {
value = digitalocean_droplet.terraria.ipv4_address
}