From b8ac511abd96c28bf0ca8251b00e946f986c4a54 Mon Sep 17 00:00:00 2001 From: michaelkad Date: Tue, 21 May 2024 08:41:41 -0500 Subject: [PATCH] Refactor Network Port --- ibm/service/power/ibm_pi_constants.go | 5 + .../resource_ibm_pi_network_port_attach.go | 150 ++++++++++-------- ...esource_ibm_pi_network_port_attach_test.go | 116 +++++++++++--- .../r/pi_network_port_attach.html.markdown | 37 +++-- 4 files changed, 200 insertions(+), 108 deletions(-) diff --git a/ibm/service/power/ibm_pi_constants.go b/ibm/service/power/ibm_pi_constants.go index 20b0ef58e9..29a85c02bb 100644 --- a/ibm/service/power/ibm_pi_constants.go +++ b/ibm/service/power/ibm_pi_constants.go @@ -27,6 +27,8 @@ const ( Arg_KeyName = "pi_key_name" Arg_LanguageCode = "pi_language_code" Arg_NetworkName = "pi_network_name" + Arg_NetworkPortDescription = "pi_network_port_description" + Arg_NetworkPortIPAddress = "pi_network_port_ipaddress" Arg_PIInstanceSharedProcessorPool = "pi_shared_processor_pool" Arg_PlacementGroupName = "pi_placement_group_name" Arg_PlacementGroupPolicy = "pi_placement_group_policy" @@ -200,6 +202,7 @@ const ( Attr_NetworkID = "network_id" Attr_NetworkName = "network_name" Attr_NetworkPorts = "network_ports" + Attr_NetworkPortID = "network_port_id" Attr_Networks = "networks" Attr_NumberOfVolumes = "number_of_volumes" Attr_Onboardings = "onboardings" @@ -335,6 +338,7 @@ const ( State_Adding = "adding" State_Available = "available" State_BUILD = "BUILD" + State_Build = "build" State_Creating = "creating" State_Deleted = "deleted" State_Deleting = "deleting" @@ -348,6 +352,7 @@ const ( State_Provisioning = "provisioning" State_Removed = "removed" State_Retry = "retry" + State_Down = "down" // Health Health_OK = "OK" diff --git a/ibm/service/power/resource_ibm_pi_network_port_attach.go b/ibm/service/power/resource_ibm_pi_network_port_attach.go index e0e342e15a..a64ee8c18f 100644 --- a/ibm/service/power/resource_ibm_pi_network_port_attach.go +++ b/ibm/service/power/resource_ibm_pi_network_port_attach.go @@ -7,13 +7,14 @@ import ( "context" "fmt" "log" + "strings" "time" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - st "github.com/IBM-Cloud/power-go-client/clients/instance" - "github.com/IBM-Cloud/power-go-client/helpers" + "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" @@ -33,53 +34,62 @@ func ResourceIBMPINetworkPortAttach() *schema.Resource { Delete: schema.DefaultTimeout(60 * time.Minute), }, Schema: map[string]*schema.Schema{ - helpers.PICloudInstanceId: { - Type: schema.TypeString, - Required: true, - ForceNew: true, + Arg_CloudInstanceID: { + Description: "The GUID of the service instance associated with an account.", + ForceNew: true, + Required: true, + Type: schema.TypeString, + ValidateFunc: validation.NoZeroValues, }, - helpers.PIInstanceId: { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: "Instance id to attach the network port to", + Arg_NetworkName: { + Description: "Network Name - This is the subnet name in the Cloud instance.", + ForceNew: true, + Required: true, + Type: schema.TypeString, + ValidateFunc: validation.NoZeroValues, }, - helpers.PINetworkName: { - Type: schema.TypeString, - Required: true, + Arg_NetworkPortDescription: { + Default: "Port Created via Terraform", + Description: "A human readable description for this network Port.", ForceNew: true, - Description: "Network Name - This is the subnet name in the Cloud instance", - }, - helpers.PINetworkPortDescription: { - Type: schema.TypeString, Optional: true, + Type: schema.TypeString, + }, + Arg_NetworkPortIPAddress: { + Description: "The requested ip address of this port.", + Computed: true, ForceNew: true, - Description: "A human readable description for this network Port", - Default: "Port Created via Terraform", + Optional: true, + Type: schema.TypeString, }, - helpers.PINetworkPortIPAddress: { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Computed: true, + Arg_PVMInstanceId: { + Description: "Instance id to attach the network port to.", + ForceNew: true, + Required: true, + Type: schema.TypeString, + ValidateFunc: validation.NoZeroValues, }, - //Computed Attributes - "macaddress": { - Type: schema.TypeString, - Computed: true, + // Attributes + Attr_MacAddress: { + Description: "The MAC address of the port.", + Computed: true, + Type: schema.TypeString, }, - "network_port_id": { - Type: schema.TypeString, - Computed: true, + Attr_NetworkPortID: { + Description: "The ID of the port.", + Computed: true, + Type: schema.TypeString, }, - "status": { - Type: schema.TypeString, - Computed: true, + Attr_PublicIP: { + Description: " The public IP associated with the port.", + Computed: true, + Type: schema.TypeString, }, - "public_ip": { - Type: schema.TypeString, - Computed: true, + Attr_Status: { + Description: "The status of the port.", + Computed: true, + Type: schema.TypeString, }, }, } @@ -91,13 +101,13 @@ func resourceIBMPINetworkPortAttachCreate(ctx context.Context, d *schema.Resourc if err != nil { return diag.FromErr(err) } - cloudInstanceID := d.Get(helpers.PICloudInstanceId).(string) - networkname := d.Get(helpers.PINetworkName).(string) - instanceID := d.Get(helpers.PIInstanceId).(string) - description := d.Get(helpers.PINetworkPortDescription).(string) + cloudInstanceID := d.Get(Arg_CloudInstanceID).(string) + networkname := d.Get(Arg_NetworkName).(string) + instanceID := d.Get(Arg_PVMInstanceId).(string) + description := d.Get(Arg_NetworkPortDescription).(string) nwportBody := &models.NetworkPortCreate{Description: description} - if v, ok := d.GetOk(helpers.PINetworkPortIPAddress); ok { + if v, ok := d.GetOk(Arg_NetworkPortIPAddress); ok { ipaddress := v.(string) nwportBody.IPAddress = ipaddress } @@ -107,7 +117,7 @@ func resourceIBMPINetworkPortAttachCreate(ctx context.Context, d *schema.Resourc PvmInstanceID: &instanceID, } - client := st.NewIBMPINetworkClient(ctx, sess, cloudInstanceID) + client := instance.NewIBMPINetworkClient(ctx, sess, cloudInstanceID) networkPortResponse, err := client.CreatePort(networkname, nwportBody) if err != nil { @@ -152,19 +162,19 @@ func resourceIBMPINetworkPortAttachRead(ctx context.Context, d *schema.ResourceD networkname := parts[1] portID := parts[2] - networkC := st.NewIBMPINetworkClient(ctx, sess, cloudInstanceID) + networkC := instance.NewIBMPINetworkClient(ctx, sess, cloudInstanceID) networkdata, err := networkC.GetPort(networkname, portID) if err != nil { return diag.FromErr(err) } - d.Set(helpers.PINetworkPortIPAddress, networkdata.IPAddress) - d.Set(helpers.PINetworkPortDescription, networkdata.Description) - d.Set(helpers.PIInstanceId, networkdata.PvmInstance.PvmInstanceID) - d.Set("macaddress", networkdata.MacAddress) - d.Set("status", networkdata.Status) - d.Set("network_port_id", networkdata.PortID) - d.Set("public_ip", networkdata.ExternalIP) + d.Set(Arg_NetworkPortIPAddress, networkdata.IPAddress) + d.Set(Arg_NetworkPortDescription, networkdata.Description) + d.Set(Arg_PVMInstanceId, networkdata.PvmInstance.PvmInstanceID) + d.Set(Attr_MacAddress, networkdata.MacAddress) + d.Set(Attr_Status, networkdata.Status) + d.Set(Attr_NetworkPortID, networkdata.PortID) + d.Set(Attr_PublicIP, networkdata.ExternalIP) return nil } @@ -185,7 +195,7 @@ func resourceIBMPINetworkPortAttachDelete(ctx context.Context, d *schema.Resourc networkname := parts[1] portID := parts[2] - client := st.NewIBMPINetworkClient(ctx, sess, cloudInstanceID) + client := instance.NewIBMPINetworkClient(ctx, sess, cloudInstanceID) log.Printf("Calling the delete with the following params delete with cloud instance (%s) and networkid (%s) and portid (%s) ", cloudInstanceID, networkname, portID) err = client.DeletePort(networkname, portID) @@ -197,12 +207,12 @@ func resourceIBMPINetworkPortAttachDelete(ctx context.Context, d *schema.Resourc return nil } -func isWaitForIBMPINetworkportAvailable(ctx context.Context, client *st.IBMPINetworkClient, id string, networkname string, timeout time.Duration) (interface{}, error) { +func isWaitForIBMPINetworkportAvailable(ctx context.Context, client *instance.IBMPINetworkClient, id string, networkname string, timeout time.Duration) (interface{}, error) { log.Printf("Waiting for Power Network (%s) that was created for Network Zone (%s) to be available.", id, networkname) - stateConf := &resource.StateChangeConf{ - Pending: []string{"retry", helpers.PINetworkProvisioning}, - Target: []string{"DOWN"}, + stateConf := &retry.StateChangeConf{ + Pending: []string{State_Retry, State_Build}, + Target: []string{State_Down}, Refresh: isIBMPINetworkportRefreshFunc(client, id, networkname), Timeout: timeout, Delay: 10 * time.Second, @@ -212,7 +222,7 @@ func isWaitForIBMPINetworkportAvailable(ctx context.Context, client *st.IBMPINet return stateConf.WaitForStateContext(ctx) } -func isIBMPINetworkportRefreshFunc(client *st.IBMPINetworkClient, id, networkname string) resource.StateRefreshFunc { +func isIBMPINetworkportRefreshFunc(client *instance.IBMPINetworkClient, id, networkname string) retry.StateRefreshFunc { log.Printf("Calling the IsIBMPINetwork Refresh Function....with the following id (%s) for network port and following id (%s) for network name and waiting for network to be READY", id, networkname) return func() (interface{}, string, error) { @@ -221,20 +231,20 @@ func isIBMPINetworkportRefreshFunc(client *st.IBMPINetworkClient, id, networknam return nil, "", err } - if *network.Status == "DOWN" { + if strings.ToLower(*network.Status) == State_Down { log.Printf(" The port has been created with the following ip address and attached to an instance ") - return network, "DOWN", nil + return network, State_Down, nil } - return network, helpers.PINetworkProvisioning, nil + return network, State_Build, nil } } -func isWaitForIBMPINetworkPortAttachAvailable(ctx context.Context, client *st.IBMPINetworkClient, id, networkname, instanceid string, timeout time.Duration) (interface{}, error) { +func isWaitForIBMPINetworkPortAttachAvailable(ctx context.Context, client *instance.IBMPINetworkClient, id, networkname, instanceid string, timeout time.Duration) (interface{}, error) { log.Printf("Waiting for Power Network (%s) that was created for Network Zone (%s) to be available.", id, networkname) - stateConf := &resource.StateChangeConf{ - Pending: []string{"retry", helpers.PINetworkProvisioning}, - Target: []string{"ACTIVE"}, + stateConf := &retry.StateChangeConf{ + Pending: []string{State_Retry, State_Build}, + Target: []string{State_Active}, Refresh: isIBMPINetworkPortAttachRefreshFunc(client, id, networkname, instanceid), Timeout: timeout, Delay: 10 * time.Second, @@ -244,7 +254,7 @@ func isWaitForIBMPINetworkPortAttachAvailable(ctx context.Context, client *st.IB return stateConf.WaitForStateContext(ctx) } -func isIBMPINetworkPortAttachRefreshFunc(client *st.IBMPINetworkClient, id, networkname, instanceid string) resource.StateRefreshFunc { +func isIBMPINetworkPortAttachRefreshFunc(client *instance.IBMPINetworkClient, id, networkname, instanceid string) retry.StateRefreshFunc { log.Printf("Calling the IsIBMPINetwork Refresh Function....with the following id (%s) for network port and following id (%s) for network name and waiting for network to be READY", id, networkname) return func() (interface{}, string, error) { @@ -253,11 +263,11 @@ func isIBMPINetworkPortAttachRefreshFunc(client *st.IBMPINetworkClient, id, netw return nil, "", err } - if *network.Status == "ACTIVE" && network.PvmInstance.PvmInstanceID == instanceid { + if strings.ToLower(*network.Status) == State_Active && network.PvmInstance.PvmInstanceID == instanceid { log.Printf(" The port has been created with the following ip address and attached to an instance ") - return network, "ACTIVE", nil + return network, State_Active, nil } - return network, helpers.PINetworkProvisioning, nil + return network, State_Build, nil } } diff --git a/ibm/service/power/resource_ibm_pi_network_port_attach_test.go b/ibm/service/power/resource_ibm_pi_network_port_attach_test.go index 7980808608..f687681aa7 100644 --- a/ibm/service/power/resource_ibm_pi_network_port_attach_test.go +++ b/ibm/service/power/resource_ibm_pi_network_port_attach_test.go @@ -17,47 +17,57 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" - st "github.com/IBM-Cloud/power-go-client/clients/instance" + "github.com/IBM-Cloud/power-go-client/clients/instance" ) func TestAccIBMPINetworkPortAttachbasic(t *testing.T) { - name := fmt.Sprintf("tf-pi-network-port-attach-%d", acctest.RandIntRange(10, 100)) + name := fmt.Sprintf("tf-pi-instance-%d", acctest.RandIntRange(10, 100)) + networkName := fmt.Sprintf("tf-pi-network-port-attach-test-%d", acctest.RandIntRange(10, 100)) + networkName2 := fmt.Sprintf("tf-pi-network-port-attach-test-%d", acctest.RandIntRange(10, 100)) + health := "OK" + resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, Providers: acc.TestAccProviders, CheckDestroy: testAccCheckIBMPINetworkPortAttachDestroy, Steps: []resource.TestStep{ { - Config: testAccCheckIBMPINetworkPortAttachConfig(name), + Config: testAccCheckIBMPINetworkPortAttachConfig(name, networkName, networkName2, health), Check: resource.ComposeTestCheckFunc( testAccCheckIBMPINetworkPortAttachExists("ibm_pi_network_port_attach.power_network_port_attach"), resource.TestCheckResourceAttr( - "ibm_pi_network_port_attach.power_network_port_attach", "pi_network_name", name), + "ibm_pi_network_port_attach.power_network_port_attach", "pi_network_name", networkName2), resource.TestCheckResourceAttrSet("ibm_pi_network_port_attach.power_network_port_attach", "id"), resource.TestCheckResourceAttrSet("ibm_pi_network_port_attach.power_network_port_attach", "network_port_id"), resource.TestCheckResourceAttrSet("ibm_pi_network_port_attach.power_network_port_attach", "public_ip"), ), + ExpectNonEmptyPlan: true, }, }, }) } func TestAccIBMPINetworkPortAttachVlanbasic(t *testing.T) { - name := fmt.Sprintf("tf-pi-network-port-attach-%d", acctest.RandIntRange(10, 100)) + name := fmt.Sprintf("tf-pi-instance-%d", acctest.RandIntRange(10, 100)) + networkName := fmt.Sprintf("tf-pi-network-port-attach-test-%d", acctest.RandIntRange(10, 100)) + networkName2 := fmt.Sprintf("tf-pi-network-port-attach-test-%d", acctest.RandIntRange(10, 100)) + health := "OK" + resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, Providers: acc.TestAccProviders, CheckDestroy: testAccCheckIBMPINetworkPortAttachDestroy, Steps: []resource.TestStep{ { - Config: testAccCheckIBMPINetworkPortAttachVlanConfig(name), + Config: testAccCheckIBMPINetworkPortAttachVlanConfig(name, networkName, networkName2, health), Check: resource.ComposeTestCheckFunc( testAccCheckIBMPINetworkPortAttachExists("ibm_pi_network_port_attach.power_network_port_attach"), resource.TestCheckResourceAttr( - "ibm_pi_network_port_attach.power_network_port_attach", "pi_network_name", name), + "ibm_pi_network_port_attach.power_network_port_attach", "pi_network_name", networkName2), resource.TestCheckResourceAttrSet("ibm_pi_network_port_attach.power_network_port_attach", "id"), resource.TestCheckResourceAttrSet("ibm_pi_network_port_attach.power_network_port_attach", "network_port_id"), ), + ExpectNonEmptyPlan: true, }, }, }) @@ -78,7 +88,7 @@ func testAccCheckIBMPINetworkPortAttachDestroy(s *terraform.State) error { cloudInstanceID := parts[0] networkname := parts[1] portID := parts[2] - networkC := st.NewIBMPINetworkClient(context.Background(), sess, cloudInstanceID) + networkC := instance.NewIBMPINetworkClient(context.Background(), sess, cloudInstanceID) _, err = networkC.GetPort(networkname, portID) if err == nil { return fmt.Errorf("PI Network Port still exists: %s", rs.Primary.ID) @@ -111,7 +121,7 @@ func testAccCheckIBMPINetworkPortAttachExists(n string) resource.TestCheckFunc { cloudInstanceID := parts[0] networkname := parts[1] portID := parts[2] - client := st.NewIBMPINetworkClient(context.Background(), sess, cloudInstanceID) + client := instance.NewIBMPINetworkClient(context.Background(), sess, cloudInstanceID) _, err = client.GetPort(networkname, portID) if err != nil { @@ -122,24 +132,88 @@ func testAccCheckIBMPINetworkPortAttachExists(n string) resource.TestCheckFunc { } } -func testAccCheckIBMPINetworkPortAttachConfig(name string) string { - return testAccCheckIBMPINetworkConfig(name) + fmt.Sprintf(` +func testAccCheckIBMPINetworkPortAttachConfig(name, networkName, networkName2, health string) string { + return fmt.Sprintf(` + data "ibm_pi_image" "power_image" { + pi_cloud_instance_id = "%[1]s" + pi_image_name = "%[3]s" + } + + resource "ibm_pi_network" "power_networks" { + pi_cloud_instance_id = "%[1]s" + pi_network_name = "%[6]s" + pi_network_type = "vlan" + pi_cidr = "192.168.15.0/24" + } + resource "ibm_pi_network" "power_networks2" { + pi_cloud_instance_id = "%[1]s" + pi_network_name = "%[7]s" + pi_network_type = "pub-vlan" + pi_cidr = "192.97.57.0/24" + } + resource "ibm_pi_instance" "power_instance" { + pi_cloud_instance_id = "%[1]s" + pi_image_id = data.ibm_pi_image.power_image.id + pi_instance_name = "%[2]s" + pi_memory = "2" + pi_proc_type = "shared" + pi_processors = "0.25" + pi_storage_pool = data.ibm_pi_image.power_image.storage_pool + pi_storage_type = "%[5]s" + pi_health_status = "%[8]s" + pi_sys_type = "s922" + pi_network { + network_id = resource.ibm_pi_network.power_networks.network_id + } + } resource "ibm_pi_network_port_attach" "power_network_port_attach" { - pi_cloud_instance_id = "%s" - pi_network_name = ibm_pi_network.power_networks.pi_network_name + pi_cloud_instance_id = "%[1]s" + pi_network_name = resource.ibm_pi_network.power_networks2.pi_network_name pi_network_port_description = "IP Reserved for Test UAT" - pi_instance_id = "%s" + pi_instance_id = resource.ibm_pi_instance.power_instance.instance_id } - `, acc.Pi_cloud_instance_id, acc.Pi_instance_name) + `, acc.Pi_cloud_instance_id, name, acc.Pi_image, acc.Pi_network_name, acc.PiStorageType, networkName, networkName2, health) } -func testAccCheckIBMPINetworkPortAttachVlanConfig(name string) string { - return testAccCheckIBMPINetworkGatewayConfig(name) + fmt.Sprintf(` +func testAccCheckIBMPINetworkPortAttachVlanConfig(name, networkName, networkName2, health string) string { + return fmt.Sprintf(` + data "ibm_pi_image" "power_image" { + pi_cloud_instance_id = "%[1]s" + pi_image_name = "%[3]s" + } + + resource "ibm_pi_network" "power_networks" { + pi_cloud_instance_id = "%[1]s" + pi_network_name = "%[6]s" + pi_network_type = "vlan" + pi_cidr = "192.168.15.0/24" + } + resource "ibm_pi_network" "power_networks2" { + pi_cloud_instance_id = "%[1]s" + pi_network_name = "%[7]s" + pi_network_type = "vlan" + pi_cidr = "192.97.57.0/24" + } + resource "ibm_pi_instance" "power_instance" { + pi_cloud_instance_id = "%[1]s" + pi_image_id = data.ibm_pi_image.power_image.id + pi_instance_name = "%[2]s" + pi_memory = "2" + pi_proc_type = "shared" + pi_processors = "0.25" + pi_storage_pool = data.ibm_pi_image.power_image.storage_pool + pi_storage_type = "%[5]s" + pi_health_status = "%[8]s" + pi_sys_type = "s922" + pi_network { + network_id = resource.ibm_pi_network.power_networks.network_id + } + } resource "ibm_pi_network_port_attach" "power_network_port_attach" { - pi_cloud_instance_id = "%s" - pi_network_name = ibm_pi_network.power_networks.pi_network_name + pi_cloud_instance_id = "%[1]s" + pi_network_name = ibm_pi_network.power_networks2.pi_network_name pi_network_port_description = "IP Reserved for Test UAT" - pi_instance_id = "%s" + pi_instance_id = resource.ibm_pi_instance.power_instance.instance_id } - `, acc.Pi_cloud_instance_id, acc.Pi_instance_name) + `, acc.Pi_cloud_instance_id, name, acc.Pi_image, acc.Pi_network_name, acc.PiStorageType, networkName, networkName2, health) } diff --git a/website/docs/r/pi_network_port_attach.html.markdown b/website/docs/r/pi_network_port_attach.html.markdown index b12d5b2a7f..57d49d0afc 100644 --- a/website/docs/r/pi_network_port_attach.html.markdown +++ b/website/docs/r/pi_network_port_attach.html.markdown @@ -8,6 +8,7 @@ description: |- --- # ibm_pi_network_port_attach + Attaches network port in the Power Virtual Server Cloud. For more information, about network in IBM power virutal server, see [adding or removing a public network ](https://cloud.ibm.com/docs/power-iaas?topic=power-iaas-modifying-server#adding-removing-network).. @@ -24,7 +25,8 @@ resource "ibm_pi_network_port_attach" "test-network-port-attach" { } ``` -**Note** +### 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` @@ -43,34 +45,35 @@ resource "ibm_pi_network_port_attach" "test-network-port-attach" { ibm_pi_network_port_attach provides the following [timeouts](https://www.terraform.io/docs/language/resources/syntax.html) configuration options: -- **create** - (Default 60 minutes) Used for attaching a network port. -- **delete** - (Default 60 minutes) Used for detaching a network port. +* **create** - (Default 60 minutes) Used for attaching a network port. +* **delete** - (Default 60 minutes) Used for detaching a network port. ## Argument reference + Review the argument references that you can specify for your resource. -- `pi_cloud_instance_id` - (Required, String) The GUID of the service instance associated with an account. -- `pi_instance_id` - (Required, String) The ID of the pvm instance to attach the network port to. -- `pi_network_name` - (Required, String) The network ID or name. -- `pi_network_port_description` - (Optional, String) The description for the Network Port. -- `pi_network_port_ipaddress` - (Optional, String) The requested ip address of this port. +* `pi_cloud_instance_id` - (Required, String) The GUID of the service instance associated with an account. +* `pi_instance_id` - (Required, String) The ID of the pvm instance to attach the network port to. +* `pi_network_name` - (Required, String) The network ID or name. +* `pi_network_port_description` - (Optional, String) The description for the Network Port. +* `pi_network_port_ipaddress` - (Optional, String) The requested ip address of this port. ## Attribute reference -In addition to all argument reference list, you can access the following attribute reference after your resource is created. -- `id` - (String) The unique identifier of the instance. The ID is composed of `//`. -- `macaddress` - (String) The MAC address of the port. -- `network_port_id` - (String) The ID of the port. -- `public_ip` - (String) The public IP associated with the port. -- `status` - (String) The status of the port. +In addition to all argument reference list, you can access the following attribute reference after your resource is created. +* `id` - (String) The unique identifier of the instance. The ID is composed of `//`. +* `macaddress` - (String) The MAC address of the port. +* `network_port_id` - (String) The ID of the port. +* `public_ip` - (String) The public IP associated with the port. +* `status` - (String) The status of the port. ## Import The `ibm_pi_network_port` resource can be imported by using `power_instance_id`, `pi_network_name` and `network_port_id`. -**Example** +### Example -``` -$ terraform import ibm_pi_network_port_attach.example d7bec597-4726-451f-8a63-e62e6f19c32c/network-name/cea6651a-bc0a-4438-9f8a-a0770bbf3ebb +```bash +terraform import ibm_pi_network_port_attach.example d7bec597-4726-451f-8a63-e62e6f19c32c/pi_network_name/cea6651a-bc0a-4438-9f8a-a0770bbf3ebb ```