diff --git a/docs/data-sources/nat_gateway_v2.md b/docs/data-sources/nat_gateway_v2.md index 66baed3e..03fd4897 100644 --- a/docs/data-sources/nat_gateway_v2.md +++ b/docs/data-sources/nat_gateway_v2.md @@ -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. diff --git a/flexibleengine/acceptance/data_source_flexibleengine_nat_gateway_v2_test.go b/flexibleengine/acceptance/data_source_flexibleengine_nat_gateway_v2_test.go new file mode 100644 index 00000000..4f3c3d23 --- /dev/null +++ b/flexibleengine/acceptance/data_source_flexibleengine_nat_gateway_v2_test.go @@ -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) +} diff --git a/flexibleengine/provider.go b/flexibleengine/provider.go index 5a861c87..f509c7d5 100644 --- a/flexibleengine/provider.go +++ b/flexibleengine/provider.go @@ -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(), @@ -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(),