-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathscylladb-instances.tf
74 lines (61 loc) · 2.06 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
66
67
68
69
70
71
72
73
74
resource "tls_private_key" "private_key" {
algorithm = "RSA"
rsa_bits = 4096
}
resource "aws_key_pair" "generated_key" {
key_name = "ScyllaDB-Enterprise-DEMO-key"
public_key = tls_private_key.private_key.public_key_openssh
}
resource "aws_instance" "scylladb_seed" {
count = 1
ami = data.aws_ami.scylla_ami.id
instance_type = var.scylla_node_type
key_name = aws_key_pair.generated_key.key_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}",
},
"start_scylla_on_first_boot": true
}
EOF
}
resource "aws_instance" "scylladb_nonseeds" {
count = var.scylla_node_count - 1
ami = data.aws_ami.scylla_ami.id
instance_type = var.scylla_node_type
key_name = aws_key_pair.generated_key.key_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}",
"start_scylla_on_first_boot": true
"seed_provider": [{"class_name": "org.apache.cassandra.locator.SimpleSeedProvider",
"parameters": [{"seeds": "${aws_instance.scylladb_seed[0].private_ip}"}]}]
},
}
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)])
}