-
Notifications
You must be signed in to change notification settings - Fork 8
/
01-create-cluster.tf
44 lines (39 loc) · 1.81 KB
/
01-create-cluster.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
resource "equinix_metal_reserved_ip_block" "cluster_ip" {
project_id = equinix_metal_project.new_project.id
quantity = 1
}
data "external" "create_cluster" {
program = ["python3", "${path.module}/scripts/create_cluster.py"]
query = {
du_fqdn = var.platform9_fqdn
user = var.platform9_user
pw = var.platform9_password
tenant = var.platform9_tenant
region = var.platform9_region
cluster_name = var.cluster_name
k8s_api_fqdn = equinix_metal_reserved_ip_block.cluster_ip.address
allow_workloads_on_master = var.allow_workloads_on_master
}
}
resource "null_resource" "delete_cluster" {
triggers = {
cluster_uuid = lookup(data.external.create_cluster.result, "cluster_id")
platform9_fqdn = var.platform9_fqdn
platform9_user = var.platform9_user
platform9_password = var.platform9_password
platform9_tenant = var.platform9_tenant
platform9_region = var.platform9_region
}
provisioner "local-exec" {
when = destroy
command = "printf '{\"du_fqdn\": \"${self.triggers.platform9_fqdn}\", \"user\": \"${self.triggers.platform9_user}\", \"pw\": \"${self.triggers.platform9_password}\", \"tenant\": \"${self.triggers.platform9_tenant}\", \"region\": \"${self.triggers.platform9_region}\", \"cluster_uuid\": \"${self.triggers.cluster_uuid}\"}' | python3 ${path.module}/scripts/delete_cluster.py"
environment = {
du_fqdn = self.triggers.platform9_fqdn
user = self.triggers.platform9_user
pw = self.triggers.platform9_password
tenant = self.triggers.platform9_tenant
region = self.triggers.platform9_region
cluster_uuid = self.triggers.cluster_uuid
}
}
}