Having some issues moving from .12.8 to lastest terraform.
My code:
resource "null_resource" "post_deploy_config" {
depends_on = [module.nutanix_module]
count = var.resourcecount
connection {
type = "ssh"
host = module.nutanix_module.vm_ip[count.index]
user = var.user
password = var.pass
}
provisioner "remote-exec" {
inline = [<<EOF
/bin/sudo /bin/systemctl restart gitlab-runner
EOF
]
}
provisioner "remote-exec" {
when = destroy
on_failure = continue
inline = [<<EOF
sudo gitlab-runner unregister --all-runners
EOF
]
}
}
But seeing the following error:
[LC02XG0YLJGH5]–[344530]–[~/Gitlab/terraform/gitlab-runner-ntnx-tf][:)]
$ terraform validate
Warning: External references from destroy provisioners are deprecated
on main.tf line 41, in resource “null_resource” “post_deploy_config”:
41: host = module.nutanix_module.vm_ips[count.index]
Destroy-time provisioners and their connection configurations may only
reference attributes of the related resource, via ‘self’, ‘count.index’, or
‘each.key’.
References to other resources during the destroy phase can cause dependency
cycles and interact poorly with create_before_destroy.
(and 2 more similar warnings elsewhere)
I am unclear how to get around this.