-
Notifications
You must be signed in to change notification settings - Fork 8
/
scylladb-instances.tf
65 lines (54 loc) · 1.83 KB
/
scylladb-instances.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
resource "aws_instance" "scylladb_seed" {
count = 1
ami = var.scylla_ami_id
instance_type = var.scylla_instance_type
key_name = var.aws_key_pair_name
subnet_id = element(aws_subnet.public_subnet.*.id, count.index)
security_groups = [aws_security_group.sg.id]
tags = {
Name = "${var.custom_name}-ScyllaDBInstance-Seed-${count.index}"
"Project" = "${var.custom_name}"
"Type" = "Scylla"
"Group" = "Seed"
}
user_data = <<EOF
{
"scylla_yaml": {
"cluster_name": "${var.custom_name}",
"internode_compression": "all",
},
"start_scylla_on_first_boot": true
}
EOF
}
resource "aws_instance" "scylladb_nonseeds" {
count = var.scylla_node_count - 1
ami = var.scylla_ami_id
instance_type = var.scylla_instance_type
key_name = var.aws_key_pair_name
subnet_id = element(aws_subnet.public_subnet.*.id, count.index)
security_groups = [aws_security_group.sg.id]
tags = {
Name = "${var.custom_name}-ScyllaDBInstance-${count.index}"
"Project" = "${var.custom_name}"
"Type" = "Scylla"
"Group" = "NonSeed"
}
user_data = <<EOF
{
"scylla_yaml": {
"cluster_name": "${var.custom_name}",
"seed_provider": [{"class_name": "org.apache.cassandra.locator.SimpleSeedProvider",
"parameters": [{"seeds": "${aws_instance.scylladb_seed[0].private_ip}"}]}]
},
"start_scylla_on_first_boot": true
}
EOF
depends_on = [aws_instance.scylladb_seed]
}
output "scylla_ips" {
value = join(",", [join(",", aws_instance.scylladb_seed.*.private_ip), join(",", aws_instance.scylladb_nonseeds.*.private_ip)])
}
output "scylla_public_ips" {
value = join(",", [join(",", aws_instance.scylladb_seed.*.public_ip), join(",", aws_instance.scylladb_nonseeds.*.public_ip)])
}