-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvolume.tf
More file actions
37 lines (31 loc) · 825 Bytes
/
volume.tf
File metadata and controls
37 lines (31 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
resource "hcloud_volume_attachment" "default" {
count = var.volume != null ? 1 : 0
server_id = hcloud_server.default.id
volume_id = var.volume.id
automount = false
}
resource "null_resource" "volume_attachment" {
count = var.volume != null ? 1 : 0
depends_on = [
hcloud_volume_attachment.default
]
triggers = {
always_run = "${timestamp()}"
}
connection {
type = "ssh"
user = "root"
private_key = var.ssh_private_key
host = hcloud_server.default.ipv4_address
timeout = "5m"
}
provisioner "file" {
source = "${path.module}/scripts/volume-attachment.sh"
destination = "/root/volume-attachment.sh"
}
provisioner "remote-exec" {
inline = [
"VOLUME_ID=\"${var.volume.id}\" sh /root/volume-attachment.sh"
]
}
}