-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.tf
46 lines (39 loc) · 936 Bytes
/
main.tf
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
38
39
40
41
42
43
44
45
46
provider "hcloud" {
token = var.api_token
}
module "cloudd" {
source = "github.com/ingobecker/cloudd"
volume_dev = "/dev/sdb"
root_dev = "/dev/sda"
context = var.context
user = var.user
ssh_key = var.ssh_key
}
resource "hcloud_server" "cloudd" {
name = "cloudd"
image = "fedora-32"
server_type = "cx11"
location = "nbg1"
user_data = module.cloudd.cloud_init
}
resource "hcloud_volume_attachment" "cloudd" {
volume_id = hcloud_volume.cloudd.id
server_id = hcloud_server.cloudd.id
automount = false
}
resource "hcloud_volume" "cloudd" {
name = "cloudd"
location = "nbg1"
size = 10
}
data "external" "snapshot" {
program = ["bash", "${path.module}/scripts/snapshot.sh"]
query = {
api_token = var.api_token
server_id = hcloud_server.cloudd.id
snap_name = var.name
}
}
output "image_id" {
value = data.external.snapshot.result.image_id
}