-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path06-kc-vm.tf
67 lines (57 loc) · 1.62 KB
/
06-kc-vm.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
data "yandex_compute_image" "vm_image" {
family = var.image_family
}
#Create KeyCloak VM
resource "yandex_compute_instance" "keycloak" {
name = var.keycloak_name
hostname = var.keycloak_name
zone = var.zone
platform_id = var.platform_id
service_account_id = yandex_iam_service_account.kc-sa.id
resources {
cores = var.cores
memory = var.memory
}
boot_disk {
initialize_params {
image_id = data.yandex_compute_image.vm_image.id
size = 30
}
}
network_interface {
subnet_id = yandex_vpc_subnet.keycloaksubnet[0].id
nat = var.nat
}
metadata = {
user-data = templatefile("${path.module}/kc-install.yml",
{
ssh_key = "${chomp(tls_private_key.ssh.public_key_openssh)}"
DomainFQDN = var.domain_fqdn
KC_VER = var.kc_ver
KC_PORT = var.kc_port
PG_DB_HOST = yandex_mdb_postgresql_cluster.pg_cluster.host.0.fqdn
PG_DB_NAME = var.pg_db_name
SA_NAME = yandex_iam_service_account.kc-sa.name
SECRET_ID = yandex_lockbox_secret.password_secret.id
}
)
}
depends_on = [
local_file.private_key,
yandex_mdb_postgresql_cluster.pg_cluster,
yandex_mdb_postgresql_database.pg_db,
yandex_kms_symmetric_key.kc-key,
yandex_iam_service_account.kc-sa,
yandex_lockbox_secret.password_secret,
null_resource.lockbox_secrets_access_binding
]
}
output "keycloak_name" {
value = yandex_compute_instance.keycloak.name
}
output "keycloak_address" {
value = yandex_compute_instance.keycloak.network_interface.0.nat_ip_address
}
output "public_key" {
value = chomp(tls_private_key.ssh.public_key_openssh)
}