-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathmonitoring.tf
82 lines (69 loc) · 2.31 KB
/
monitoring.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
75
76
77
78
79
80
81
82
# Creates prometheus and grafana instances for students
# They still need to be provisioned
resource "random_integer" "monitoring-id" {
min = 0
max = length(var.public-subnet-ids) - 1
}
locals {
monitoring-placement = random_integer.monitoring-id.result
}
resource "aws_instance" "prometheus" {
count = var.create-monitoring-instances ? 1 : 0
ami = var.aws-ami-id
instance_type = var.prometheus-instance-type
key_name = var.key-name
root_block_device {
volume_size = 64
}
tags = {
Name = "${var.dns-suffix}-prometheus"
description = "Prometheus node - Managed by Terraform"
role = "prometheus"
Schedule = "zookeeper-mon-8am-fri-6pm"
sshUser = var.linux-user
region = var.region
}
subnet_id = var.public-subnet-ids[local.monitoring-placement]
availability_zone = var.availability-zones[local.monitoring-placement]
vpc_security_group_ids = [ var.internal-vpc-security-group-id, var.external-vpc-security-group-id ]
associate_public_ip_address = true
}
resource "aws_route53_record" "prometheus" {
count = var.create-monitoring-instances ? 1 : 0
allow_overwrite = true
zone_id = var.hosted-zone-id
name = "prometheus.${var.dns-suffix}"
type = "A"
ttl = "300"
records = [element(aws_instance.prometheus.*.private_ip, count.index)]
}
resource "aws_instance" "grafana" {
count = var.create-monitoring-instances ? 1 : 0
ami = var.aws-ami-id
instance_type = var.grafana-instance-type
key_name = var.key-name
root_block_device {
volume_size = 64
}
tags = {
Name = "${var.dns-suffix}-grafana"
description = "Grafana node - Managed by Terraform"
role = "grafana"
Schedule = "zookeeper-mon-8am-fri-6pm"
sshUser = var.linux-user
region = var.region
}
subnet_id = var.public-subnet-ids[local.monitoring-placement]
availability_zone = var.availability-zones[local.monitoring-placement]
vpc_security_group_ids = [ var.internal-vpc-security-group-id, var.external-vpc-security-group-id ]
associate_public_ip_address = true
}
resource "aws_route53_record" "grafana" {
count = var.create-monitoring-instances ? 1 : 0
allow_overwrite = true
zone_id = var.hosted-zone-id
name = "grafana.${var.dns-suffix}"
type = "A"
ttl = "300"
records = [element(aws_instance.grafana.*.private_ip, count.index)]
}