Skip to content

Commit

Permalink
add volume_id as a parameter to volumes
Browse files Browse the repository at this point in the history
  • Loading branch information
mboisson committed Jan 13, 2025
1 parent 3c1e6e1 commit cb02d51
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions openstack/infrastructure.tf
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ resource "openstack_compute_instance_v2" "instances" {
}

resource "openstack_blockstorage_volume_v3" "volumes" {
for_each = module.design.volumes
for_each = {
for x, values in module.design.volumes : x => true if values.volume_id != undef
}
name = "${var.cluster_name}-${each.key}"
description = "${var.cluster_name} ${each.key}"
size = each.value.size
Expand All @@ -110,7 +112,7 @@ resource "openstack_blockstorage_volume_v3" "volumes" {
resource "openstack_compute_volume_attach_v2" "attachments" {
for_each = module.design.volumes
instance_id = openstack_compute_instance_v2.instances[each.value.instance].id
volume_id = openstack_blockstorage_volume_v3.volumes[each.key].id
volume_id = try(each.value.volume_id, openstack_blockstorage_volume_v3.volumes[each.key].id)
}

locals {
Expand Down

0 comments on commit cb02d51

Please sign in to comment.