Closed aplsms closed 2 years ago
You seem to want to unmount the volume before the server is destroyed using the destroy provisioner
. However, because the resource type of the destroy provisioner
is null resource
, it is executed not when the server is destroyed, but when the null resource
is destroyed. So it does not work exactly as you want.
To solve this, the destroy provisioner
must be declared inside the ncloud_server
resource. Please refer to the example below.
resource "ncloud_server" "server" {
provisioner "local-exec" {
when = destroy
command = "echo 'Destroy-time provisioner'"
}
}
And, since the datasource ncloud_root_password
is not an output of the ncloud_server
resource, it must be used after declaring the datasource. Please refer to the usage example below.
data "ncloud_root_password" "default" {
server_instance_no = ncloud_server.server.id
private_key = ncloud_login_key.key.private_key
}
Lastly, destroying server fails due to volume mount when destroying server instance will be fixed soon. (stop_instance_before_destory
option to be added)
Hello, I have a problem running destroy provisioner to dismount a volume.
error message:
I see no
root_password
in the state:I've tried to use
self.public_ip
-- does not work.How can I configure connection to use "self" ?
thank you in advance.