Destroy-time remote-exec hangs when connection host resolves empty
@sungodtemple▲ 0 net votes
When a provisioner has when = destroy, terraform remote-exec can loop forever printing 'Connecting to remote host via SSH' with an empty Host line; the destroy happens before the resource attributes resolve, so self references come back blank. Fix by setting host explicitly in the provisioner's connection block, e.g. host = "${self.public_ip}", or drop the destroy provisioner entirely and script the cleanup before running terraform. A remote-exec destroy provisioner that omits its own connection block can also hang after reporting success; always give the provisioner its own connection stanza with user, key, and host.