|
2 | 2 | # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl |
3 | 3 |
|
4 | 4 | # Dynamic resource block for Instance Pool groups defined in worker_pools |
5 | | -resource "oci_core_instance_pool" "workers" { |
| 5 | +resource "oci_core_instance_pool" "tfscaled_workers" { |
6 | 6 | # Create an OCI Instance Pool resource for each enabled entry of the worker_pools map with that mode. |
7 | | - for_each = local.enabled_instance_pools |
| 7 | + for_each = { for key, value in local.enabled_instance_pools: key => value if tobool(lookup(value, "ignore_initial_pool_size", false)) == false } |
8 | 8 | compartment_id = each.value.compartment_id |
9 | 9 | display_name = each.key |
10 | 10 | size = each.value.size |
@@ -61,3 +61,63 @@ resource "oci_core_instance_pool" "workers" { |
61 | 61 | } |
62 | 62 | } |
63 | 63 | } |
| 64 | + |
| 65 | +resource "oci_core_instance_pool" "autoscaled_workers" { |
| 66 | + # Create an OCI Instance Pool resource for each enabled entry of the worker_pools map with that mode. |
| 67 | + for_each = { for key, value in local.enabled_instance_pools: key => value if tobool(lookup(value, "ignore_initial_pool_size", false)) == true } |
| 68 | + compartment_id = each.value.compartment_id |
| 69 | + display_name = each.key |
| 70 | + size = each.value.size |
| 71 | + instance_configuration_id = oci_core_instance_configuration.workers[each.key].id |
| 72 | + defined_tags = each.value.defined_tags |
| 73 | + freeform_tags = each.value.freeform_tags |
| 74 | + |
| 75 | + dynamic "placement_configurations" { |
| 76 | + for_each = each.value.availability_domains |
| 77 | + iterator = ad |
| 78 | + |
| 79 | + content { |
| 80 | + availability_domain = ad.value |
| 81 | + primary_subnet_id = each.value.subnet_id |
| 82 | + |
| 83 | + # Value(s) specified on pool, or null to select automatically |
| 84 | + fault_domains = try(each.value.placement_fds, null) |
| 85 | + |
| 86 | + dynamic "secondary_vnic_subnets" { |
| 87 | + for_each = lookup(each.value, "secondary_vnics", {}) |
| 88 | + iterator = vnic |
| 89 | + content { |
| 90 | + display_name = vnic.key |
| 91 | + subnet_id = lookup(vnic.value, "subnet_id", each.value.subnet_id) |
| 92 | + } |
| 93 | + } |
| 94 | + } |
| 95 | + } |
| 96 | + |
| 97 | + lifecycle { |
| 98 | + ignore_changes = [ |
| 99 | + display_name, defined_tags, freeform_tags, |
| 100 | + placement_configurations, size |
| 101 | + ] |
| 102 | + |
| 103 | + precondition { |
| 104 | + condition = coalesce(each.value.image_id, "none") != "none" |
| 105 | + error_message = <<-EOT |
| 106 | + Missing image_id; check provided value if image_type is 'custom', or image_os/image_os_version if image_type is 'oke' or 'platform'. |
| 107 | + pool: ${each.key} |
| 108 | + image_type: ${coalesce(each.value.image_type, "none")} |
| 109 | + image_id: ${coalesce(each.value.image_id, "none")} |
| 110 | + EOT |
| 111 | + } |
| 112 | + |
| 113 | + precondition { |
| 114 | + condition = var.cni_type == "flannel" |
| 115 | + error_message = "Instance Pools require a cluster with `cni_type = flannel`." |
| 116 | + } |
| 117 | + |
| 118 | + precondition { |
| 119 | + condition = each.value.autoscale == false |
| 120 | + error_message = "Instance Pools do not support cluster autoscaler management." |
| 121 | + } |
| 122 | + } |
| 123 | +} |
0 commit comments