Skip to content

Commit 30855d9

Browse files
committed
feat: Reflect platform_config type from worker shape
Signed-off-by: Devon Crouse <[email protected]>
1 parent 42e2ecc commit 30855d9

File tree

5 files changed

+34
-5
lines changed

5 files changed

+34
-5
lines changed

examples/vars-workers-advanced.auto.tfvars

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,8 @@ worker_pools = {
4545
},
4646
shielded_instances = {
4747
description = "Self-managed Shielded VM Instance", create = false,
48-
size = 1, mode = "instance", shape = "VM.Standard2.4",
48+
size = 1, mode = "instance", shape = "VM.Standard2.4",
4949
platform_config = {
50-
type = "INTEL_VM",
5150
is_measured_boot_enabled = true,
5251
is_secure_boot_enabled = true,
5352
is_trusted_platform_module_enabled = true,

modules/workers/data-shapes.tf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright (c) 2023 Oracle Corporation and/or its affiliates.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl
3+
4+
data "oci_core_shapes" "oke" {
5+
compartment_id = var.compartment_id
6+
}
7+
8+
locals {
9+
shapes_by_name = {
10+
for shape in data.oci_core_shapes.oke.shapes :
11+
lookup(shape, "name") => shape if contains(keys(shape), "name")
12+
}
13+
14+
platform_config_by_shape = {
15+
for k, v in local.shapes_by_name :
16+
k => merge(lookup(v, "platform_config_options", [])...)
17+
}
18+
}

modules/workers/instance.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,13 @@ resource "oci_core_instance" "workers" {
2222
dynamic "platform_config" {
2323
for_each = each.value.platform_config != null ? [1] : []
2424
content {
25-
type = lookup(each.value.platform_config, "type")
25+
type = lookup(
26+
# Attempt lookup against data source for the associated 'type' of configured worker shape
27+
lookup(local.platform_config_by_shape, each.value.shape, {}), "type",
28+
# Fall back to 'type' on pool with custom platform_config, or INTEL_VM default
29+
lookup(each.value.platform_config, "type", "INTEL_VM")
30+
)
31+
# Remaining parameters as configured, validated by instance/instance config resource
2632
are_virtual_instructions_enabled = lookup(each.value.platform_config, "are_virtual_instructions_enabled", null)
2733
is_access_control_service_enabled = lookup(each.value.platform_config, "is_access_control_service_enabled", null)
2834
is_input_output_memory_management_unit_enabled = lookup(each.value.platform_config, "is_input_output_memory_management_unit_enabled", null)

modules/workers/instanceconfig.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,13 @@ resource "oci_core_instance_configuration" "workers" {
6767
dynamic "platform_config" {
6868
for_each = each.value.platform_config != null ? [1] : []
6969
content {
70-
type = lookup(each.value.platform_config, "type")
70+
type = lookup(
71+
# Attempt lookup against data source for the associated 'type' of configured worker shape
72+
lookup(local.platform_config_by_shape, each.value.shape, {}), "type",
73+
# Fall back to 'type' on pool with custom platform_config, or INTEL_VM default
74+
lookup(each.value.platform_config, "type", "INTEL_VM")
75+
)
76+
# Remaining parameters as configured, validated by instance/instance config resource
7177
are_virtual_instructions_enabled = lookup(each.value.platform_config, "are_virtual_instructions_enabled", null)
7278
is_access_control_service_enabled = lookup(each.value.platform_config, "is_access_control_service_enabled", null)
7379
is_input_output_memory_management_unit_enabled = lookup(each.value.platform_config, "is_input_output_memory_management_unit_enabled", null)

variables-workers.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ variable "platform_config" {
235235
default = null
236236
description = "Default platform_config for self-managed worker pools created with mode: 'instance', 'instance-pool', or 'cluster-network'. See <a href=https://docs.oracle.com/en-us/iaas/api/#/en/iaas/20160918/datatypes/PlatformConfig>PlatformConfig</a> for more information."
237237
type = object({
238-
type = string,
238+
type = optional(string),
239239
are_virtual_instructions_enabled = optional(bool),
240240
is_access_control_service_enabled = optional(bool),
241241
is_input_output_memory_management_unit_enabled = optional(bool),

0 commit comments

Comments
 (0)