-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnodes.tf
52 lines (46 loc) · 1.52 KB
/
nodes.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
# Setting up volume
resource "digitalocean_volume" "storage_volume" {
count = "${var.hp_count}"
name = "${var.project}-volume-${count.index + 1}"
region = "${var.region}"
size = "${var.volume_size}"
}
resource "digitalocean_droplet" "honey_pot" {
count = "${var.hp_count}"
image = "${var.hp_image}"
name = "${var.project}-honeypot-${count.index + 1}"
region = "${var.region}"
size = "${var.hp_size}"
private_networking = true
ssh_keys = ["${split(",",var.keys)}"]
user_data = "${data.template_file.user_data.rendered}"
volume_ids = ["${element(digitalocean_volume.storage_volume.*.id, count.index)}"]
connection {
user = "root"
type = "ssh"
key_file = "${var.private_key_path}"
timeout = "2m"
}
}
resource "digitalocean_droplet" "probe" {
count = "${var.probe_count}"
image = "${var.probe_image}"
name = "${var.project}-probe-${count.index + 1}"
region = "${var.region}"
size = "${var.probe_size}"
private_networking = true
ssh_keys = ["${split(",",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}"
}
}