IBM-Cloud / terraform-provider-ibm

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

The datasource "ibm_is_bare_metal_server_initialization" doesn't provide a valid error if the bare metal is deleted outside the terraform context #4454

Open hkantare opened 1 year ago

hkantare commented 1 year ago

when there is error to retrieve data resource "ibm_is_bare_metal_server_initialization", there should be a more meaningful error message returned instead of reporting a terraform error. Additional details can be found in servicenow : CS3253979

ujjwal-ibm commented 1 year ago

looking into it

vcfvpc commented 1 year ago

@ujjwal-ibm There could be some misunderstanding of the original issue reported in the ticket. The bare metal server is not deleted, we met the error when trying to destroy the workspace. And after some investigation we found when the error happened, VPC bare metal API is broken, which cause the data "ibm_is_bare_metal_server_initialization" failed to get the password of the bare metal server. Such error should be caught and a meaningful error message should be sent instead of a terraform exception.

The code snippet is like

inside module "zone_bare_metal_esxi"

data "ibm_is_bare_metal_server_initialization" "esx_host_init_values" {
    bare_metal_server = ibm_is_bare_metal_server.esx_host.id
}

output "ibm_is_bare_metal_server_initialization" {
  value = data.ibm_is_bare_metal_server_initialization.esx_host_init_values
}

outside module "zone_bare_metal_esxi"

locals {
   hosts = {
    password = module.zone_bare_metal_esxi.ibm_is_bare_metal_server_initialization.user_accounts[0].password,
  }
}