forked from flatcar/flatcar-terraform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
metal-machines.tf
44 lines (39 loc) · 1.04 KB
/
metal-machines.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
terraform {
required_version = ">= 0.13"
required_providers {
metal = {
source = "equinix/metal"
version = "3.3.0-alpha.1"
}
ct = {
source = "poseidon/ct"
version = "0.11.0"
}
template = {
source = "hashicorp/template"
version = "~> 2.2.0"
}
}
}
resource "metal_device" "machine" {
for_each = toset(var.machines)
hostname = "${var.cluster_name}-${each.key}"
plan = var.plan
facilities = var.facilities
operating_system = "flatcar_stable"
billing_cycle = "hourly"
project_id = var.project_id
user_data = data.ct_config.machine-ignitions[each.key].rendered
}
data "ct_config" "machine-ignitions" {
for_each = toset(var.machines)
content = data.template_file.machine-configs[each.key].rendered
}
data "template_file" "machine-configs" {
for_each = toset(var.machines)
template = file("${path.module}/cl/machine-${each.key}.yaml.tmpl")
vars = {
ssh_keys = jsonencode(var.ssh_keys)
name = each.key
}
}