-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhaproxy.tf
50 lines (43 loc) · 1.35 KB
/
haproxy.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
# haproxy lb and web node set up
resource "digitalocean_droplet" "load_balancer" {
count = 2
image = "${var.image_slug}"
name = "${var.project}-lb-${count.index + 1}"
region = "${var.region}"
size = "${var.lb_size}"
private_networking = true
ssh_keys = ["${var.keys}"]
user_data = "${data.template_file.user_data.rendered}"
connection {
user = "root"
type = "ssh"
key_file = "${var.private_key_path}"
timeout = "2m"
}
}
resource "digitalocean_droplet" "web_node" {
count = "${var.node_count}"
image = "${var.image_slug}"
name = "${var.project}-web-${count.index + 1}"
region = "${var.region}"
size = "${var.node_size}"
private_networking = true
ssh_keys = ["${var.keys}"]
user_data = "${data.template_file.user_data.rendered}"
connection {
user = "root"
type = "ssh"
key_file = "${var.private_key_path}"
timeout = "2m"
}
}
data "template_file" "user_data" {
template = "${file("${path.module}/config/cloud-config.yaml")}"
vars {
public_key = "${var.public_key}"
}
}
resource "digitalocean_floating_ip" "fip" {
region = "${var.region}"
droplet_id = "${digitalocean_droplet.load_balancer.0.id}"
}