-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
71 lines (57 loc) · 1.3 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
terraform {
required_providers {
digitalocean = {
source = "digitalocean/digitalocean"
version = "~> 2.0"
}
}
}
provider "digitalocean" {
token = var.do_token
}
data "digitalocean_ssh_key" "ssh_key" {
name = var.ssh_key
}
resource "digitalocean_domain" "domain" {
name = var.domain
}
resource "digitalocean_record" "dns-record" {
domain = digitalocean_domain.domain.name
name = "@"
type = "A"
value = digitalocean_loadbalancer.lb.ip
}
resource "digitalocean_certificate" "lb-cert" {
name = "le-lb-cert"
type = "lets_encrypt"
domains = [digitalocean_domain.domain.name]
}
resource "digitalocean_droplet" "proxy" {
image = "docker-20-04"
name = "botonarioum-proxy-${count.index}"
region = "ams3"
size = "s-1vcpu-1gb"
count = 2
ssh_keys = [
data.digitalocean_ssh_key.ssh_key.id
]
}
resource "digitalocean_loadbalancer" "lb" {
name = "proxy-load-balancer"
region = "ams3"
forwarding_rule {
entry_port = 80
entry_protocol = "http"
target_port = 80
target_protocol = "http"
certificate_id = digitalocean_certificate.lb-cert.id
}
healthcheck {
port = 22
protocol = "tcp"
}
droplet_ids = digitalocean_droplet.proxy.*.id
}
output "droplet_ips" {
value = digitalocean_droplet.proxy.*.id
}