Skip to content

Commit

Permalink
fix: image import from data source lookup (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
surajsbharadwaj authored Oct 27, 2023
1 parent e542faa commit 7224211
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions modules/pi-workspace/pi_images.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ data "ibm_pi_catalog_images" "catalog_images_ds" {
}

locals {
catalog_images_to_import = flatten([for stock_image in data.ibm_pi_catalog_images.catalog_images_ds.images : [for image_name in var.pi_image_names : stock_image if stock_image.name == image_name]])
catalog_images = { for stock_image in data.ibm_pi_catalog_images.catalog_images_ds.images : stock_image.name => stock_image.image_id }
}

#######################################################
Expand All @@ -19,7 +19,7 @@ resource "ibm_pi_image" "import_images" {

for_each = toset(var.pi_image_names)
pi_cloud_instance_id = ibm_resource_instance.pi_workspace.guid
pi_image_id = local.catalog_images_to_import[index((var.pi_image_names), each.key)].image_id
pi_image_id = lookup(local.catalog_images, each.key)
pi_image_name = each.key

timeouts {
Expand All @@ -33,6 +33,5 @@ resource "ibm_pi_image" "import_images" {
################

locals {

pi_images = { for image in ibm_pi_image.import_images : image.pi_image_name => image.image_id }
}

0 comments on commit 7224211

Please sign in to comment.