-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
57 lines (43 loc) · 1.85 KB
/
main.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
locals {
workspace_id = var.create_prometheus && var.create_workspace ? aws_prometheus_workspace.this[0].id : var.workspace_id
# if this is true, then this will error
# only one otel collector service at a time
ecs_service_validator = !(var.create_adot_service && var.create_otel_collector_service)
}
resource "null_resource" "validate_otel_collector_service" {
count = local.ecs_service_validator ? 0 : 1
provisioner "local-exec" {
command = "echo 'Only one of create_adot_service or create_otel_collector_service can be true.'"
}
}
################################################################################
# Workspace
################################################################################
resource "aws_prometheus_workspace" "this" {
count = var.create_prometheus && var.create_workspace ? 1 : 0
alias = var.workspace_alias
dynamic "logging_configuration" {
for_each = length(var.logging_configuration) > 0 ? [var.logging_configuration] : []
content {
log_group_arn = logging_configuration.value.log_group_arn
}
}
tags = var.tags
}
################################################################################
# Alert Manager Definition
################################################################################
resource "aws_prometheus_alert_manager_definition" "this" {
count = var.create_prometheus ? 1 : 0
workspace_id = local.workspace_id
definition = var.alert_manager_definition
}
################################################################################
# Rule Group Namespace
################################################################################
resource "aws_prometheus_rule_group_namespace" "this" {
for_each = var.create_prometheus ? var.rule_group_namespaces : {}
name = each.value.name
workspace_id = local.workspace_id
data = each.value.data
}