-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
34 lines (30 loc) · 1017 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
resource "random_id" "random" {
byte_length = 8
}
resource "local_file" "kubeconfig" {
content = var.kubeconfig
filename = "${path.module}/${random_id.random.hex}/kubeconfig"
}
resource "local_file" "bundle_yaml" {
content = yamlencode({
"applications": var.applications,
"bundle": var.bundle,
"description": var.description,
"relations": var.relations,
})
filename = "${path.module}/${random_id.random.hex}/bundle.yaml"
}
resource "null_resource" "testfaster_vm" {
depends_on = [local_file.bundle_yaml, local_file.kubeconfig]
provisioner "local-exec" {
command = <<-EOT
cd ${path.module}/${random_id.random.hex}
export KUBECONFIG=$(pwd)/kubeconfig
snap install juju --classic --channel=2.9/stable
/snap/bin/juju add-k8s --client k8s
/snap/bin/juju bootstrap k8s
/snap/bin/juju deploy ./bundle.yaml
EOT
}
}
// TODO: outputs, such as DNS names for services created?