-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathnodes.tf
50 lines (40 loc) · 1.4 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
resource "aws_instance" "nodes" {
count = var.nodes_size
ami = local.nodes_ami_id
instance_type = var.nodes_intance_type
associate_public_ip_address = var.nodes_associate_public_ip_address
monitoring = var.nodes_monitoring
subnet_id = var.subnet_id
vpc_security_group_ids = [aws_security_group.loadtest.id]
iam_instance_profile = aws_iam_instance_profile.loadtest.name
user_data_base64 = local.nodes_user_data_base64
#PUBLISHING SCRIPTS AND DATA
key_name = aws_key_pair.loadtest.key_name
connection {
host = coalesce(self.public_ip, self.private_ip)
type = "ssh"
user = var.ssh_user
private_key = tls_private_key.loadtest.private_key_pem
}
provisioner "remote-exec" {
inline = [
"sudo mkdir -p ${var.loadtest_dir_destination} || true",
"sudo chown ${var.ssh_user}:${var.ssh_user} ${var.loadtest_dir_destination} || true"
]
}
provisioner "file" {
destination = var.loadtest_dir_destination
source = var.loadtest_dir_source
}
provisioner "remote-exec" {
inline = [
"echo 'START EXECUTION'",
"while [ ! -f /tmp/finished-setup ]; do echo 'waiting setup to be instaled'; sleep 5; done",
"sleep 10"
]
}
tags = merge(
var.tags,
var.nodes_tags
)
}