Hello,
I’m trying to send a map to a module in order to come and fill in a block but I can’t find how to dynamically fill in the key.
Exemple i have variable :
variable "monitor_thresholds" {
type = map(number)
description = "Alert thresholds of the monitor."
default = {
critical = 1
critical_recovery = 2
}
}
And i want create block :
resource "datadog_monitor" "monitor_limit_custom_metric" {
name = "[${var.business_department}] ${var.name}"
type = var.type
query = var.query
message = var.message
tags = var.tags
notify_audit = var.notify_audit
locked = var.locked
timeout_h = var.timeout_h
new_host_delay = var.new_host_delay
require_full_window = var.require_full_window
notify_no_data = var.notify_no_data
renotify_interval = var.renotify_interval
escalation_message = var.escalation_message
include_tags = var.include_tags
priority = var.priority
dynamic "monitor_thresholds" {
for_each = var.monitor_thresholds
content {
monitor_thresholds.key = monitor_thresholds.value
}
}
}
But i can’t use monitor_thresholds.key in key.
It’s possible to do this in HCL ?
The goal being that the monitor_thresholds field is fully dynamic and that I can send the module values of the style:
module "monitor-limit-free-custom-metrics" {
source = "../terraform-modules/monitoring-datadog-terraform-monitor"
....
monitor_thresholds = {
critical = 2
ok = 1
warning = 1
}
priority = 2
}