Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(NAT): Synchronized NAT dataSources, unit test and document. #1099

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
Comment on lines +39 to +44
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

too many spaces


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)
}
4 changes: 2 additions & 2 deletions flexibleengine/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,6 @@ func Provider() *schema.Provider {
"flexibleengine_vpc_peering_connection_v2": dataSourceVpcPeeringConnectionV2(),
"flexibleengine_vpc_eip": dataSourceVpcEipV1(),

"flexibleengine_nat_gateway_v2": dataSourceNatGatewayV2(),

"flexibleengine_sfs_file_system_v2": dataSourceSFSFileSystemV2(),

"flexibleengine_compute_bms_flavors_v2": dataSourceBMSFlavorV2(),
Expand Down Expand Up @@ -383,6 +381,8 @@ func Provider() *schema.Provider {
"flexibleengine_modelarts_datasets": modelarts.DataSourceDatasets(),
"flexibleengine_modelarts_dataset_versions": modelarts.DataSourceDatasetVerions(),

"flexibleengine_nat_gateway_v2": nat.DataSourcePublicGateway(),

"flexibleengine_obs_buckets": obs.DataSourceObsBuckets(),
"flexibleengine_obs_bucket_object": obs.DataSourceObsBucketObject(),

Expand Down
Loading