-
Notifications
You must be signed in to change notification settings - Fork 1
/
splunk.tf
72 lines (56 loc) · 1.87 KB
/
splunk.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
resource "aws_instance" "splunk_ent" {
ami = var.aws_ami_id == "" ? data.aws_ami.splunk_ent.id : var.aws_ami_id
instance_type = var.splunk_server_instance_type
key_name = var.aws_key_pair_name
subnet_id = aws_subnet.splunk_subnet_a.id
private_ip = "172.31.54.11"
vpc_security_group_ids = [aws_security_group.splunk_ent.id]
ebs_optimized = true
root_block_device {
delete_on_termination = true
volume_size = 100
volume_type = "gp2"
}
tags = merge(
local.common_tags,
{
"Name" = "splunk-ent-${random_id.random.hex}"
}
)
connection {
user = var.aws_ubuntu_image_user
private_key = file(var.aws_key_pair_file)
host = self.public_ip
}
provisioner "file" {
destination = "/tmp/ssl_cert"
content = var.splunk_custom_ssl_cert_chain
}
provisioner "file" {
destination = "/tmp/ssl_key"
content = var.splunk_custom_ssl_private_key
}
provisioner "local-exec" {
// Clean up local known_hosts in case we get a re-used public IP
command = "ssh-keygen -R ${aws_instance.splunk_ent.public_ip}"
}
provisioner "local-exec" {
// Write ssh key for Automate server to local known_hosts so we can scp automate-credentials.toml in data.external.a2_secrets
command = "ssh-keyscan -t ecdsa ${aws_instance.splunk_ent.public_ip} >> ~/.ssh/known_hosts"
}
provisioner "file" {
content = templatefile("${path.module}/templates/linux_node_user_data.sh.tpl", { splunk_password = var.splunk_password, load_awscodecommit = var.load_awscodecommit})
destination = "/tmp/linux_node_user_data.sh"
}
provisioner "remote-exec" {
inline = [
"bash /tmp/linux_node_user_data.sh"
]
}
provisioner "remote-exec" {
inline = [
"sudo reboot"
]
on_failure = "continue"
}
}