-
Notifications
You must be signed in to change notification settings - Fork 25
/
gat-eu.tf
89 lines (75 loc) · 2.41 KB
/
gat-eu.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
variable "gat-count-eu" {
default = 0
}
data "openstack_images_image_v2" "gat-image-eu" {
name = "Ubuntu 22.04"
}
# Random passwords for the VMs, easier to type/remember for the non-ssh key
# users.
resource "random_pet" "training-vm-eu" {
keepers = {
image = "${data.openstack_images_image_v2.gat-image-eu.id}"
region = "eu"
}
length = 2
count = var.gat-count-eu
}
# The VMs themselves.
resource "openstack_compute_instance_v2" "training-vm-eu" {
name = "gat-${count.index}.eu.training.galaxyproject.eu"
flavor_name = "c1.c4m16d50"
key_pair = "gat"
security_groups = ["default", "public-ping", "public-web2", "egress", "public-amqp"]
network {
name = "public"
}
block_device {
uuid = data.openstack_images_image_v2.gat-image-eu.id
source_type = "image"
volume_size = 50
destination_type = "volume"
boot_index = 0
delete_on_termination = true
}
# Update user password
user_data = <<-EOF
#cloud-config
chpasswd:
list: |
ubuntu:${element(random_pet.training-vm-eu.*.id, count.index)}
expire: False
runcmd:
- [ sed, -i, s/PasswordAuthentication no/PasswordAuthentication yes/, /etc/ssh/sshd_config ]
- [ systemctl, restart, ssh ]
EOF
count = var.gat-count-eu
}
# Setup a DNS record for the VMs to make access easier (and https possible.)
resource "aws_route53_record" "training-vm-eu" {
zone_id = "Z05016927AMHTHGB1IS2"
name = "gat-${count.index}.eu.training.galaxyproject.eu"
type = "A"
ttl = "3600"
records = ["${element(openstack_compute_instance_v2.training-vm-eu.*.access_ip_v4, count.index)}"]
count = var.gat-count-eu
}
## Only for the REAL gat.
#resource "aws_route53_record" "training-vm-eu-gxit-wildcard" {
# zone_id = aws_route53_zone.training-gxp-eu.zone_id
# name = "*.interactivetoolentrypoint.interactivetool.gat-${count.index}.eu.training.galaxyproject.eu"
# type = "CNAME"
# ttl = "3600"
# records = ["gat-${count.index}.eu.training.galaxyproject.eu"]
# count = var.gat-count-eu
#}
# Outputs to be consumed by admins
output "training_ips-eu" {
value = ["${openstack_compute_instance_v2.training-vm-eu.*.access_ip_v4}"]
}
output "training_pws-eu" {
value = ["${random_pet.training-vm-eu.*.id}"]
sensitive = true
}
output "training_dns-eu" {
value = ["${aws_route53_record.training-vm-eu.*.name}"]
}