IBM-Cloud / terraform-provider-ibm

https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs
Mozilla Public License 2.0
341 stars 672 forks source link

Resource `ibm_pi_image` does not respect `pi_image_name` when importing a stock image #4964

Open smathews opened 12 months ago

smathews commented 12 months ago

Community Note

Terraform CLI and Terraform IBM Provider Version

Terraform v1.6.3 on linux_amd64

resource ibm_pi_image

Terraform Configuration Files

data "ibm_pi_catalog_images" "all" {
  pi_cloud_instance_id = data.ibm_resource_instance.power_workspace.guid
}

locals {
  redhat_92_image = data.ibm_pi_catalog_images.all.images[index(data.ibm_pi_catalog_images.all.images[*].name, "RHEL9-SP2")]
}

resource "ibm_pi_image" "redhat" {
  pi_image_name         = "RHEL9-ASPERA"
  pi_image_id           = local.redhat_92_image.image_id
  pi_cloud_instance_id  = data.ibm_resource_instance.power_workspace.guid
}

Debug Output

  # ibm_pi_image.redhat will be created
  + resource "ibm_pi_image" "redhat" {
      + id                     = (known after apply)
      + image_id               = (known after apply)
      + pi_cloud_instance_id   = "0f73d546-acf2-4898-8391-a5c442881def"
      + pi_image_bucket_access = "public"
      + pi_image_id            = "2dee28bc-417b-4979-b3da-3a28919151e1"
      + pi_image_name          = "RHEL9-ASPERA"
    }

Panic Output

Expected Behavior

Image would be created with the name RHEL9-ASPERA.

Actual Behavior

Image created with name of stock image RHEL9-SP2.

image

Steps to Reproduce

  1. terraform apply

Important Factoids

References

michaelkad commented 6 months ago

@smathews The pi_image_name is primarily utilized for COS. However, it's important to note that stock image names cannot be altered. If you're importing an image from your COS, then modifications can be made accordingly.