遇到错误“属性“触发”的值不正确:映射的字符串是必需的。”
尝试使用在创建特定资源(在这种情况下为“监视器”)之前应触发的本地执行配置器。
resource "null_resource" "test_run" {
provisioner "local-exec" {
command = "bin/script.sh"
interpreter = ["bash", "-File"]
}
triggers {
before = "${bigip_ltm_monitor.millenium}"
}
}
resource "bigip_ltm_monitor" "millenium" {
compatibility = "enabled"
interval = "5"
name = "/Common/https_mon"
parent = "/Common/https"
receive = "200"
reverse = "disabled"
send = "GET /health HTTP/1.1\r\nHost: xyz.com\r\nConnection: Close\r\n\r\n"
timeout = "16"
}
答案 0 :(得分:0)
尝试在您的 null_resource 中的 bigip_ltm_monitor 资源中代替depends_on = [null_resource.test_run]
的{strong>设置triggers{...}
。
这使Terraform可以在监控器之前创建预配器资源。
有关更多信息,请参见Resource Dependencies 。
答案 1 :(得分:0)
triggers
参数的目的是指定一个字符串集合,null_resource
实现可以检查这些字符串以确定是否替换对象,这将反过来重新运行预配程序。
如果需要在创建null_resource.test_run
之前创建 bigip_ltm_monitor.millenium
,则需要以另一种方式在bigip_ltm_monitor
内编写依赖项边。例如:
resource "bigip_ltm_monitor" "millenium" {
compatibility = "enabled"
interval = "5"
name = "/Common/https_mon"
parent = "/Common/https"
receive = "200"
reverse = "disabled"
send = "GET /health HTTP/1.1\r\nHost: xyz.com\r\nConnection: Close\r\n\r\n"
timeout = "16"
depends_on = [null_resource.test_run]
}