我有这样的资源:
resource "yandex_mdb_mysql_cluster" "main" {
+ allow_regeneration_host = false
+ created_at = (known after apply)
+ description = "Multi node MySQL cluster created with Terraform"
+ environment = "PRODUCTION"
+ health = (known after apply)
+ id = (known after apply)
+ labels = {
+ "env" = "dev"
}
+ name = (known after apply)
+ status = (known after apply)
+ version = "5.7"
+ access {
+ data_lens = false
+ web_sql = true
}
+ backup_window_start {
+ hours = 1
+ minutes = 0
}
+ host {
+ assign_public_ip = false
+ fqdn = (known after apply)
+ subnet_id = (known after apply)
+ zone = "ru-central1-a"
}
+ host {
+ assign_public_ip = false
+ fqdn = (known after apply)
+ subnet_id = (known after apply)
+ zone = "ru-central1-b"
}
+ host {
+ assign_public_ip = false
+ fqdn = (known after apply)
+ subnet_id = (known after apply)
+ zone = "ru-central1-c"
}
现在我想设置一个输出,host
以地图形式从动态块获取数据host.zone = host.fqdn
,例如:
{ru-central1-a = "fqdn-a"
ru-central1-b = "fqdn-b"
ru-central1-c = "fqdn-c"}
我已经尝试对整个资源运行循环并使用 host.zone 和 host.fqdn,但它似乎不起作用...任何帮助都值得感激!
答案1
您是否尝试过这样的事情?
output x {
value = { for v in yandex_mdb_mysql_cluster.main.host: v.zone => v.fqdn }
}