-
Notifications
You must be signed in to change notification settings - Fork 1
/
compute.tf
66 lines (59 loc) · 2.63 KB
/
compute.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
# ---------------------------------------------------------------------------
# Trivadis AG, Infrastructure Managed Services
# Saegereistrasse 29, 8152 Glattbrugg, Switzerland
# ---------------------------------------------------------------------------
# Name.......: compute.tf
# Author.....: Stefan Oehrli (oes) [email protected]
# Editor.....: Stefan Oehrli
# Date.......: 2020.10.12
# Revision...:
# Purpose....: Compute Instance for the terraform module tvdlab compute.
# Notes......: --
# Reference..: --
# License....: Apache License Version 2.0, January 2004 as shown
# at http://www.apache.org/licenses/
# ---------------------------------------------------------------------------
resource "oci_core_instance" "compute" {
count = var.host_enabled == true ? var.tvd_participants : 0
availability_domain = local.availability_domain
compartment_id = var.compartment_id
display_name = var.label_prefix == "none" ? format("${local.resource_shortname}-${var.host_name}%02d", count.index) : format("${var.label_prefix}-${local.resource_shortname}-${var.host_name}%02d", count.index)
shape = var.host_shape
state = var.host_state
defined_tags = var.defined_tags
freeform_tags = var.tags
create_vnic_details {
subnet_id = var.host_subnet[count.index]
assign_public_ip = var.host_public_ip
private_ip = var.host_private_ip
display_name = var.label_prefix == "none" ? "vnic" : "${var.label_prefix}-vnic"
hostname_label = var.host_name
}
# prevent the host from destroying and recreating itself if the image ocid changes
lifecycle {
ignore_changes = [source_details[0].source_id]
}
metadata = {
ssh_authorized_keys = local.ssh_authorized_keys
user_data = var.host_bootstrap != "" ? var.host_bootstrap : base64encode(templatefile(local.host_bootstrap_template, {
yum_upgrade = var.yum_upgrade
authorized_keys = base64gzip(local.ssh_authorized_keys)
etc_hosts = base64gzip(local.hosts_file)
bootstrap_windows_host = local.bootstrap_windows_host
bootstrap_linux_host = local.bootstrap_linux_host
}))
}
shape_config {
memory_in_gbs = var.host_memory_in_gbs
ocpus = var.host_ocpus
}
source_details {
source_type = "image"
source_id = local.host_image_id
boot_volume_size_in_gbs = var.host_boot_volume_size
}
timeouts {
create = "60m"
}
}
# --- EOF -------------------------------------------------------------------