Skip to content

Commit

Permalink
feat(EIP): Synchronized EIP dataSources, unit test and document.
Browse files Browse the repository at this point in the history
  • Loading branch information
dengyali0125 committed Jan 17, 2024
1 parent ba09928 commit ce8986e
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 5 deletions.
12 changes: 8 additions & 4 deletions docs/data-sources/vpc_eip.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,26 @@ data "flexibleengine_vpc_eip" "by_address" {
* `region` - (Optional, String) Specifies the region in which to obtain the EIP.
If omitted, the provider-level region will be used.

* `public_ip` - (Optional, String) The public ip address of the EIP.
* `public_ip` - (Optional, String) Specifies the public **IPv4** address of the EIP.

* `port_id` - (Optional, String) The port id of the EIP.
* `port_id` - (Optional, String) Specifies the port id of the EIP.

* `enterprise_project_id` - (Optional, String) Specifies the enterprise project id of the EIP.

## Attribute Reference

In addition to all arguments above, the following attributes are exported:

* `id` - The data source ID in UUID format.

* `status` - The status of the EIP.

* `type` - The type of the EIP.

* `private_ip` - The private ip of the EIP.

* `ip_version` - The IP version, either 4 or 6.

* `ipv6_address` - The IPv6 address of the EIP.

* `bandwidth_id` - The bandwidth id of the EIP.

* `bandwidth_size` - The bandwidth size of the EIP.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package acceptance

import (
"fmt"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/services/acceptance"
)

func TestAccVpcEipDataSource_basic(t *testing.T) {
randName := acceptance.RandomAccResourceName()
dataSourceName := "data.flexibleengine_vpc_eip.test"

dc := acceptance.InitDataSourceCheck(dataSourceName)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: TestAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccDataSourceVpcEipConfig_basic(randName),
Check: resource.ComposeTestCheckFunc(
dc.CheckResourceExists(),
resource.TestCheckResourceAttr(dataSourceName, "status", "UNBOUND"),
resource.TestCheckResourceAttr(dataSourceName, "type", "5_bgp"),
resource.TestCheckResourceAttr(dataSourceName, "ip_version", "4"),
resource.TestCheckResourceAttr(dataSourceName, "bandwidth_size", "5"),
resource.TestCheckResourceAttr(dataSourceName, "bandwidth_share_type", "PER"),
),
},
},
})
}

func testAccDataSourceVpcEipConfig_basic(rName string) string {
return fmt.Sprintf(`
resource "flexibleengine_vpc_eip" "test" {
publicip {
type = "5_bgp"
}
bandwidth {
name = "%s"
size = 5
share_type = "PER"
charge_mode = "traffic"
}
}
data "flexibleengine_vpc_eip" "test" {
public_ip = flexibleengine_vpc_eip.test.address
}
`, rName)
}
3 changes: 2 additions & 1 deletion flexibleengine/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ func Provider() *schema.Provider {
"flexibleengine_vpc_subnet_v1": dataSourceVpcSubnetV1(),
"flexibleengine_vpc_subnet_ids_v1": dataSourceVpcSubnetIdsV1(),
"flexibleengine_vpc_peering_connection_v2": dataSourceVpcPeeringConnectionV2(),
"flexibleengine_vpc_eip": dataSourceVpcEipV1(),

"flexibleengine_nat_gateway_v2": dataSourceNatGatewayV2(),

Expand Down Expand Up @@ -319,6 +318,8 @@ func Provider() *schema.Provider {

"flexibleengine_compute_servergroups": ecs.DataSourceComputeServerGroups(),

"flexibleengine_vpc_eip": eip.DataSourceVpcEip(),

"flexibleengine_css_flavors": css.DataSourceCssFlavors(),

"flexibleengine_dcs_flavors": dcs.DataSourceDcsFlavorsV2(),
Expand Down

0 comments on commit ce8986e

Please sign in to comment.