diff --git a/ibm/provider/provider.go b/ibm/provider/provider.go index eab13bce4b..71d6d365a5 100644 --- a/ibm/provider/provider.go +++ b/ibm/provider/provider.go @@ -685,6 +685,7 @@ func Provider() *schema.Provider { "ibm_pi_network_address_groups": power.DataSourceIBMPINetworkAddressGroups(), "ibm_pi_network_interface": power.DataSourceIBMPINetworkInterface(), "ibm_pi_network_interfaces": power.DataSourceIBMPINetworkInterfaces(), + "ibm_pi_network_peers": power.DataSourceIBMPINetworkPeers(), "ibm_pi_network_port": power.DataSourceIBMPINetworkPort(), "ibm_pi_network_security_group": power.DataSourceIBMPINetworkSecurityGroup(), "ibm_pi_network_security_groups": power.DataSourceIBMPINetworkSecurityGroups(), diff --git a/ibm/service/power/data_source_ibm_pi_network.go b/ibm/service/power/data_source_ibm_pi_network.go index dec8dab0cc..bc699c4f07 100644 --- a/ibm/service/power/data_source_ibm_pi_network.go +++ b/ibm/service/power/data_source_ibm_pi_network.go @@ -37,7 +37,8 @@ func DataSourceIBMPINetwork() *schema.Resource { // Attributes Attr_AccessConfig: { Computed: true, - Description: "The network communication configuration option of the network (for satellite locations only).", + Deprecated: "This field is deprecated please use peer_id instead.", + Description: "The network communication configuration option of the network (for on prem locations only). Use `peer_id` instead.", Type: schema.TypeString, }, Attr_AvailableIPCount: { @@ -83,6 +84,25 @@ func DataSourceIBMPINetwork() *schema.Resource { Description: "The unique identifier or name of a network.", Type: schema.TypeString, }, + Attr_NetworkAddressTranslation: { + Computed: true, + Description: "Contains the network address translation details (for on prem locations only).", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + Attr_SourceIP: { + Computed: true, + Description: "source IP address.", + Type: schema.TypeString, + }, + }, + }, + Type: schema.TypeList, + }, + Attr_PeerID: { + Computed: true, + Description: "Network peer ID (for on prem locations only).", + Type: schema.TypeString, + }, Attr_Type: { Computed: true, Description: "The type of network.", @@ -153,6 +173,13 @@ func dataSourceIBMPINetworkRead(ctx context.Context, d *schema.ResourceData, met if networkdata.Name != nil { d.Set(Attr_Name, networkdata.Name) } + networkAddressTranslation := []map[string]interface{}{} + if networkdata.NetworkAddressTranslation != nil { + natMap := networkAddressTranslationToMap(networkdata.NetworkAddressTranslation) + networkAddressTranslation = append(networkAddressTranslation, natMap) + } + d.Set(Attr_NetworkAddressTranslation, networkAddressTranslation) + d.Set(Attr_PeerID, networkdata.PeerID) if networkdata.Type != nil { d.Set(Attr_Type, networkdata.Type) } diff --git a/ibm/service/power/data_source_ibm_pi_network_peers.go b/ibm/service/power/data_source_ibm_pi_network_peers.go new file mode 100644 index 0000000000..3df2820dad --- /dev/null +++ b/ibm/service/power/data_source_ibm_pi_network_peers.go @@ -0,0 +1,109 @@ +// Copyright IBM Corp. 2024 All Rights Reserved. +// Licensed under the Mozilla Public License v2.0 + +package power + +import ( + "context" + + "github.com/hashicorp/go-uuid" + "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" + + "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" +) + +func DataSourceIBMPINetworkPeers() *schema.Resource { + return &schema.Resource{ + ReadContext: dataSourceIBMPINetworkPeersRead, + + Schema: map[string]*schema.Schema{ + // Arguments + Arg_CloudInstanceID: { + Description: "The GUID of the service instance associated with an account.", + Required: true, + Type: schema.TypeString, + ValidateFunc: validation.NoZeroValues, + }, + + // Attributes + Attr_NetworkPeers: { + Computed: true, + Description: "List of network peers.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + Attr_Description: { + Computed: true, + Description: "Description of the network peer.", + Type: schema.TypeString, + }, + Attr_ID: { + Computed: true, + Description: "ID of the network peer.", + Type: schema.TypeString, + }, + Attr_Name: { + Computed: true, + Description: "Name of the network peer.", + Type: schema.TypeString, + }, + Attr_Type: { + Computed: true, + Description: "Type of the network peer.", + Type: schema.TypeString, + }, + }, + }, + Type: schema.TypeList, + }, + }, + } +} + +func dataSourceIBMPINetworkPeersRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + sess, err := meta.(conns.ClientSession).IBMPISession() + if err != nil { + return diag.FromErr(err) + } + cloudInstanceID := d.Get(Arg_CloudInstanceID).(string) + + networkC := instance.NewIBMPINetworkPeerClient(ctx, sess, cloudInstanceID) + networkdata, err := networkC.GetNetworkPeers() + if err != nil { + return diag.FromErr(err) + } + var clientgenU, _ = uuid.GenerateUUID() + d.SetId(clientgenU) + + networkPeers := []map[string]interface{}{} + if networkdata.NetworkPeers != nil { + for _, np := range networkdata.NetworkPeers { + npMap := dataSourceIBMPINetworkPeersNetworkPeerToMap(np) + + networkPeers = append(networkPeers, npMap) + } + } + d.Set(Attr_NetworkPeers, networkPeers) + + return nil +} + +func dataSourceIBMPINetworkPeersNetworkPeerToMap(np *models.NetworkPeer) map[string]interface{} { + npMap := make(map[string]interface{}) + if np.Description != nil { + npMap[Attr_Description] = np.Description + } + if np.ID != nil { + npMap[Attr_ID] = np.ID + } + if np.Name != nil { + npMap[Attr_Name] = np.Name + } + if np.Type != nil { + npMap[Attr_Type] = np.Type + } + return npMap +} diff --git a/ibm/service/power/data_source_ibm_pi_network_peers_test.go b/ibm/service/power/data_source_ibm_pi_network_peers_test.go new file mode 100644 index 0000000000..0493065877 --- /dev/null +++ b/ibm/service/power/data_source_ibm_pi_network_peers_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" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + + acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" +) + +func TestAccIBMPINetworkPeersDataSourceBasic(t *testing.T) { + networksResData := "data.ibm_pi_network_peers.network_peers" + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheck(t) }, + Providers: acc.TestAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccCheckIBMPINetworkPeersDataSourceConfigBasic(), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet(networksResData, "id"), + resource.TestCheckResourceAttrSet(networksResData, "network_peers.#"), + ), + }, + }, + }) +} + +func testAccCheckIBMPINetworkPeersDataSourceConfigBasic() string { + return fmt.Sprintf(` + data "ibm_pi_network_peers" "network_peers" { + pi_cloud_instance_id = "%s" + }`, acc.Pi_cloud_instance_id) +} diff --git a/ibm/service/power/data_source_ibm_pi_networks.go b/ibm/service/power/data_source_ibm_pi_networks.go index db5c3ed5c2..5a4b48d40f 100644 --- a/ibm/service/power/data_source_ibm_pi_networks.go +++ b/ibm/service/power/data_source_ibm_pi_networks.go @@ -37,7 +37,8 @@ func DataSourceIBMPINetworks() *schema.Resource { Schema: map[string]*schema.Schema{ Attr_AccessConfig: { Computed: true, - Description: "The network communication configuration option of the network (for satellite locations only).", + Deprecated: "This field is deprecated please use peer_id instead.", + Description: "The network communication configuration option of the network (for on-prem locations only). Use `peer_id` instead.", Type: schema.TypeString, }, Attr_CRN: { @@ -70,6 +71,11 @@ func DataSourceIBMPINetworks() *schema.Resource { Description: "The unique identifier of a network.", Type: schema.TypeString, }, + Attr_PeerID: { + Computed: true, + Description: "Network Peer ID.", + Type: schema.TypeString, + }, Attr_Type: { Computed: true, Description: "The type of network.", @@ -126,6 +132,7 @@ func flattenNetworks(list []*models.NetworkReference, meta interface{}) []map[st Attr_MTU: i.Mtu, Attr_Name: *i.Name, Attr_NetworkID: *i.NetworkID, + Attr_PeerID: i.PeerID, Attr_Type: *i.Type, Attr_VLanID: *i.VlanID, } diff --git a/ibm/service/power/ibm_pi_constants.go b/ibm/service/power/ibm_pi_constants.go index 77ae403ce0..53513daffc 100644 --- a/ibm/service/power/ibm_pi_constants.go +++ b/ibm/service/power/ibm_pi_constants.go @@ -53,6 +53,7 @@ const ( Arg_NetworkID = "pi_network_id" Arg_NetworkInterfaceID = "pi_network_interface_id" Arg_NetworkName = "pi_network_name" + Arg_NetworkPeer = "pi_network_peer" Arg_NetworkSecurityGroupID = "pi_network_security_group_id" Arg_NetworkSecurityGroupMemberID = "pi_network_security_group_member_id" Arg_NetworkSecurityGroupRuleID = "pi_network_security_group_rule_id" @@ -279,9 +280,11 @@ const ( Attr_Name = "name" Attr_NetworkAddressGroupID = "network_address_group_id" Attr_NetworkAddressGroups = "network_address_groups" + Attr_NetworkAddressTranslation = "network_address_translation" Attr_NetworkID = "network_id" Attr_NetworkInterfaceID = "network_interface_id" Attr_NetworkName = "network_name" + Attr_NetworkPeers = "network_peers" Attr_NetworkPorts = "network_ports" Attr_Networks = "networks" Attr_NetworkSecurityGroupID = "network_security_group_id" @@ -291,6 +294,7 @@ const ( Attr_Onboardings = "onboardings" Attr_OperatingSystem = "operating_system" Attr_OSType = "os_type" + Attr_PeerID = "peer_id" Attr_PercentComplete = "percent_complete" Attr_PinPolicy = "pin_policy" Attr_PlacementGroupID = "placement_group_id" @@ -345,6 +349,7 @@ const ( Attr_Size = "size" Attr_SnapshotID = "snapshot_id" Attr_SourceChecksum = "source_checksum" + Attr_SourceIP = "source_ip" Attr_SourcePort = "source_port" Attr_SourceVolumeID = "source_volume_id" Attr_SourceVolumeName = "source_volume_name" @@ -468,8 +473,11 @@ const ( HostGroup = "hostGroup" ICMP = "icmp" IPV4_Address = "ipv4-address" - NAG = "network-address-group" + L2 = "L2" + L3BGP = "L3BGP" + L3Static = "L3Static" MaxVolumeSupport = "maxVolumeSupport" + NAG = "network-address-group" Netweaver = "Netweaver" Network_Interface = "network-interface" None = "none" diff --git a/ibm/service/power/resource_ibm_pi_network.go b/ibm/service/power/resource_ibm_pi_network.go index 3670aa3d10..392763bbf5 100644 --- a/ibm/service/power/resource_ibm_pi_network.go +++ b/ibm/service/power/resource_ibm_pi_network.go @@ -94,9 +94,47 @@ func ResourceIBMPINetwork() *schema.Resource { Type: schema.TypeString, Optional: true, Computed: true, + Deprecated: "This field is deprecated please use pi_network_peer instead", ValidateFunc: validate.ValidateAllowedStringValues([]string{"internal-only", "outbound-only", "bidirectional-static-route", "bidirectional-bgp", "bidirectional-l2out"}), Description: "PI network communication configuration", }, + Arg_NetworkPeer: { + Description: "Network peer information.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + Attr_ID: { + Description: "ID of the network peer.", + Required: true, + Type: schema.TypeString, + }, + Attr_NetworkAddressTranslation: { + Description: "Contains the network address translation Details.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + Attr_SourceIP: { + Description: "source IP address, required if network peer type is L3BGP or L3STATIC and if NAT is enabled.", + Required: true, + Type: schema.TypeString, + }, + }, + }, + MaxItems: 1, + Optional: true, + Type: schema.TypeList, + }, + Attr_Type: { + Description: "Type of the network peer.", + Optional: true, + Type: schema.TypeString, + ValidateFunc: validate.ValidateAllowedStringValues([]string{L2, L3BGP, L3Static}), + }, + }, + }, + ForceNew: true, + MaxItems: 1, + Optional: true, + Type: schema.TypeList, + }, helpers.PICloudInstanceId: { Type: schema.TypeString, Required: true, @@ -141,6 +179,25 @@ func ResourceIBMPINetwork() *schema.Resource { Computed: true, Description: "PI network ID", }, + Attr_NetworkAddressTranslation: { + Computed: true, + Description: "Contains the Network Address Translation Details (for on-prem locations only).", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + Attr_SourceIP: { + Computed: true, + Description: "source IP address, required if network peer type is L3BGP or L3STATIC and if NAT is enabled.", + Type: schema.TypeString, + }, + }, + }, + Type: schema.TypeList, + }, + Attr_PeerID: { + Computed: true, + Description: "Network Peer ID (for on-prem locations only).", + Type: schema.TypeString, + }, "vlan_id": { Type: schema.TypeFloat, Computed: true, @@ -158,7 +215,6 @@ func resourceIBMPINetworkCreate(ctx context.Context, d *schema.ResourceData, met cloudInstanceID := d.Get(helpers.PICloudInstanceId).(string) networkname := d.Get(helpers.PINetworkName).(string) networktype := d.Get(helpers.PINetworkType).(string) - client := instance.NewIBMPINetworkClient(ctx, sess, cloudInstanceID) var body = &models.NetworkCreate{ Type: &networktype, @@ -183,6 +239,10 @@ func resourceIBMPINetworkCreate(ctx context.Context, d *schema.ResourceData, met if v, ok := d.GetOk(helpers.PINetworkAccessConfig); ok { body.AccessConfig = models.AccessConfig(v.(string)) } + if _, ok := d.GetOk(Arg_NetworkPeer); ok { + peerModel := networkMapToNetworkCreatePeer(d.Get(Arg_NetworkPeer + ".0").(map[string]interface{})) + body.Peer = peerModel + } if networktype == DHCPVlan || networktype == Vlan { var networkcidr string @@ -212,17 +272,20 @@ func resourceIBMPINetworkCreate(ctx context.Context, d *schema.ResourceData, met body.Gateway = gateway body.Cidr = networkcidr } - wsclient := instance.NewIBMPIWorkspacesClient(ctx, sess, cloudInstanceID) - wsData, err := wsclient.Get(cloudInstanceID) - if err != nil { - return diag.FromErr(err) - } - if wsData.Capabilities[PER] { - _, err = waitForPERWorkspaceActive(ctx, wsclient, cloudInstanceID, d.Timeout(schema.TimeoutRead)) + if !sess.IsOnPrem() { + wsclient := instance.NewIBMPIWorkspacesClient(ctx, sess, cloudInstanceID) + wsData, err := wsclient.Get(cloudInstanceID) if err != nil { return diag.FromErr(err) } + if wsData.Capabilities[PER] { + _, err = waitForPERWorkspaceActive(ctx, wsclient, cloudInstanceID, d.Timeout(schema.TimeoutRead)) + if err != nil { + return diag.FromErr(err) + } + } } + networkResponse, err := client.Create(body) if err != nil { return diag.FromErr(err) @@ -284,6 +347,13 @@ func resourceIBMPINetworkRead(ctx context.Context, d *schema.ResourceData, meta d.Set(helpers.PINetworkMtu, networkdata.Mtu) d.Set(helpers.PINetworkAccessConfig, networkdata.AccessConfig) d.Set(helpers.PINetworkGateway, networkdata.Gateway) + d.Set(Attr_PeerID, networkdata.PeerID) + networkAddressTranslation := []map[string]interface{}{} + if networkdata.NetworkAddressTranslation != nil { + natMap := networkAddressTranslationToMap(networkdata.NetworkAddressTranslation) + networkAddressTranslation = append(networkAddressTranslation, natMap) + } + d.Set(Attr_NetworkAddressTranslation, networkAddressTranslation) ipRangesMap := []map[string]interface{}{} if networkdata.IPAddressRanges != nil { for _, n := range networkdata.IPAddressRanges { @@ -529,3 +599,33 @@ func isPERWorkspaceRefreshFunc(client *instance.IBMPIWorkspacesClient, id string return ws, State_Configuring, nil } } +func networkMapToNetworkCreatePeer(networkCreatePeerMap map[string]interface{}) *models.NetworkCreatePeer { + ncp := &models.NetworkCreatePeer{} + if networkCreatePeerMap[Attr_ID].(string) != "" { + id := networkCreatePeerMap[Attr_ID].(string) + ncp.ID = &id + } + if networkCreatePeerMap[Attr_NetworkAddressTranslation] != nil && len(networkCreatePeerMap[Attr_NetworkAddressTranslation].([]interface{})) > 0 { + networkAddressTranslationModel := natMapToNetworkAddressTranslation(networkCreatePeerMap[Attr_NetworkAddressTranslation].([]interface{})[0].(map[string]interface{})) + ncp.NetworkAddressTranslation = networkAddressTranslationModel + } + if networkCreatePeerMap[Attr_Type].(string) != "" { + ncp.Type = models.NetworkPeerType(networkCreatePeerMap[Attr_Type].(string)) + } + return ncp +} +func natMapToNetworkAddressTranslation(networkAddressTranslationMap map[string]interface{}) *models.NetworkAddressTranslation { + nat := &models.NetworkAddressTranslation{} + if networkAddressTranslationMap[Attr_SourceIP].(string) != "" { + nat.SourceIP = networkAddressTranslationMap[Attr_SourceIP].(string) + } + return nat +} + +func networkAddressTranslationToMap(nat *models.NetworkAddressTranslation) map[string]interface{} { + natMap := make(map[string]interface{}) + if nat.SourceIP != "" { + natMap[Attr_SourceIP] = nat.SourceIP + } + return natMap +} diff --git a/ibm/service/power/resource_ibm_pi_network_test.go b/ibm/service/power/resource_ibm_pi_network_test.go index b62dac6513..a3cd335ac0 100644 --- a/ibm/service/power/resource_ibm_pi_network_test.go +++ b/ibm/service/power/resource_ibm_pi_network_test.go @@ -188,7 +188,26 @@ func TestAccIBMPINetworkUserTags(t *testing.T) { }, }) } - +func TestAccIBMPINetworkPeerOnPrem(t *testing.T) { + name := fmt.Sprintf("tf-pi-network-%d", acctest.RandIntRange(10, 100)) + networkRes := "ibm_pi_network.power_network_peer" + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheck(t) }, + Providers: acc.TestAccProviders, + CheckDestroy: testAccCheckIBMPINetworkDestroy, + Steps: []resource.TestStep{ + { + Config: testAccCheckIBMPINetworkPeerOnPrem(name), + Check: resource.ComposeTestCheckFunc( + testAccCheckIBMPINetworkExists(networkRes), + resource.TestCheckResourceAttr(networkRes, "pi_network_name", name), + resource.TestCheckResourceAttrSet(networkRes, "id"), + resource.TestCheckResourceAttrSet(networkRes, "peer_id"), + ), + }, + }, + }) +} func testAccCheckIBMPINetworkDestroy(s *terraform.State) error { sess, err := acc.TestAccProvider.Meta().(conns.ClientSession).IBMPISession() if err != nil { @@ -338,3 +357,19 @@ func testAccCheckIBMPINetworkUserTagsConfig(name string, userTagsString string) } `, acc.Pi_cloud_instance_id, name, userTagsString) } + +func testAccCheckIBMPINetworkPeerOnPrem(name string) string { + return fmt.Sprintf(` + resource "ibm_pi_network" "power_network_peer" { + pi_cloud_instance_id = "%s" + pi_network_name = "%s" + pi_network_type = "vlan" + pi_cidr = "192.168.17.0/24" + + pi_network_peer { + id = "2" + type = "L2" + } + } + `, acc.Pi_cloud_instance_id, name) +} diff --git a/website/docs/d/pi_network.html.markdown b/website/docs/d/pi_network.html.markdown index befcce7a1c..c7951bb79d 100644 --- a/website/docs/d/pi_network.html.markdown +++ b/website/docs/d/pi_network.html.markdown @@ -7,9 +7,11 @@ description: |- --- # ibm_pi_network + Retrieve information about the network that your Power Systems Virtual Server instance is connected to. For more information, about power virtual server instance network, see [setting up an IBM network install server](https://cloud.ibm.com/docs/power-iaas?topic=power-iaas-configuring-subnet). ## Example usage + ```terraform data "ibm_pi_network" "ds_network" { pi_network_name = "APP" @@ -17,13 +19,15 @@ data "ibm_pi_network" "ds_network" { } ``` -**Notes** +### 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" @@ -32,15 +36,17 @@ Example usage: ``` ## Argument reference -Review the argument references that you can specify for your data source. + +Review the argument references that you can specify for your data source. - `pi_cloud_instance_id` - (Required, String) The GUID of the service instance associated with an account. - `pi_network_name` - (Required, String) The name of the network. ## Attribute reference -In addition to all argument reference list, you can access the following attribute references after your data source is created. -- `access_config` - (String) The network communication configuration option of the network (for satellite locations only). +In addition to all argument reference list, you can access the following attribute references after your data source is created. + +- `access_config` - (Deprecated, String) The network communication configuration option of the network (for on-prem locations only). Use `peer_id` instead. - `available_ip_count` - (Float) The total number of IP addresses that you have in your network. - `cidr` - (String) The CIDR of the network. - `crn` - (String) The CRN of this resource. @@ -49,6 +55,11 @@ In addition to all argument reference list, you can access the following attribu - `id` - (String) The ID of the network. - `jumbo` - (Deprecated, Boolean) MTU Jumbo option of the network (for multi-zone locations only). - `mtu` - (Boolean) Maximum Transmission Unit option of the network. +- `network_address_translation` - (List) Contains the network address translation details (for on-prem locations only). + + Nested schema for `network_address_translation`: + - `source_ip` - (String) source IP address. +- `peer_id` - (String) Network peer ID (for on-prem locations only). - `type` - (String) The type of network. - `used_ip_count` - (Float) The number of used IP addresses. - `used_ip_percent` - (Float) The percentage of IP addresses used. diff --git a/website/docs/d/pi_network_peers.html.markdown b/website/docs/d/pi_network_peers.html.markdown new file mode 100644 index 0000000000..f55811ca00 --- /dev/null +++ b/website/docs/d/pi_network_peers.html.markdown @@ -0,0 +1,54 @@ +--- +subcategory: "Power Systems" +layout: "ibm" +page_title: "IBM : ibm_pi_network_peers" +description: |- + Get information about IBM Power Virtual Server cloud network peers. +--- + +# ibm_pi_network_peers + +Provides a read-only data source to retrieve information about pi_network_peers for on-prem locations. + +## Example Usage + +```terraform +data "ibm_pi_network_peers" "pi_network_peers" { + pi_cloud_instance_id = "49fba6c9-23f8-40bc-9899-aca322ee7d5b" +} +``` + +### 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" + } + ``` + +## Argument reference + +Review the argument references that you can specify for your data source. + +- `pi_cloud_instance_id` - (Required, String) The GUID of the service instance associated with an account. + +## Attribute Reference + +In addition to all argument reference list, you can access the following attribute references after your data source is created. + +- `id` - (String) The unique identifier of the pi_network_peers. +- `network_peers` - (List) List of network peers. + + Nested schema for `network_peers`: + - `description` - (String) Description of the network peer. + - `id` - (String) ID of the network peer. + - `name` - (String) Name of the network peer. + - `type` - (String) Type of the network peer. diff --git a/website/docs/d/pi_networks.html.markdown b/website/docs/d/pi_networks.html.markdown index 2b030d6165..94f3a6e973 100644 --- a/website/docs/d/pi_networks.html.markdown +++ b/website/docs/d/pi_networks.html.markdown @@ -7,22 +7,26 @@ description: |- --- # ibm_pi_networks + Retrieve a list of networks that you can use in your Power Systems Virtual Server instance. For more information, about power virtual server instance networks, see [setting up an IBM network install server](https://cloud.ibm.com/docs/power-iaas?topic=power-iaas-configuring-subnet). ## Example usage + ```terraform data "ibm_pi_networks" "ds_network" { pi_cloud_instance_id = "49fba6c9-23f8-40bc-9899-aca322ee7d5b" } ``` -**Notes** +### 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" @@ -31,23 +35,26 @@ Example usage: ``` ## Argument reference -Review the argument references that you can specify for your data source. + +Review the argument references that you can specify for your data source. - `pi_cloud_instance_id` - (Required, String) The GUID of the service instance associated with an account. ## Attribute reference -In addition to all argument reference list, you can access the following attribute references after your data source is created. -- `networks` - (List) List of all networks. +In addition to all argument reference list, you can access the following attribute references after your data source is created. + +- `networks` - (List) List of all networks. Nested scheme for `networks`: - - `access_config` - (String) The network communication configuration option of the network (for satellite locations only). + - `access_config` - (Deprecated, String) The network communication configuration option of the network (for on-prem locations only). Use `peer_id` instead. - `crn` - (String) The CRN of this resource. - `dhcp_managed` - (Boolean) Indicates if the network DHCP Managed. - - `href` - (String) The hyper link of a network. + - `href` - (String) The hyper link of a network. - `mtu` - (Boolean) Maximum Transmission Unit option of the network. - `name` - (String) The name of a network. - `network_id` - (String) The ID of the network. + - `peer_id` - (String) Network peer ID (for on-prem locations only). - `type` - (String) The type of network. - `user_tags` - (List) List of user tags attached to the resource. - `vlan_id` - (String) The VLAN ID that the network is connected to. diff --git a/website/docs/r/pi_network.html.markdown b/website/docs/r/pi_network.html.markdown index e8ece20e93..e2ddbd8c0f 100644 --- a/website/docs/r/pi_network.html.markdown +++ b/website/docs/r/pi_network.html.markdown @@ -71,7 +71,16 @@ Review the argument references that you can specify for your resource. - `pi_starting_ip_address` - (Required, String) The staring ip address. **Note** if the `pi_gateway` or `pi_ipaddress_range` is not provided, it will calculate the value based on CIDR respectively. - `pi_network_jumbo` - (Deprecated, Optional, Bool) MTU Jumbo option of the network (for multi-zone locations only). - `pi_network_mtu` - (Optional, Integer) Maximum Transmission Unit option of the network, min size = 1450 & max size = 9000. -- `pi_network_access_config` - (Optional, String) The network communication configuration option of the network (for satellite locations only). +- `pi_network_access_config` - (Deprecated, Optional, String) The network communication configuration option of the network (for on-prem locations only). Please use `pi_network_peer`. +- `pi_network_peer` - (Optional, List) Network peer information (for on-prem locations only). Max items: 1. + + Nested schema for `pi_network_peer`: + - `id` - (Required, String) ID of the network peer. + - `network_address_translation` - (Optional, List) Contains the Network Address Translation Details. Max items: 1. + + Nested schema for `network_address_translation`: + - `source_ip` - (Optional, String) source IP address, required if network peer type is `L3BGP` or `L3STATIC` and if NAT is enabled. + - `type` - (Optional, String) Type of the network peer. Allowable values are: `L2`, `L3BGP`, `L3Static`. - `pi_user_tags` - (Optional, List) The user tags attached to this resource. ## Attribute reference @@ -81,6 +90,11 @@ In addition to all argument reference list, you can access the following attribu - `crn` - (String) The CRN of this resource. - `id` - (String) The unique identifier of the network. The ID is composed of `/`. - `network_id` - (String) The unique identifier of the network. +- `network_address_translation` - (List) Contains the network address translation details (for on-prem locations only). + + Nested schema for `network_address_translation`: + - `source_ip` - (String) source IP address. +- `peer_id` - (String) Network peer ID (for on-prem locations only). - `vlan_id` - (Integer) The ID of the VLAN that your network is attached to. ## Import