-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.tf
93 lines (86 loc) · 2.39 KB
/
main.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
91
92
93
#************ Tyrannosaurus Rekt (Liquidation Bot)************** #
#
resource "digitalocean_droplet" "fs-trex" {
count = 1
image = "ubuntu-18-04-x64"
name = "fs-trex${count.index}"
region = var.region
size = var.size
ssh_keys = [
"${var.ssh_fingerprint}"
]
connection {
user = "root"
type = "ssh"
private_key = "${file(var.pvt_key)}"
timeout = "2m"
host = self.ipv4_address
}
provisioner "remote-exec" {
inline = [
"export PATH=$PATH:/usr/bin",
"apt update",
"apt install -y git",
"curl -sSL https://get.docker.com/ | sh",
"curl -L 'https://github.com/docker/compose/releases/download/1.25.4/docker-compose-Linux-x86_64' -o /usr/local/bin/docker-compose",
"chmod +x /usr/local/bin/docker-compose",
"git clone https://github.com/futureswap/liquidation_bot.git",
"echo 'PRIVATE_KEY=${var.trex_wallet_private_key}' > /root/liquidation_bot/.env",
"cd liquidation_bot",
"docker-compose up --detach"
]
on_failure = continue
}
}
#************ ELK Rekt (Internal Exchange Bot)************** #
#
resource "digitalocean_droplet" "fs-elk" {
count = 1
image = "ubuntu-18-04-x64"
name = "fs-elk${count.index}"
region = var.region
size = "s-1vcpu-1gb"
ssh_keys = [
"${var.ssh_fingerprint}"
]
connection {
user = "root"
type = "ssh"
private_key = "${file(var.pvt_key)}"
timeout = "2m"
host = self.ipv4_address
}
provisioner "remote-exec" {
inline = [
"export PATH=$PATH:/usr/bin",
"apt update",
"curl -sL https://deb.nodesource.com/setup_13.x | bash -",
"apt-get install -y nodejs",
"git clone https://github.com/futureswap/internal_exchange_bot.git",
"echo 'PRIVATE_KEY=${var.elk_wallet_private_key}' > /root/internal_exchange_bot/.env",
"cd internal_exchange_bot",
"npm install"
]
on_failure = continue
}
}
# T-Rex CF Domain
#
resource "cloudflare_record" "fs-trex" {
count = 1
zone_id = var.cf_zone_id
name = "fs-trex${count.index}"
value = "${digitalocean_droplet.fs-trex[count.index].ipv4_address}"
type = "A"
ttl = 1
}
# ELK CF Domain
#
resource "cloudflare_record" "fs-elk" {
count = 1
zone_id = var.cf_zone_id
name = "fs-elk${count.index}"
value = "${digitalocean_droplet.fs-elk[count.index].ipv4_address}"
type = "A"
ttl = 1
}