Skip to content

Commit 4cd2324

Browse files
committed
use a list for CW configuration in prometheus
1 parent 7439e1e commit 4cd2324

4 files changed

Lines changed: 11 additions & 11 deletions

File tree

aws/telemetry/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module "prometheus_workspace" {
2323
alert_resolve_timeout = var.alert_resolve_timeout
2424
alert_subject_template = var.alert_subject_template
2525
alertmanager_config_enabled = var.alertmanager_config_enabled
26-
logging_group_name = var.logging_group_name
26+
logging_configuration = var.logging_configuration
2727
name = var.prometheus_workspace_name
2828
tags = var.tags
2929

aws/telemetry/modules/prometheus-workspace/main.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ resource "aws_prometheus_workspace" "this" {
33
tags = var.tags
44

55
dynamic logging_configuration {
6-
for_each = var.logging_group_name
6+
for_each = var.logging_configuration
77
content {
8-
log_group_arn = data.aws_cloudwatch_log_group.this.arn
8+
log_group_arn = data.aws_cloudwatch_log_group.this.arn
99
}
1010
}
1111
}
1212

1313
data "aws_cloudwatch_log_group" "this" {
14-
count = var.logging_group_name ? 1 : 0
15-
name = var.logging_group_name
14+
for_each = var.logging_configuration
15+
name = each.value.name
1616
}
1717

1818
resource "aws_iam_role" "ingestion" {

aws/telemetry/modules/prometheus-workspace/variables.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ variable "alertmanager_config_enabled" {
2828
default = true
2929
}
3030

31-
variable "logging_group_name" {
32-
description = "Name of Cloudwatch logging group for Prometheus workspace"
33-
type = string
31+
variable "logging_configuration" {
32+
description = "Cloudwatch logging configuration for Prometheus workspace"
33+
type = map(string)
3434
default = null
3535
}
3636

aws/telemetry/variables.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ variable "alertmanager_config_enabled" {
4646
default = true
4747
}
4848

49-
variable "logging_group_name" {
50-
description = "Name of Cloudwatch logging group for Prometheus workspace"
51-
type = string
49+
variable "logging_configuration" {
50+
description = "Cloudwatch logging configuration for Prometheus workspace"
51+
type = map(string)
5252
default = null
5353
}
5454

0 commit comments

Comments
 (0)