diff --git a/go.mod b/go.mod index a7a84d94c5..21ec7e1b00 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.19 require ( github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20240216115622-a311507b4b5b - github.com/IBM-Cloud/power-go-client v1.6.0 + github.com/IBM-Cloud/power-go-client v1.6.0-beta10 github.com/IBM/apigateway-go-sdk v0.0.0-20210714141226-a5d5d49caaca github.com/IBM/appconfiguration-go-admin-sdk v0.3.0 github.com/IBM/appid-management-go-sdk v0.0.0-20210908164609-dd0e0eaf732f @@ -65,6 +65,7 @@ require ( github.com/IBM/go-sdk-core v1.1.0 github.com/IBM/mqcloud-go-sdk v0.0.4 github.com/IBM/sarama v1.41.2 + github.com/IBM/vmware-go-sdk v0.1.2 github.com/stretchr/testify v1.9.0 k8s.io/utils v0.0.0-20230313181309-38a27ef9d749 sigs.k8s.io/controller-runtime v0.14.1 diff --git a/go.sum b/go.sum index a0397807cc..ee8581804f 100644 --- a/go.sum +++ b/go.sum @@ -106,8 +106,8 @@ github.com/IBM-Cloud/bluemix-go v0.0.0-20240402122236-5c5b994a3f1a/go.mod h1:/7h github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20240216115622-a311507b4b5b h1:Wnq0BuprazpP41+nQlRpxpmAs8+8jyOqU50KrvFdJQ4= github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20240216115622-a311507b4b5b/go.mod h1:xUQL9SGAjoZFd4GNjrjjtEpjpkgU7RFXRyHesbKTjiY= github.com/IBM-Cloud/ibm-cloud-cli-sdk v0.5.3/go.mod h1:RiUvKuHKTBmBApDMUQzBL14pQUGKcx/IioKQPIcRQjs= -github.com/IBM-Cloud/power-go-client v1.6.0 h1:X+QX+WSF66+aouyaf4r+IeBLXUurAJj9+Bd+vH7G5I0= -github.com/IBM-Cloud/power-go-client v1.6.0/go.mod h1:0ad5Lcq1utoYVJx0uqooMjCpUaYaK0ItP9QJYtY6k0Y= +github.com/IBM-Cloud/power-go-client v1.6.0-beta10 h1:8Y1qyzBwYYN2MmgAuGFrHytltD8xtJLEbFvHZG6P6Xk= +github.com/IBM-Cloud/power-go-client v1.6.0-beta10/go.mod h1:bvErc8Wjz3yBlL+BHJ+ScuzuJtR+5EFasMvusluF+Yc= github.com/IBM-Cloud/softlayer-go v1.0.5-tf h1:koUAyF9b6X78lLLruGYPSOmrfY2YcGYKOj/Ug9nbKNw= github.com/IBM-Cloud/softlayer-go v1.0.5-tf/go.mod h1:6HepcfAXROz0Rf63krk5hPZyHT6qyx2MNvYyHof7ik4= github.com/IBM/apigateway-go-sdk v0.0.0-20210714141226-a5d5d49caaca h1:crniVcf+YcmgF03NmmfonXwSQ73oJF+IohFYBwknMxs= @@ -172,6 +172,8 @@ github.com/IBM/schematics-go-sdk v0.2.3 h1:lgTt0Sbudii3cuSk1YSQgrtiZAXDbBABAoVj3 github.com/IBM/schematics-go-sdk v0.2.3/go.mod h1:Tw2OSAPdpC69AxcwoyqcYYaGTTW6YpERF9uNEU+BFRQ= github.com/IBM/secrets-manager-go-sdk/v2 v2.0.4 h1:xa9e+POVqaXxXHXkSMCOVAbKdUNEu86jQmo5hcpd+L4= github.com/IBM/secrets-manager-go-sdk/v2 v2.0.4/go.mod h1:5gq8D8uWOIbqOm1uztay6lpOysgJaxxEsaVZLWGWb40= +github.com/IBM/vmware-go-sdk v0.1.2 h1:5lKWFyInWz9e2hwGsoFTEoLa1jYkD30SReN0fQ10w9M= +github.com/IBM/vmware-go-sdk v0.1.2/go.mod h1:2UGPBJju3jiv5VKKBBm9a5L6bzF/aJdKOKAzJ7HaOjA= github.com/IBM/vpc-beta-go-sdk v0.6.0 h1:wfM3AcW3zOM3xsRtZ+EA6+sESlGUjQ6Yf4n5QQyz4uc= github.com/IBM/vpc-beta-go-sdk v0.6.0/go.mod h1:fzHDAQIqH/5yJmYsKodKHLcqxMDT+yfH6vZjdiw8CQA= github.com/IBM/vpc-go-sdk v0.50.0 h1:+vnXYK0FXFXYqaS/5/X1XEqH0bbRotkzkerRk21ZEjE= diff --git a/ibm/acctest/acctest.go b/ibm/acctest/acctest.go index 21e404be70..e8c84025f5 100644 --- a/ibm/acctest/acctest.go +++ b/ibm/acctest/acctest.go @@ -219,6 +219,7 @@ var ( Pi_target_storage_tier string Pi_volume_clone_task_id string Pi_resource_group_id string + Pi_instance_id string ) var ( @@ -1074,6 +1075,11 @@ func init() { fmt.Println("[INFO] Set the environment variable PI_PVM_INSTANCE_ID for testing Pi_instance_name resource else it is set to default value 'terraform-test-power'") } + Pi_instance_id = os.Getenv("PI_PVM_INSTANCE_ID") + if Pi_instance_id == "" { + fmt.Println("[INFO] Set the environment variable PI_PVM_INSTANCE_ID for testing resource else it is not set") + } + Pi_dhcp_id = os.Getenv("PI_DHCP_ID") if Pi_dhcp_id == "" { Pi_dhcp_id = "terraform-test-power" diff --git a/ibm/provider/provider.go b/ibm/provider/provider.go index 9c81232548..afc4c5fe00 100644 --- a/ibm/provider/provider.go +++ b/ibm/provider/provider.go @@ -1219,6 +1219,8 @@ func Provider() *schema.Provider { "ibm_pi_volume_group": power.ResourceIBMPIVolumeGroup(), "ibm_pi_volume_onboarding": power.ResourceIBMPIVolumeOnboarding(), "ibm_pi_volume": power.ResourceIBMPIVolume(), + "ibm_pi_volumes_attach": power.ResourceIBMPIVolumesAttach(), + "ibm_pi_volumes_detach": power.ResourceIBMPIVolumesDetach(), "ibm_pi_vpn_connection": power.ResourceIBMPIVPNConnection(), "ibm_pi_workspace": power.ResourceIBMPIWorkspace(), diff --git a/ibm/service/power/ibm_pi_constants.go b/ibm/service/power/ibm_pi_constants.go index 8cb883ed13..511ea54528 100644 --- a/ibm/service/power/ibm_pi_constants.go +++ b/ibm/service/power/ibm_pi_constants.go @@ -4,9 +4,12 @@ import "time" const ( // Arguments + Arg_BootVolumeID = "pi_boot_volume_id" Arg_CloudConnectionName = "pi_cloud_connection_name" Arg_CloudInstanceID = "pi_cloud_instance_id" Arg_DatacenterZone = "pi_datacenter_zone" + Arg_DetachAllVolumes = "pi_detach_all_volumes" + Arg_DetachPrimaryBootVolume = "pi_detach_primary_boot_volume" Arg_DhcpCidr = "pi_cidr" Arg_DhcpCloudConnectionID = "pi_cloud_connection_id" Arg_DhcpDnsServer = "pi_dns_server" @@ -17,6 +20,7 @@ const ( Arg_IBMiPHA = "pi_ibmi_pha" Arg_IBMiRDSUsers = "pi_ibmi_rds_users" Arg_ImageName = "pi_image_name" + Arg_InstanceID = "pi_instance_id" Arg_InstanceName = "pi_instance_name" Arg_KeyName = "pi_key_name" Arg_NetworkName = "pi_network_name" @@ -41,6 +45,7 @@ const ( Arg_StorageType = "pi_storage_type" Arg_VolumeGroupID = "pi_volume_group_id" Arg_VolumeID = "pi_volume_id" + Arg_VolumeIDs = "pi_volume_ids" Arg_VolumeName = "pi_volume_name" Arg_VolumeOnboardingID = "pi_volume_onboarding_id" Arg_VTL = "vtl" diff --git a/ibm/service/power/resource_ibm_pi_volumes_attach.go b/ibm/service/power/resource_ibm_pi_volumes_attach.go new file mode 100644 index 0000000000..9890c27c8a --- /dev/null +++ b/ibm/service/power/resource_ibm_pi_volumes_attach.go @@ -0,0 +1,102 @@ +// Copyright IBM Corp. 2024 All Rights Reserved. +// Licensed under the Mozilla Public License v2.0 + +package power + +import ( + "context" + "fmt" + "log" + + st "github.com/IBM-Cloud/power-go-client/clients/instance" + "github.com/IBM-Cloud/power-go-client/power/models" + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" +) + +func ResourceIBMPIVolumesAttach() *schema.Resource { + return &schema.Resource{ + CreateContext: resourceIBMPIVolumesAttachCreate, + ReadContext: resourceIBMPIVolumesAttachRead, + DeleteContext: resourceIBMPIVolumesAttachDelete, + Importer: &schema.ResourceImporter{}, + + Schema: map[string]*schema.Schema{ + // Arguments + Arg_CloudInstanceID: { + Description: "The GUID of the service instance associated with an account.", + ForceNew: true, + Required: true, + Type: schema.TypeString, + ValidateFunc: validation.NoZeroValues, + }, + Arg_InstanceID: { + Description: "The unique identifier of the instance.", + ForceNew: true, + Required: true, + Type: schema.TypeString, + ValidateFunc: validation.NoZeroValues, + }, + Arg_VolumeIDs: { + Description: "List of volumes to be detached from a pi_instance; required if detachAllVolumes is not provided.", + Elem: &schema.Schema{Type: schema.TypeString}, + ForceNew: true, + Required: true, + Type: schema.TypeList, + ValidateFunc: validation.NoZeroValues, + }, + Arg_BootVolumeID: { + Description: "Primary Boot Volume Id.", + ForceNew: true, + Optional: true, + Type: schema.TypeString, + }, + }, + } +} + +func resourceIBMPIVolumesAttachCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + sess, err := meta.(conns.ClientSession).IBMPISession() + if err != nil { + return diag.FromErr(err) + } + + body := &models.VolumesAttach{} + pvmInstanceID := d.Get(Arg_InstanceID).(string) + cloudInstanceID := d.Get(Arg_CloudInstanceID).(string) + + var volumeIDs []string + if _, ok := d.GetOk(Arg_VolumeIDs); ok { + for _, v := range d.Get(Arg_VolumeIDs).([]interface{}) { + volumeIDsItem := v.(string) + volumeIDs = append(volumeIDs, volumeIDsItem) + } + body.VolumeIDs = volumeIDs + } + + if _, ok := d.GetOk(Arg_BootVolumeID); ok { + body.BootVolumeID = d.Get(Arg_BootVolumeID).(string) + } + volClient := st.NewIBMPIVolumeClient(ctx, sess, cloudInstanceID) + volinfo, err := volClient.BulkVolumeAttach(pvmInstanceID, body) + if err != nil { + return diag.FromErr(err) + } + + log.Printf("[DEBUG] Volumes attach accepted: %s", *volinfo.Summary) + + d.SetId(fmt.Sprintf("%s/%s", cloudInstanceID, pvmInstanceID)) + + return resourceIBMPIVolumesAttachRead(ctx, d, meta) +} + +func resourceIBMPIVolumesAttachRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + return nil +} + +func resourceIBMPIVolumesAttachDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + d.SetId("") + return nil +} diff --git a/ibm/service/power/resource_ibm_pi_volumes_attach_test.go b/ibm/service/power/resource_ibm_pi_volumes_attach_test.go new file mode 100644 index 0000000000..0d6d469068 --- /dev/null +++ b/ibm/service/power/resource_ibm_pi_volumes_attach_test.go @@ -0,0 +1,37 @@ +// Copyright IBM Corp. 2024 All Rights Reserved. +// Licensed under the Mozilla Public License v2.0 + +package power_test + +import ( + "fmt" + "testing" + + acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccIBMPIVolumesAttach(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheck(t) }, + Providers: acc.TestAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccCheckIBMPIVolumesAttachConfig(), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet("ibm_pi_volumes_attach.pi_volumes_attach_instance", "id"), + ), + }, + }, + }) +} + +func testAccCheckIBMPIVolumesAttachConfig() string { + return fmt.Sprintf(` + resource "ibm_pi_volumes_attach" "pi_volumes_attach_instance" { + pi_cloud_instance_id = "%[1]s" + pi_instance_id = "%[2]s" + pi_volume_ids = ["6679e1ef-d98a-4487-b2a6-51c242136884"] + } + `, acc.Pi_cloud_instance_id, acc.Pi_instance_id) +} diff --git a/ibm/service/power/resource_ibm_pi_volumes_detach.go b/ibm/service/power/resource_ibm_pi_volumes_detach.go new file mode 100644 index 0000000000..fc66568eaf --- /dev/null +++ b/ibm/service/power/resource_ibm_pi_volumes_detach.go @@ -0,0 +1,113 @@ +// Copyright IBM Corp. 2024 All Rights Reserved. +// Licensed under the Mozilla Public License v2.0 + +package power + +import ( + "context" + "fmt" + "log" + + st "github.com/IBM-Cloud/power-go-client/clients/instance" + "github.com/IBM-Cloud/power-go-client/power/models" + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" +) + +func ResourceIBMPIVolumesDetach() *schema.Resource { + return &schema.Resource{ + CreateContext: resourceIBMPIVolumesDetachCreate, + ReadContext: resourceIBMPIVolumesDetachRead, + DeleteContext: resourceIBMPIVolumesDetachDelete, + Importer: &schema.ResourceImporter{}, + + Schema: map[string]*schema.Schema{ + // Arguments + Arg_CloudInstanceID: { + Description: "The GUID of the service instance associated with an account.", + ForceNew: true, + Required: true, + Type: schema.TypeString, + ValidateFunc: validation.NoZeroValues, + }, + Arg_InstanceID: { + Description: "The unique identifier of the instance.", + ForceNew: true, + Required: true, + Type: schema.TypeString, + ValidateFunc: validation.NoZeroValues, + }, + Arg_DetachAllVolumes: { + ConflictsWith: []string{Arg_VolumeIDs}, + Description: "Indicates if all volumes, except primary boot volume, attached to the pi_instance should be detached (default=false); required if volumeIDs is not provided.", + ForceNew: true, + Optional: true, + Type: schema.TypeBool, + }, + Arg_DetachPrimaryBootVolume: { + Description: "Indicates if primary boot volume attached to the pi_instance should be detached (default=false).", + ForceNew: true, + Optional: true, + Type: schema.TypeBool, + }, + Arg_VolumeIDs: { + ConflictsWith: []string{Arg_DetachAllVolumes}, + Description: "List of volumes to be detached from a pi_instance; required if detachAllVolumes is not provided.", + Elem: &schema.Schema{Type: schema.TypeString}, + ForceNew: true, + Optional: true, + Type: schema.TypeList, + }, + }, + } +} + +func resourceIBMPIVolumesDetachCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + sess, err := meta.(conns.ClientSession).IBMPISession() + if err != nil { + return diag.FromErr(err) + } + + pvmInstanceID := d.Get(Arg_InstanceID).(string) + cloudInstanceID := d.Get(Arg_CloudInstanceID).(string) + body := &models.VolumesDetach{} + var volumeIDs []string + if _, ok := d.GetOk(Arg_VolumeIDs); ok { + for _, v := range d.Get(Arg_VolumeIDs).([]interface{}) { + volumeIDsItem := v.(string) + volumeIDs = append(volumeIDs, volumeIDsItem) + } + body.VolumeIDs = volumeIDs + } + + if _, ok := d.GetOk(Arg_DetachAllVolumes); ok { + body.DetachAllVolumes = flex.PtrToBool(d.Get(Arg_DetachAllVolumes).(bool)) + } + if _, ok := d.GetOk(Arg_DetachPrimaryBootVolume); ok { + body.DetachPrimaryBootVolume = flex.PtrToBool(d.Get(Arg_DetachPrimaryBootVolume).(bool)) + } + + volClient := st.NewIBMPIVolumeClient(ctx, sess, cloudInstanceID) + volinfo, err := volClient.BulkVolumeDetach(pvmInstanceID, body) + if err != nil { + return diag.FromErr(err) + } + + log.Printf("[DEBUG] Volumes detach accepted: %s", *volinfo.Summary) + + d.SetId(fmt.Sprintf("%s/%s", cloudInstanceID, pvmInstanceID)) + + return resourceIBMPIVolumesAttachRead(ctx, d, meta) +} + +func resourceIBMPIVolumesDetachRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + return nil +} + +func resourceIBMPIVolumesDetachDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + d.SetId("") + return nil +} diff --git a/ibm/service/power/resource_ibm_pi_volumes_detach_test.go b/ibm/service/power/resource_ibm_pi_volumes_detach_test.go new file mode 100644 index 0000000000..f26921ce12 --- /dev/null +++ b/ibm/service/power/resource_ibm_pi_volumes_detach_test.go @@ -0,0 +1,37 @@ +// Copyright IBM Corp. 2024 All Rights Reserved. +// Licensed under the Mozilla Public License v2.0 + +package power_test + +import ( + "fmt" + "testing" + + acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccIBMPIVolumesDetach(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheck(t) }, + Providers: acc.TestAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccCheckIBMPIVolumesDetachConfig(), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet("ibm_pi_volumes_detach.pi_volumes_detach_instance", "id"), + ), + }, + }, + }) +} + +func testAccCheckIBMPIVolumesDetachConfig() string { + return fmt.Sprintf(` + resource "ibm_pi_volumes_detach" "pi_volumes_detach_instance" { + pi_cloud_instance_id = "%[1]s" + pi_instance_id = "%[2]s" + pi_detach_all_volumes = true + } + `, acc.Pi_cloud_instance_id, acc.Pi_instance_id) +} diff --git a/website/docs/r/pi_instance.html.markdown b/website/docs/r/pi_instance.html.markdown index 50e13f9b8b..8dbf6f1491 100644 --- a/website/docs/r/pi_instance.html.markdown +++ b/website/docs/r/pi_instance.html.markdown @@ -98,7 +98,7 @@ Review the argument references that you can specify for your resource. - `pi_sap_deployment_type` - (Optional, String) Custom SAP deployment type information (For Internal Use Only). - `pi_shared_processor_pool` - (Optional, String) The shared processor pool for instance deployment. Conflicts with `pi_sap_profile_id`. - `pi_storage_pool` - (Optional, String) Storage Pool for server deployment; if provided then `pi_affinity_policy` will be ignored; Only valid when you deploy one of the IBM supplied stock images. Storage pool for a custom image (an imported image or an image that is created from a VM capture) defaults to the storage pool the image was created in. -- `pi_storage_pool_affinity` - (Optional, Boolean) Indicates if all volumes attached to the server must reside in the same storage pool. The default value is `true`. To attach data volumes from a different storage pool (mixed storage) set to `false` and use `pi_volume_attach` resource. Once set to `false`, cannot be set back to `true` unless all volumes attached reside in the same storage type and pool. +- `pi_storage_pool_affinity` - (Optional, Boolean) Indicates if all volumes attached to the server must reside in the same storage pool. The default value is `true`. To attach data volumes from a different storage pool (mixed storage) set to `false` and use `ibm_pi_volume_attach` or `ibm_pi_volumes_attach` resource. Once set to `false`, cannot be set back to `true` unless all volumes attached reside in the same storage type and pool. - `pi_storage_type` - (Optional, String) - Storage type for server deployment; If storage type is not provided the storage type will default to `tier3`. - `pi_storage_connection` - (Optional, String) - Storage Connectivity Group (SCG) for server deployment. Only supported value is `vSCSI`. - `pi_sys_type` - (Optional, String) The type of system on which to create the VM (s922/e880/e980/s1022). diff --git a/website/docs/r/pi_volumes_attach.html.markdown b/website/docs/r/pi_volumes_attach.html.markdown new file mode 100644 index 0000000000..48b4f93884 --- /dev/null +++ b/website/docs/r/pi_volumes_attach.html.markdown @@ -0,0 +1,60 @@ +--- +subcategory: "Power Systems" +layout: "ibm" +page_title: "IBM : ibm_pi_volumes_attach" +description: |- + Manages volumes in Power Virtual Server cloud. +--- + +# ibm_pi_volumes_attach + +Attach volumes to a Power Systems Virtual Server instance, see [volumes](https://cloud.ibm.com/apidocs/power-cloud#pcloud-v2-pvminstances-volumes-post) + +## Example Usage + +The following example attach volumes to power virtual instance. + +```terraform +resource "ibm_pi_volumes_attach" "pi_volumes_attach_instance" { + pi_cloud_instance_id = "" + pi_instance_id = "" + pi_volume_ids = ["volume ids"] +} +``` + +## Notes + +* Please find [supported Regions](https://cloud.ibm.com/apidocs/power-cloud#endpoint) for endpoints. +* If a Power cloud instance is provisioned at `lon04`, The provider level attributes should be as follows: + * `region` - `lon` + * `zone` - `lon04` + +Example usage: + + ```terraform + provider "ibm" { + region = "lon" + zone = "lon04" + } + ``` + +## Timeouts + +`pi_volumes_attach` provides the following [Timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) configuration options: + +* `create` - (Default 10 minutes) Used for attaching volumes to a power virtual server instance. + +## Argument Reference + +You can specify the following arguments for this resource. + +* `pi_boot_volume_id` - (Optional, Forces new resource, String) Primary Boot Volume ID. +* `pi_cloud_instance_id` - (Required, Forces new resource, String) The GUID of the service instance associated with an account. +* `pi_instance_id` - (Required, Forces new resource, String) The unique identifier of an instance. +* `pi_volume_ids` - (Required, Forces new resource, List) List of volumes to be attached to a `pi_instance`. + +## Attribute Reference + +After your resource is created, you can read values from the listed arguments and the following attributes. + +* `id` - The unique identifier of volumes attach. The ID is composed of `/` diff --git a/website/docs/r/pi_volumes_detach.hmtl.markdown b/website/docs/r/pi_volumes_detach.hmtl.markdown new file mode 100644 index 0000000000..c84c97be3b --- /dev/null +++ b/website/docs/r/pi_volumes_detach.hmtl.markdown @@ -0,0 +1,61 @@ +--- +subcategory: "Power Systems" +layout: "ibm" +page_title: "IBM : ibm_pi_volumes_detach" +description: |- + Manages volumes in Power Virtual Server cloud. +--- + +# ibm_pi_volumes_attach + +Detach volumes to a Power Systems Virtual Server instance, see [volumes](https://cloud.ibm.com/apidocs/power-cloud#pcloud-v2-pvminstances-volumes-post) + +## Example Usage + +The following example attach volumes to power virtual instance. + +```terraform +resource "ibm_pi_volumes_detach" "pi_volumes_detach_instance" { + pi_cloud_instance_id = "" + pi_instance_id = "" + pi_detach_all_volumes = true +} +``` + +## Notes + +* Please find [supported Regions](https://cloud.ibm.com/apidocs/power-cloud#endpoint) for endpoints. +* If a Power cloud instance is provisioned at `lon04`, The provider level attributes should be as follows: + * `region` - `lon` + * `zone` - `lon04` + +Example usage: + + ```terraform + provider "ibm" { + region = "lon" + zone = "lon04" + } + ``` + +## Timeouts + +`pi_volumes_detach` provides the following [Timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) configuration options: + +* `delete` - (Default 10 minutes) Used for detaching volumes from a power virtual server instance. + +## Argument Reference + +You can specify the following arguments for this resource. + +* `pi_cloud_instance_id` - (Required, Forces new resource, String) The GUID of the service instance associated with an account. +* `pi_detach_all_volumes` - (Optional, Forces new resource, Boolean) Indicates if all volumes, except primary boot volume, attached to the `pi_instance` should be detached (default=`false`); required if `pi_volume_ids` is not provided. +* `pi_detach_primary_boot_volume` - (Optional, Forces new resource, Boolean) Indicates if primary boot volume attached to the `pi_instance` should be detached (default=`false`). +* `pi_instance_id` - (Required, Forces new resource, String) The unique identifier of an instance. +* `pi_volume_ids` - (Optional, Forces new resource, List) List of volumes to be detached from a `pi_instance`; required if `pi_detach_all_volumes` is not provided. + +## Attribute Reference + +After your resource is created, you can read values from the listed arguments and the following attributes. + +* `id` - The unique identifier of volumes detach. The ID is composed of `/`