Skip to content

Commit

Permalink
feat(NAT): Synchronized NAT dataSources, unit test and document.
Browse files Browse the repository at this point in the history
  • Loading branch information
dengyali0125 committed Jan 15, 2024
1 parent ba09928 commit 7be49be
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 12 deletions.
25 changes: 14 additions & 11 deletions docs/data-sources/nat_gateway_v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,30 @@ data "flexibleengine_nat_gateway_v2" "natgateway" {

## Argument Reference

* `region` - (Optional, String) The region in which to query the data source. If omitted, the provider-level region
will be used.
* `region` - (Optional, String) Specifies the region in which to create the NAT gateway resource. If omitted, the
provider-level region will be used.

* `id` - (Optional, String) Specifies the ID of the NAT gateway.

* `name` - (Optional, String) Specifies the NAT gateway name. The name can contain only digits, letters,
underscores (_), and hyphens(-).

* `vpc_id` - (Optional, String) Specifies the ID of the VPC this NAT gateway belongs to.
* `subnet_id` - (Optional, String) Specifies the subnet ID of the downstream interface (the next hop of the DVR) of the
public NAT gateway.

* `subnet_id` - (Optional, String) Specifies the ID of the VPC Subnet of the downstream interface
(the next hop of the DVR) of the NAT gateway.
* `vpc_id` - (Optional, String) Specifies the ID of the VPC this public NAT gateway belongs to.

* `spec` - (Optional, String) The NAT gateway type. The value can be:
+ `1`: small type, which supports up to 10,000 SNAT connections.
+ `2`: medium type, which supports up to 50,000 SNAT connections.
+ `3`: large type, which supports up to 200,000 SNAT connections.
+ `4`: extra-large type, which supports up to 1,000,000 SNAT connections.
* `enterprise_project_id` - (Optional, String) Specifies the enterprise project ID of the NAT gateway.

* `spec` - (Optional, String) The public NAT gateway type. The valid values are as follows:
+ **1**: Small type, which supports up to `10,000` SNAT connections.
+ **2**: Medium type, which supports up to `50,000` SNAT connections.
+ **3**: Large type, which supports up to `200,000` SNAT connections.
+ **4**: Extra-large type, which supports up to `1,000,000` SNAT connections.

* `description` - (Optional, String) Specifies the description of the NAT gateway. The value contains 0 to 255
characters, and angle brackets (<) and (>) are not allowed.
characters, and angle brackets (<)
and (>) are not allowed.

* `status` - (Optional, String) Specifies the status of the NAT gateway.

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

import (
"fmt"
"testing"

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

func TestAccDataPublicGateway_basic(t *testing.T) {
var (
name = acceptance.RandomAccResourceName()
nameFilter = acceptance.InitDataSourceCheck("data.flexibleengine_nat_gateway_v2.name_filter")
idFilter = acceptance.InitDataSourceCheck("data.flexibleengine_nat_gateway_v2.id_filter")
allParamsFilter = acceptance.InitDataSourceCheck("data.flexibleengine_nat_gateway_v2.all_params_filter")
)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: TestAccProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccDataPublicGateway_basic(name),
Check: resource.ComposeTestCheckFunc(
nameFilter.CheckResourceExists(),
idFilter.CheckResourceExists(),
allParamsFilter.CheckResourceExists(),
),
},
},
})
}

func testAccDataPublicGateway_basic(name string) string {
return fmt.Sprintf(`
%[1]s
resource "flexibleengine_nat_gateway_v2" "test" {
name = "%[2]s"
spec = "1"
subnet_id = flexibleengine_vpc_subnet_v1.test.id
vpc_id = flexibleengine_vpc_v1.test.id
}
data "flexibleengine_nat_gateway_v2" "name_filter" {
name = flexibleengine_nat_gateway_v2.test.name
}
data "flexibleengine_nat_gateway_v2" "id_filter" {
id = flexibleengine_nat_gateway_v2.test.id
}
data "flexibleengine_nat_gateway_v2" "all_params_filter" {
name = flexibleengine_nat_gateway_v2.test.name
spec = flexibleengine_nat_gateway_v2.test.spec
subnet_id = flexibleengine_nat_gateway_v2.test.subnet_id
vpc_id = flexibleengine_nat_gateway_v2.test.vpc_id
enterprise_project_id = "0"
}
`, testBaseNetwork(name), name)
}
2 changes: 1 addition & 1 deletion flexibleengine/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ func Provider() *schema.Provider {
"flexibleengine_vpc_peering_connection_v2": dataSourceVpcPeeringConnectionV2(),
"flexibleengine_vpc_eip": dataSourceVpcEipV1(),

"flexibleengine_nat_gateway_v2": dataSourceNatGatewayV2(),
"flexibleengine_nat_gateway_v2": nat.DataSourcePublicGateway(),

"flexibleengine_sfs_file_system_v2": dataSourceSFSFileSystemV2(),

Expand Down

0 comments on commit 7be49be

Please sign in to comment.