From 7201f3d0a5503a921971a421147e3e7bb1910561 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix-Antoine=20Fortin?= Date: Wed, 15 Jan 2025 10:49:51 -0500 Subject: [PATCH] Fix specs --- common/design/main.tf | 7 +++++-- openstack/infrastructure.tf | 12 ++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/common/design/main.tf b/common/design/main.tf index 6e60aa1b..acb71ade 100644 --- a/common/design/main.tf +++ b/common/design/main.tf @@ -10,8 +10,11 @@ locals { for prefix, attrs in var.instances : [ for i in range(lookup(attrs, "count", 1)) : { (format("%s%d", prefix, i + 1)) = merge( - { specs = { for attr, value in attrs : attr => value if ! contains(["count", "tags"], attr) } }, - { prefix = prefix, tags = attrs.tags } + { for attr, value in attrs : attr => value if ! contains(["count"], attr) }, + { + prefix = prefix, + specs = { for attr, value in attrs : attr => value if ! contains(["count", "tags", "image"], attr) } + }, ) } ] diff --git a/openstack/infrastructure.tf b/openstack/infrastructure.tf index 4ffac4f0..7644ff98 100644 --- a/openstack/infrastructure.tf +++ b/openstack/infrastructure.tf @@ -46,21 +46,21 @@ module "provision" { data "openstack_images_image_v2" "image" { for_each = var.instances - name_regex = lookup(each.valu.specs, "image", var.image) + name_regex = lookup(each.value, "image", var.image) most_recent = true } data "openstack_compute_flavor_v2" "flavors" { for_each = var.instances - name = each.value.specs.type + name = each.value.type } resource "openstack_compute_instance_v2" "instances" { for_each = module.design.instances_to_build name = format("%s-%s", var.cluster_name, each.key) - image_id = lookup(each.value.specs, "disk_size", 10) > data.openstack_compute_flavor_v2.flavors[each.value.prefix].disk ? null : data.openstack_images_image_v2.image[each.value.prefix].id + image_id = lookup(each.value, "disk_size", 10) > data.openstack_compute_flavor_v2.flavors[each.value.prefix].disk ? null : data.openstack_images_image_v2.image[each.value.prefix].id - flavor_name = each.value.specs.type + flavor_name = each.value.type user_data = base64gzip(module.configuration.user_data[each.key]) metadata = {} force_delete = true @@ -76,7 +76,7 @@ resource "openstack_compute_instance_v2" "instances" { } dynamic "block_device" { - for_each = lookup(each.value.specs, "disk_size", 10) > data.openstack_compute_flavor_v2.flavors[each.value.prefix].disk ? [{ volume_size = lookup(each.value.specs, "disk_size", 10) }] : [] + for_each = lookup(each.value, "disk_size", 10) > data.openstack_compute_flavor_v2.flavors[each.value.prefix].disk ? [{ volume_size = lookup(each.value, "disk_size", 10) }] : [] content { uuid = data.openstack_images_image_v2.image[each.value.prefix].id source_type = "image" @@ -84,7 +84,7 @@ resource "openstack_compute_instance_v2" "instances" { boot_index = 0 delete_on_termination = true volume_size = block_device.value.volume_size - volume_type = lookup(each.value.specs, "disk_type", null) + volume_type = lookup(each.value, "disk_type", null) } }