Skip to content

Commit

Permalink
WIP:feat(VPC): Synchronized VPC resources and data sources.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zippo-Wang committed Jan 16, 2024
1 parent ba09928 commit 45d8601
Show file tree
Hide file tree
Showing 9 changed files with 617 additions and 32 deletions.
6 changes: 3 additions & 3 deletions docs/data-sources/vpc_peering_connection_v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ The given filters must match exactly one VPC peering connection whose data will
* `peer_tenant_id` (Optional, String) - The Tenant ID of the accepter/peer VPC
of the specific VPC Peering Connection to retrieve.

## Attributes Reference
## Attribute Reference

* `description` - The description of the VPC Peering Connection.
All the arguments above can also be exported attributes.

All of the argument attributes are exported as result attributes.
* `description` - The description of the VPC Peering Connection.
9 changes: 4 additions & 5 deletions docs/data-sources/vpc_subnet_v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,11 @@ subnet whose data will be exported as attributes.

* `description` - The description of the subnet.

## **Attributes Reference**
## Attribute Reference

All of the argument attributes are also exported as
result attributes. This data source will complete the data by populating
any fields that are not included in the configuration with the data for
the selected subnet.
All the argument attributes are also exported as result attributes.
This data source will complete the data by populating any fields that are not included in the configuration with the
data for the selected subnet.

* `dns_list` - The IP address list of DNS servers on the subnet.

Expand Down
26 changes: 21 additions & 5 deletions docs/resources/networking_vip_associate_v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,32 @@ resource "flexibleengine_networking_vip_associate_v2" "vip_associate_1" {

The following arguments are supported:

* `vip_id` - (Required) The ID of vip to attach the port to.
Changing this creates a new vip associate.
* `region` - (Optional, String, ForceNew) The region in which to create the vip associate resource. If omitted, the
provider-level region will be used.

* `port_ids` - (Required) An array of one or more IDs of the ports to attach the vip to.
Changing this creates a new vip associate.
* `vip_id` - (Required, String, ForceNew) The ID of vip to attach the port to.
Changing this creates a new vip associate.

## Attributes Reference
* `port_ids` - (Required, List, ForceNew) An array of one or more IDs of the ports to attach the vip to.
Changing this creates a new vip associate.

## Attribute Reference

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

* `id` - The resource ID.

* `vip_subnet_id` - The ID of the subnet this vip connects to.

* `vip_ip_address` - The IP address in the subnet for this vip.

* `ip_addresses` - The IP addresses of ports to attach the vip to.

## Import

Vip associate can be imported using the `vip_id` and port IDs separated by slashes (no limit on the number of
port IDs), e.g.

```shell
terraform import flexibleengine_networking_vip_associate_v2.vip_associated vip_id/port1_id/port2_id
```
11 changes: 6 additions & 5 deletions docs/resources/vpc_peering_connection_v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@ The following arguments are supported:
* `peer_tenant_id` (Optional, String, ForceNew) - Specified the Tenant Id of the accepter tenant.
Changing this creates a new VPC peering connection.

## Attributes Reference
* `description` - (Optional, String) Specifies the description of the VPC peering connection.

All of the argument attributes are also exported as
result attributes:
## Attribute Reference

All the arguments above can also be exported attributes.

* `id` - The VPC peering connection ID.

Expand All @@ -62,8 +63,8 @@ result attributes:

This resource provides the following timeouts configuration options:

* `create` - Default is 10 minute.
* `delete` - Default is 10 minute.
* `create` - Default is 10 minutes.
* `delete` - Default is 10 minutes.

## Import

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
package acceptance

import (
"fmt"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"

"github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/services/acceptance"
)

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

dc := acceptance.InitDataSourceCheck(dataSourceName)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: TestAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccVpcPeeringConnectionDataSource_basic(randName),
Check: resource.ComposeTestCheckFunc(
dc.CheckResourceExists(),
resource.TestCheckResourceAttr(dataSourceName, "name", randName),
resource.TestCheckResourceAttr(dataSourceName, "status", "ACTIVE"),
resource.TestCheckResourceAttr(dataSourceName, "description", "vpc1 peers to vpc2"),
),
},
},
})
}

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

