From 5bd14aa53c59a8383703cfde47f9ce7e22b1634a Mon Sep 17 00:00:00 2001 From: Alexander Kita Date: Sat, 16 Nov 2024 16:49:35 -0600 Subject: [PATCH] Set cloud instance ID and host group ID in host, update docs with import --- ibm/service/power/resource_ibm_pi_host.go | 6 ++++++ website/docs/r/pi_host.html.markdown | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/ibm/service/power/resource_ibm_pi_host.go b/ibm/service/power/resource_ibm_pi_host.go index 8e045f35fd..f67b6ca80f 100644 --- a/ibm/service/power/resource_ibm_pi_host.go +++ b/ibm/service/power/resource_ibm_pi_host.go @@ -246,6 +246,12 @@ func resourceIBMPIHostRead(ctx context.Context, d *schema.ResourceData, meta int } return diag.FromErr(err) } + d.Set(Arg_CloudInstanceID, cloudInstanceID) + hostGroupID, err := getLastPart(host.HostGroup.Href) + if err != nil { + return diag.FromErr(err) + } + d.Set(Arg_HostGroupID, hostGroupID) d.Set(Attr_HostID, host.ID) if host.Capacity != nil { diff --git a/website/docs/r/pi_host.html.markdown b/website/docs/r/pi_host.html.markdown index a4d9eaeb47..474e2cd09a 100644 --- a/website/docs/r/pi_host.html.markdown +++ b/website/docs/r/pi_host.html.markdown @@ -92,3 +92,13 @@ In addition to all argument reference list, you can access the following attribu - `status` - (String) Status of the host `enabled` or `disabled`. - `sys_type` - (String) System type. - `user_tags` - (List) The user tags attached to this resource. + +## Import + +The `ibm_pi_host` resource can be imported by using `pi_cloud_instance_id` and `host_id`. + +### Example + +```bash +terraform import ibm_pi_host.example d7bec597-4726-451f-8a63-e62e6f19c32c/b17a2b7f-77ab-491c-811e-495f8d4c8947 +``` \ No newline at end of file