Skip to content

Commit

Permalink
Fix specs
Browse files Browse the repository at this point in the history
  • Loading branch information
cmd-ntrf committed Jan 15, 2025
1 parent a112ada commit 7201f3d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
7 changes: 5 additions & 2 deletions common/design/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
},
)
}
]
Expand Down
12 changes: 6 additions & 6 deletions openstack/infrastructure.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -76,15 +76,15 @@ 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"
destination_type = "volume"
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)
}
}

Expand Down

0 comments on commit 7201f3d

Please sign in to comment.