2019-12-03 19:23:07 +01:00
|
|
|
locals {
|
|
|
|
user = "name"
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "null_resource" "a" {
|
|
|
|
connection {
|
|
|
|
host = self.hostname
|
2019-12-12 22:26:42 +01:00
|
|
|
user = local.user # ERROR: Invalid reference from destroy provisioner
|
2019-12-03 19:23:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
provisioner "remote-exec" {
|
|
|
|
when = destroy
|
|
|
|
index = count.index
|
|
|
|
key = each.key
|
2020-01-15 17:39:01 +01:00
|
|
|
|
|
|
|
// path and terraform values are static, and do not create any
|
|
|
|
// dependencies.
|
2020-01-13 22:44:44 +01:00
|
|
|
dir = path.module
|
2020-01-15 17:39:01 +01:00
|
|
|
workspace = terraform.workspace
|
2019-12-03 19:23:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "null_resource" "b" {
|
|
|
|
connection {
|
|
|
|
host = self.hostname
|
|
|
|
# this is OK since there is no destroy provisioner
|
|
|
|
user = local.user
|
|
|
|
}
|
|
|
|
|
|
|
|
provisioner "remote-exec" {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "null_resource" "b" {
|
|
|
|
provisioner "remote-exec" {
|
|
|
|
when = destroy
|
|
|
|
connection {
|
|
|
|
host = self.hostname
|
2019-12-12 22:26:42 +01:00
|
|
|
user = local.user # ERROR: Invalid reference from destroy provisioner
|
2019-12-03 19:23:07 +01:00
|
|
|
}
|
|
|
|
|
2019-12-12 22:26:42 +01:00
|
|
|
command = "echo ${local.name}" # ERROR: Invalid reference from destroy provisioner
|
2019-12-03 19:23:07 +01:00
|
|
|
}
|
|
|
|
}
|