-
Notifications
You must be signed in to change notification settings - Fork 11
/
aws_instance.cassandra.tf
42 lines (36 loc) · 1.14 KB
/
aws_instance.cassandra.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
resource "aws_instance" "cassandra" {
# checkov:skip=CKV2_AWS_17: invalid check
# checkov:skip=CKV2_AWS_41: no role required
count = length(var.private_ips)
ami = data.aws_ami.ami.id
instance_type = var.instance_type
monitoring = true
private_ip = var.private_ips[count.index]
ebs_optimized = true
root_block_device {
volume_type = "standard"
volume_size = 100
delete_on_termination = false
encrypted = true
}
vpc_security_group_ids = [aws_security_group.cassandra.id]
subnet_id = var.subnet_ids[count.index]
lifecycle {
create_before_destroy = true
}
user_data = <<HERE
#!/bin/bash
read -d '' CONTENT << EOF
${templatefile("${path.module}/template/cassandra.tmpl", { private_ip = var.private_ips[count.index], seeds = "${var.private_ips[0]},${var.private_ips[2]}" })}
EOF
sudo echo "$CONTENT" > /etc/cassandra/conf/cassandra.yaml
yum update -y
systemctl enable cassandra
service cassandra start
HERE
metadata_options {
http_endpoint = "enabled"
http_tokens = "required"
}
iam_instance_profile = var.iam_instance_profile
}