-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.tf
72 lines (63 loc) · 1.78 KB
/
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
terraform {
required_version = ">= 1.0"
required_providers {
openstack = {
source = "terraform-provider-openstack/openstack"
version = "~> 1.35.0"
}
gandi = {
source = "go-gandi/gandi"
version = "2.0.0"
}
}
}
data "template_file" "user_data" {
template = file("${path.module}/templates/cloud-init.yaml")
vars = {
domain = "${var.dns_subdomain}.${var.dns_zone}"
email = "${var.letsencrypt_email}"
use_le_staging = "${var.letsencrypt_staging}"
}
}
resource "openstack_compute_keypair_v2" "jitsi-keypair" {
name = var.keypair_name
}
resource "openstack_compute_instance_v2" "jitsi" {
name = "jitsi"
key_pair = openstack_compute_keypair_v2.jitsi-keypair.name
flavor_name = "V-R2"
security_groups = ["default"]
power_state = "active"
network {
name = "public"
}
user_data = data.template_file.user_data.rendered
block_device {
# Ubuntu 20.04
uuid = "47edd0a0-23ce-4ce5-9168-36de68990d1b"
source_type = "image"
volume_size = 25
boot_index = 0
destination_type = "volume"
delete_on_termination = true
}
}
resource "local_file" "private-key" {
content = openstack_compute_keypair_v2.jitsi-keypair.private_key
filename = "jitsi-priv.key"
file_permission = "0600"
}
resource "gandi_livedns_record" "jitsi_dns_v4" {
zone = var.dns_zone
name = var.dns_subdomain
type = "A"
ttl = 1800
values = ["${openstack_compute_instance_v2.jitsi.access_ip_v4}"]
}
resource "gandi_livedns_record" "jitsi_dns_v6" {
zone = var.dns_zone
name = var.dns_subdomain
type = "AAAA"
ttl = 1800
values = [trim("${openstack_compute_instance_v2.jitsi.access_ip_v6}", "[]")]
}