dc := acceptance.InitDataSourceCheck(dataSourceName)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: TestAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccVpcPeeringConnectionDataSource_byVpcId(randName),
Check: resource.ComposeTestCheckFunc(
dc.CheckResourceExists(),
resource.TestCheckResourceAttr(dataSourceName, "name", randName),
resource.TestCheckResourceAttr(dataSourceName, "status", "ACTIVE"),
),
},
},
})
}

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

dc := acceptance.InitDataSourceCheck(dataSourceName)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: TestAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccVpcPeeringConnectionDataSource_byPeerVpcId(randName),
Check: resource.ComposeTestCheckFunc(
dc.CheckResourceExists(),
resource.TestCheckResourceAttr(dataSourceName, "name", randName),
resource.TestCheckResourceAttr(dataSourceName, "status", "ACTIVE"),
),
},
},
})
}

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

dc := acceptance.InitDataSourceCheck(dataSourceName)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: TestAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccVpcPeeringConnectionDataSource_byVpcIds(randName),
Check: resource.ComposeTestCheckFunc(
dc.CheckResourceExists(),
resource.TestCheckResourceAttr(dataSourceName, "name", randName),
resource.TestCheckResourceAttr(dataSourceName, "status", "ACTIVE"),
),
},
},
})
}

func testAccVpcPeeringConnectionDataSource_base(rName string) string {
return fmt.Sprintf(`
resource "flexibleengine_vpc_v1" "vpc_1" {
name = "%[1]s_1"
cidr = "172.16.0.0/20"
}
resource "flexibleengine_vpc_v1" "vpc_2" {
name = "%[1]s_2"
cidr = "172.16.128.0/20"
}
resource "flexibleengine_vpc_peering_connection_v2" "test" {
name = "%[1]s"
vpc_id = flexibleengine_vpc_v1.vpc_1.id
peer_vpc_id = flexibleengine_vpc_v1.vpc_2.id
description = "vpc1 peers to vpc2"
}
`, rName)
}

func testAccVpcPeeringConnectionDataSource_basic(rName string) string {
return fmt.Sprintf(`
%s
data "flexibleengine_vpc_peering_connection_v2" "test" {
id = flexibleengine_vpc_peering_connection_v2.test.id
}
`, testAccVpcPeeringConnectionDataSource_base(rName))
}

func testAccVpcPeeringConnectionDataSource_byVpcId(rName string) string {
return fmt.Sprintf(`
%s
data "flexibleengine_vpc_peering_connection_v2" "test" {
vpc_id = flexibleengine_vpc_peering_connection_v2.test.vpc_id
}
`, testAccVpcPeeringConnectionDataSource_base(rName))
}

func testAccVpcPeeringConnectionDataSource_byPeerVpcId(rName string) string {
return fmt.Sprintf(`
%s
data "flexibleengine_vpc_peering_connection_v2" "test" {
peer_vpc_id = flexibleengine_vpc_peering_connection_v2.test.peer_vpc_id
}
`, testAccVpcPeeringConnectionDataSource_base(rName))
}

func testAccVpcPeeringConnectionDataSource_byVpcIds(rName string) string {
return fmt.Sprintf(`
%s
data "flexibleengine_vpc_peering_connection_v2" "test" {
vpc_id = flexibleengine_vpc_peering_connection_v2.test.vpc_id
peer_vpc_id = flexibleengine_vpc_peering_connection_v2.test.peer_vpc_id
}
`, testAccVpcPeeringConnectionDataSource_base(rName))
}
Loading

0 comments on commit 45d8601

Please sign in to comment.