From fb1a18090b99db81615b98dcd883de8819eda80a Mon Sep 17 00:00:00 2001 From: MrWolong <36806235+MrWolong@users.noreply.github.com> Date: Wed, 22 Jan 2025 13:47:10 +0800 Subject: [PATCH] resource/alicloud_dfs_file_system: Added the field region_id; Improved the testcase (#8152) --- alicloud/resource_alicloud_dfs_file_system.go | 35 +- .../resource_alicloud_dfs_file_system_test.go | 369 ++++-------------- alicloud/service_alicloud_dfs_v2.go | 16 +- website/docs/r/dfs_file_system.html.markdown | 24 +- 4 files changed, 115 insertions(+), 329 deletions(-) diff --git a/alicloud/resource_alicloud_dfs_file_system.go b/alicloud/resource_alicloud_dfs_file_system.go index d8567ae152f8..9c16d25ff77e 100644 --- a/alicloud/resource_alicloud_dfs_file_system.go +++ b/alicloud/resource_alicloud_dfs_file_system.go @@ -56,18 +56,22 @@ func resourceAliCloudDfsFileSystem() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - ValidateFunc: StringInSlice([]string{"HDFS"}, false), + ValidateFunc: StringInSlice([]string{"HDFS", "PANGU"}, false), }, "provisioned_throughput_in_mi_bps": { - Type: schema.TypeInt, - Optional: true, + Type: schema.TypeInt, + Optional: true, + ValidateFunc: IntBetween(0, 1024), DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool { if v, ok := d.GetOk("throughput_mode"); ok && v.(string) == "Provisioned" { return false } return true }, - ValidateFunc: IntBetween(0, 1024), + }, + "region_id": { + Type: schema.TypeString, + Computed: true, }, "space_capacity": { Type: schema.TypeInt, @@ -111,7 +115,7 @@ func resourceAliCloudDfsFileSystemCreate(d *schema.ResourceData, meta interface{ return WrapError(err) } request = make(map[string]interface{}) - query["InputRegionId"] = client.RegionId + request["InputRegionId"] = client.RegionId if v, ok := d.GetOk("zone_id"); ok { request["ZoneId"] = v @@ -131,7 +135,6 @@ func resourceAliCloudDfsFileSystemCreate(d *schema.ResourceData, meta interface{ } if v, ok := d.GetOk("storage_set_name"); ok { request["StorageSetName"] = v - request["PartitionNumber"] = d.Get("partition_number") } if v, ok := d.GetOk("partition_number"); ok { request["PartitionNumber"] = v @@ -154,9 +157,9 @@ func resourceAliCloudDfsFileSystemCreate(d *schema.ResourceData, meta interface{ } return resource.NonRetryableError(err) } - addDebug(action, response, request) return nil }) + addDebug(action, response, request) if err != nil { return WrapErrorf(err, DefaultErrorMsg, "alicloud_dfs_file_system", action, AlibabaCloudSdkGoERROR) @@ -196,6 +199,9 @@ func resourceAliCloudDfsFileSystemRead(d *schema.ResourceData, meta interface{}) if objectRaw["ProvisionedThroughputInMiBps"] != nil { d.Set("provisioned_throughput_in_mi_bps", formatInt(objectRaw["ProvisionedThroughputInMiBps"])) } + if objectRaw["RegionId"] != nil { + d.Set("region_id", objectRaw["RegionId"]) + } if objectRaw["SpaceCapacity"] != nil { d.Set("space_capacity", objectRaw["SpaceCapacity"]) } @@ -218,6 +224,7 @@ func resourceAliCloudDfsFileSystemUpdate(d *schema.ResourceData, meta interface{ var response map[string]interface{} var query map[string]interface{} update := false + action := "ModifyFileSystem" conn, err := client.NewDfsClient() if err != nil { @@ -225,8 +232,8 @@ func resourceAliCloudDfsFileSystemUpdate(d *schema.ResourceData, meta interface{ } request = make(map[string]interface{}) query = make(map[string]interface{}) - query["FileSystemId"] = d.Id() - query["InputRegionId"] = client.RegionId + request["FileSystemId"] = d.Id() + request["InputRegionId"] = client.RegionId if d.HasChange("file_system_name") { update = true } @@ -267,9 +274,9 @@ func resourceAliCloudDfsFileSystemUpdate(d *schema.ResourceData, meta interface{ } return resource.NonRetryableError(err) } - addDebug(action, response, request) return nil }) + addDebug(action, response, request) if err != nil { return WrapErrorf(err, DefaultErrorMsg, d.Id(), action, AlibabaCloudSdkGoERROR) } @@ -290,8 +297,8 @@ func resourceAliCloudDfsFileSystemDelete(d *schema.ResourceData, meta interface{ return WrapError(err) } request = make(map[string]interface{}) - query["FileSystemId"] = d.Id() - query["InputRegionId"] = client.RegionId + request["FileSystemId"] = d.Id() + request["InputRegionId"] = client.RegionId runtime := util.RuntimeOptions{} runtime.SetAutoretry(true) @@ -306,12 +313,12 @@ func resourceAliCloudDfsFileSystemDelete(d *schema.ResourceData, meta interface{ } return resource.NonRetryableError(err) } - addDebug(action, response, request) return nil }) + addDebug(action, response, request) if err != nil { - if IsExpectedErrors(err, []string{"InvalidParameter.FileSystemNotFound"}) { + if IsExpectedErrors(err, []string{"InvalidParameter.FileSystemNotFound"}) || NotFoundError(err) { return nil } return WrapErrorf(err, DefaultErrorMsg, d.Id(), action, AlibabaCloudSdkGoERROR) diff --git a/alicloud/resource_alicloud_dfs_file_system_test.go b/alicloud/resource_alicloud_dfs_file_system_test.go index 4e193e6578fa..ac400baedbc9 100644 --- a/alicloud/resource_alicloud_dfs_file_system_test.go +++ b/alicloud/resource_alicloud_dfs_file_system_test.go @@ -35,7 +35,7 @@ func init() { func testSweepDFSFileSystem(region string) error { rawClient, err := sharedClientForRegionWithBackendRegions(region, true, connectivity.DfsSupportRegions) if err != nil { - return fmt.Errorf("error getting Alicloud client: %s", err) + return fmt.Errorf("error getting AliCloud client: %s", err) } client := rawClient.(*connectivity.AliyunClient) @@ -109,118 +109,7 @@ func testSweepDFSFileSystem(region string) error { return nil } -func TestAccAliCloudDfsFileSystem_basic0(t *testing.T) { - var v map[string]interface{} - resourceId := "alicloud_dfs_file_system.default" - checkoutSupportedRegions(t, true, connectivity.DfsSupportRegions) - ra := resourceAttrInit(resourceId, AlicloudDFSFileSystemMap0) - rc := resourceCheckInitWithDescribeMethod(resourceId, &v, func() interface{} { - return &DfsService{testAccProvider.Meta().(*connectivity.AliyunClient)} - }, "DescribeDfsFileSystem") - rac := resourceAttrCheckInit(rc, ra) - testAccCheck := rac.resourceAttrMapUpdateSet() - rand := acctest.RandIntRange(10000, 99999) - name := fmt.Sprintf("tf-testacc%sdfsfilesystem%d", defaultRegionToTest, rand) - testAccConfig := resourceTestAccConfigFunc(resourceId, name, AlicloudDFSFileSystemBasicDependence0) - resource.Test(t, resource.TestCase{ - PreCheck: func() { - testAccPreCheck(t) - }, - IDRefreshName: resourceId, - Providers: testAccProviders, - CheckDestroy: rac.checkResourceDestroy(), - Steps: []resource.TestStep{ - { - Config: testAccConfig(map[string]interface{}{ - "storage_type": "${local.storage_type}", - "zone_id": "${local.zone_id}", - "protocol_type": "HDFS", - "description": name, - "file_system_name": name, - "space_capacity": "1024", - "throughput_mode": "Provisioned", - "provisioned_throughput_in_mi_bps": "512", - }), - Check: resource.ComposeTestCheckFunc( - testAccCheck(map[string]string{ - "storage_type": CHECKSET, - "zone_id": CHECKSET, - "protocol_type": "HDFS", - "description": name, - "file_system_name": name, - "space_capacity": "1024", - "throughput_mode": "Provisioned", - "provisioned_throughput_in_mi_bps": "512", - }), - ), - }, - { - Config: testAccConfig(map[string]interface{}{ - "file_system_name": name + "Update", - }), - Check: resource.ComposeTestCheckFunc( - testAccCheck(map[string]string{ - "file_system_name": name + "Update", - }), - ), - }, - { - Config: testAccConfig(map[string]interface{}{ - "description": name + "Update", - }), - Check: resource.ComposeTestCheckFunc( - testAccCheck(map[string]string{ - "description": name + "Update", - }), - ), - }, - { - Config: testAccConfig(map[string]interface{}{ - "space_capacity": "2048", - }), - Check: resource.ComposeTestCheckFunc( - testAccCheck(map[string]string{ - "space_capacity": "2048", - }), - ), - }, - { - Config: testAccConfig(map[string]interface{}{ - "description": name, - "file_system_name": name, - }), - Check: resource.ComposeTestCheckFunc( - testAccCheck(map[string]string{ - "description": name, - "file_system_name": name, - }), - ), - }, - { - ResourceName: resourceId, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - -var AlicloudDFSFileSystemMap0 = map[string]string{} - -func AlicloudDFSFileSystemBasicDependence0(name string) string { - return fmt.Sprintf(` -variable "name" { - default = "%s" -} -data "alicloud_dfs_zones" "default" {} -locals { - zone_id = data.alicloud_dfs_zones.default.zones.0.zone_id - storage_type = data.alicloud_dfs_zones.default.zones.0.options.0.storage_type -} -`, name) -} - -func TestUnitAlicloudDFSFileSystem(t *testing.T) { +func TestUnitAliCloudDFSFileSystem(t *testing.T) { p := Provider().(*schema.Provider).ResourcesMap dInit, _ := schema.InternalMap(p["alicloud_dfs_file_system"].Schema).Data(nil, nil) dExisted, _ := schema.InternalMap(p["alicloud_dfs_file_system"].Schema).Data(nil, nil) @@ -481,7 +370,7 @@ func TestUnitAlicloudDFSFileSystem(t *testing.T) { func TestAccAliCloudDfsFileSystem_basic5910(t *testing.T) { var v map[string]interface{} resourceId := "alicloud_dfs_file_system.default" - ra := resourceAttrInit(resourceId, AlicloudDfsFileSystemMap5910) + ra := resourceAttrInit(resourceId, AliCloudDfsFileSystemMap5910) rc := resourceCheckInitWithDescribeMethod(resourceId, &v, func() interface{} { return &DfsServiceV2{testAccProvider.Meta().(*connectivity.AliyunClient)} }, "DescribeDfsFileSystem") @@ -489,93 +378,38 @@ func TestAccAliCloudDfsFileSystem_basic5910(t *testing.T) { testAccCheck := rac.resourceAttrMapUpdateSet() rand := acctest.RandIntRange(10000, 99999) name := fmt.Sprintf("tf-testacc%sdfsfilesystem%d", defaultRegionToTest, rand) - testAccConfig := resourceTestAccConfigFunc(resourceId, name, AlicloudDfsFileSystemBasicDependence5910) + testAccConfig := resourceTestAccConfigFunc(resourceId, name, AliCloudDfsFileSystemBasicDependence5910) resource.Test(t, resource.TestCase{ PreCheck: func() { + testAccPreCheckWithRegions(t, true, []connectivity.Region{"cn-hangzhou"}) testAccPreCheck(t) - testAccPreCheckWithRegions(t, true, []connectivity.Region{connectivity.Hangzhou}) - testAccPreCheckWithTime(t, []int{1}) }, IDRefreshName: resourceId, Providers: testAccProviders, CheckDestroy: rac.checkResourceDestroy(), Steps: []resource.TestStep{ - { - Config: testAccConfig(map[string]interface{}{ - "space_capacity": "1024", - "storage_type": "${data.alicloud_dfs_zones.default.zones.0.options.0.storage_type}", - "zone_id": "${local.zone_id}", - "protocol_type": "HDFS", - "file_system_name": name, - "throughput_mode": "Provisioned", - "provisioned_throughput_in_mi_bps": "500", - }), - Check: resource.ComposeTestCheckFunc( - testAccCheck(map[string]string{ - "space_capacity": "1024", - "storage_type": CHECKSET, - "zone_id": CHECKSET, - "protocol_type": "HDFS", - "file_system_name": name, - "throughput_mode": "Provisioned", - "provisioned_throughput_in_mi_bps": "500", - }), - ), - }, - { - Config: testAccConfig(map[string]interface{}{ - "description": "ResourceManagerCenterFsTestCase", - }), - Check: resource.ComposeTestCheckFunc( - testAccCheck(map[string]string{ - "description": "ResourceManagerCenterFsTestCase", - }), - ), - }, - { - Config: testAccConfig(map[string]interface{}{ - "provisioned_throughput_in_mi_bps": "1000", - "throughput_mode": "Provisioned", - }), - Check: resource.ComposeTestCheckFunc( - testAccCheck(map[string]string{ - "provisioned_throughput_in_mi_bps": "1000", - "throughput_mode": "Provisioned", - }), - ), - }, - { - Config: testAccConfig(map[string]interface{}{ - "throughput_mode": "Provisioned", - }), - Check: resource.ComposeTestCheckFunc( - testAccCheck(map[string]string{ - "throughput_mode": "Provisioned", - }), - ), - }, { Config: testAccConfig(map[string]interface{}{ "space_capacity": "1024", "description": "ResourceManagerCenterFsTestCase", - "storage_type": "${data.alicloud_dfs_zones.default.zones.0.options.0.storage_type}", - "zone_id": "${local.zone_id}", - "protocol_type": "HDFS", - "file_system_name": name + "_update", + "storage_type": "PERFORMANCE", + "zone_id": "cn-hangzhou-b", + "protocol_type": "PANGU", + "file_system_name": name, "data_redundancy_type": "LRS", - "provisioned_throughput_in_mi_bps": "1024", + "provisioned_throughput_in_mi_bps": "1000", "throughput_mode": "Provisioned", }), Check: resource.ComposeTestCheckFunc( testAccCheck(map[string]string{ "space_capacity": "1024", "description": "ResourceManagerCenterFsTestCase", - "storage_type": CHECKSET, - "zone_id": CHECKSET, - "protocol_type": "HDFS", - "file_system_name": name + "_update", + "storage_type": "PERFORMANCE", + "zone_id": "cn-hangzhou-b", + "protocol_type": "PANGU", + "file_system_name": name, "data_redundancy_type": "LRS", - "provisioned_throughput_in_mi_bps": "1024", + "provisioned_throughput_in_mi_bps": "1000", "throughput_mode": "Provisioned", }), ), @@ -584,27 +418,22 @@ func TestAccAliCloudDfsFileSystem_basic5910(t *testing.T) { ResourceName: resourceId, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"data_redundancy_type", "partition_number", "storage_set_name"}, + ImportStateVerifyIgnore: []string{"data_redundancy_type", "dedicated_cluster_id", "partition_number", "storage_set_name"}, }, }, }) } -var AlicloudDfsFileSystemMap5910 = map[string]string{ +var AliCloudDfsFileSystemMap5910 = map[string]string{ "create_time": CHECKSET, + "region_id": CHECKSET, } -func AlicloudDfsFileSystemBasicDependence5910(name string) string { +func AliCloudDfsFileSystemBasicDependence5910(name string) string { return fmt.Sprintf(` -variable "name" { - default = "%s" -} - -data "alicloud_dfs_zones" "default" {} -locals { - zone_id = data.alicloud_dfs_zones.default.zones.0.zone_id - storage_type = data.alicloud_dfs_zones.default.zones.0.options.0.storage_type -} + variable "name" { + default = "%s" + } `, name) } @@ -612,7 +441,7 @@ locals { func TestAccAliCloudDfsFileSystem_basic5175(t *testing.T) { var v map[string]interface{} resourceId := "alicloud_dfs_file_system.default" - ra := resourceAttrInit(resourceId, AlicloudDfsFileSystemMap5175) + ra := resourceAttrInit(resourceId, AliCloudDfsFileSystemMap5175) rc := resourceCheckInitWithDescribeMethod(resourceId, &v, func() interface{} { return &DfsServiceV2{testAccProvider.Meta().(*connectivity.AliyunClient)} }, "DescribeDfsFileSystem") @@ -620,12 +449,11 @@ func TestAccAliCloudDfsFileSystem_basic5175(t *testing.T) { testAccCheck := rac.resourceAttrMapUpdateSet() rand := acctest.RandIntRange(10000, 99999) name := fmt.Sprintf("tf-testacc%sdfsfilesystem%d", defaultRegionToTest, rand) - testAccConfig := resourceTestAccConfigFunc(resourceId, name, AlicloudDfsFileSystemBasicDependence5175) + testAccConfig := resourceTestAccConfigFunc(resourceId, name, AliCloudDfsFileSystemBasicDependence5175) resource.Test(t, resource.TestCase{ PreCheck: func() { + testAccPreCheckWithRegions(t, true, []connectivity.Region{"cn-hangzhou"}) testAccPreCheck(t) - testAccPreCheckWithRegions(t, true, []connectivity.Region{connectivity.Hangzhou}) - testAccPreCheckWithTime(t, []int{1}) }, IDRefreshName: resourceId, Providers: testAccProviders, @@ -633,92 +461,12 @@ func TestAccAliCloudDfsFileSystem_basic5175(t *testing.T) { Steps: []resource.TestStep{ { Config: testAccConfig(map[string]interface{}{ - "space_capacity": "1024", - "storage_type": "${data.alicloud_dfs_zones.default.zones.0.options.0.storage_type}", - "zone_id": "${local.zone_id}", - "protocol_type": "HDFS", - "file_system_name": name, - }), - Check: resource.ComposeTestCheckFunc( - testAccCheck(map[string]string{ - "space_capacity": "1024", - "storage_type": CHECKSET, - "zone_id": CHECKSET, - "protocol_type": "HDFS", - "file_system_name": name, - }), - ), - }, - { - Config: testAccConfig(map[string]interface{}{ - "description": "ResourceManagerCenterFsTestCase", - }), - Check: resource.ComposeTestCheckFunc( - testAccCheck(map[string]string{ - "description": "ResourceManagerCenterFsTestCase", - }), - ), - }, - { - Config: testAccConfig(map[string]interface{}{ - "space_capacity": "1026", - }), - Check: resource.ComposeTestCheckFunc( - testAccCheck(map[string]string{ - "space_capacity": "1026", - }), - ), - }, - { - Config: testAccConfig(map[string]interface{}{ - "description": "ResourceManagerCenterTestCase-fix", - }), - Check: resource.ComposeTestCheckFunc( - testAccCheck(map[string]string{ - "description": "ResourceManagerCenterTestCase-fix", - }), - ), - }, - { - Config: testAccConfig(map[string]interface{}{ - "file_system_name": name + "_update", - }), - Check: resource.ComposeTestCheckFunc( - testAccCheck(map[string]string{ - "file_system_name": name + "_update", - }), - ), - }, - { - Config: testAccConfig(map[string]interface{}{ - "throughput_mode": "Provisioned", - "provisioned_throughput_in_mi_bps": "1010", - }), - Check: resource.ComposeTestCheckFunc( - testAccCheck(map[string]string{ - "throughput_mode": "Provisioned", - "provisioned_throughput_in_mi_bps": "1010", - }), - ), - }, - { - Config: testAccConfig(map[string]interface{}{ - "throughput_mode": "Standard", - }), - Check: resource.ComposeTestCheckFunc( - testAccCheck(map[string]string{ - "throughput_mode": "Standard", - }), - ), - }, - { - Config: testAccConfig(map[string]interface{}{ - "space_capacity": "1026", + "space_capacity": "1024", "description": "ResourceManagerCenterFsTestCase", - "storage_type": "${data.alicloud_dfs_zones.default.zones.0.options.0.storage_type}", - "zone_id": "${local.zone_id}", - "protocol_type": "HDFS", - "file_system_name": name + "_update", + "storage_type": "STANDARD", + "zone_id": "cn-hangzhou-e", + "protocol_type": "PANGU", + "file_system_name": name, "data_redundancy_type": "LRS", "provisioned_throughput_in_mi_bps": "1000", "throughput_mode": "Provisioned", @@ -727,12 +475,12 @@ func TestAccAliCloudDfsFileSystem_basic5175(t *testing.T) { }), Check: resource.ComposeTestCheckFunc( testAccCheck(map[string]string{ - "space_capacity": "1026", + "space_capacity": "1024", "description": "ResourceManagerCenterFsTestCase", - "storage_type": CHECKSET, - "zone_id": CHECKSET, - "protocol_type": "HDFS", - "file_system_name": name + "_update", + "storage_type": "STANDARD", + "zone_id": "cn-hangzhou-e", + "protocol_type": "PANGU", + "file_system_name": name, "data_redundancy_type": "LRS", "provisioned_throughput_in_mi_bps": "1000", "throughput_mode": "Provisioned", @@ -741,31 +489,54 @@ func TestAccAliCloudDfsFileSystem_basic5175(t *testing.T) { }), ), }, + //provisioned_throughput_in_mi_bps can only be modified once a day + { + Config: testAccConfig(map[string]interface{}{ + "space_capacity": "1026", + "description": "ResourceManagerCenterTestCase-fix", + "file_system_name": name + "_update", + //"provisioned_throughput_in_mi_bps": "1010", + }), + Check: resource.ComposeTestCheckFunc( + testAccCheck(map[string]string{ + "space_capacity": "1026", + "description": "ResourceManagerCenterTestCase-fix", + "file_system_name": name + "_update", + //"provisioned_throughput_in_mi_bps": "1010", + }), + ), + }, + //throughput_mode can only be modified once a day + //{ + // Config: testAccConfig(map[string]interface{}{ + // "throughput_mode": "Standard", + // }), + // Check: resource.ComposeTestCheckFunc( + // testAccCheck(map[string]string{ + // "throughput_mode": "Standard", + // }), + // ), + //}, { ResourceName: resourceId, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"data_redundancy_type", "partition_number", "storage_set_name"}, + ImportStateVerifyIgnore: []string{"data_redundancy_type", "dedicated_cluster_id", "partition_number", "storage_set_name"}, }, }, }) } -var AlicloudDfsFileSystemMap5175 = map[string]string{ +var AliCloudDfsFileSystemMap5175 = map[string]string{ "create_time": CHECKSET, + "region_id": CHECKSET, } -func AlicloudDfsFileSystemBasicDependence5175(name string) string { +func AliCloudDfsFileSystemBasicDependence5175(name string) string { return fmt.Sprintf(` -variable "name" { - default = "%s" -} - -data "alicloud_dfs_zones" "default" {} -locals { - zone_id = data.alicloud_dfs_zones.default.zones.0.zone_id - storage_type = data.alicloud_dfs_zones.default.zones.0.options.0.storage_type -} + variable "name" { + default = "%s" + } `, name) } diff --git a/alicloud/service_alicloud_dfs_v2.go b/alicloud/service_alicloud_dfs_v2.go index a700b35c55f5..a1b40f69926d 100644 --- a/alicloud/service_alicloud_dfs_v2.go +++ b/alicloud/service_alicloud_dfs_v2.go @@ -174,15 +174,15 @@ func (s *DfsServiceV2) DescribeDfsFileSystem(id string) (object map[string]inter var request map[string]interface{} var response map[string]interface{} var query map[string]interface{} - action := "GetFileSystem" conn, err := client.NewDfsClient() if err != nil { return object, WrapError(err) } request = make(map[string]interface{}) query = make(map[string]interface{}) - query["FileSystemId"] = id - query["InputRegionId"] = client.RegionId + request["FileSystemId"] = id + request["InputRegionId"] = client.RegionId + action := "GetFileSystem" runtime := util.RuntimeOptions{} runtime.SetAutoretry(true) @@ -197,14 +197,13 @@ func (s *DfsServiceV2) DescribeDfsFileSystem(id string) (object map[string]inter } return resource.NonRetryableError(err) } - addDebug(action, response, request) return nil }) + addDebug(action, response, request) if err != nil { if IsExpectedErrors(err, []string{"InvalidParameter.FileSystemNotFound"}) { return object, WrapErrorf(Error(GetNotFoundMessage("FileSystem", id)), NotFoundMsg, response) } - addDebug(action, response, request) return object, WrapErrorf(err, DefaultErrorMsg, id, action, AlibabaCloudSdkGoERROR) } @@ -229,6 +228,13 @@ func (s *DfsServiceV2) DfsFileSystemStateRefreshFunc(id string, field string, fa v, err := jsonpath.Get(field, object) currentStatus := fmt.Sprint(v) + if strings.HasPrefix(field, "#") { + v, _ := jsonpath.Get(strings.TrimPrefix(field, "#"), object) + if v != nil { + currentStatus = "#CHECKSET" + } + } + for _, failState := range failStates { if currentStatus == failState { return object, currentStatus, WrapError(Error(FailedToReachTargetStatus, currentStatus)) diff --git a/website/docs/r/dfs_file_system.html.markdown b/website/docs/r/dfs_file_system.html.markdown index 1077e09c02a2..8b8e29a283a9 100644 --- a/website/docs/r/dfs_file_system.html.markdown +++ b/website/docs/r/dfs_file_system.html.markdown @@ -3,14 +3,16 @@ subcategory: "Apsara File Storage for HDFS (DFS)" layout: "alicloud" page_title: "Alicloud: alicloud_dfs_file_system" description: |- - Provides a Alicloud DFS File System resource. + Provides a Alicloud Apsara File Storage for HDFS (DFS) File System resource. --- # alicloud_dfs_file_system -Provides a DFS File System resource. +Provides a Apsara File Storage for HDFS (DFS) File System resource. -For information about DFS File System and how to use it, see [What is File System](https://www.alibabacloud.com/help/en/aibaba-cloud-storage-services/latest/apsara-file-storage-for-hdfs). + + +For information about Apsara File Storage for HDFS (DFS) File System and how to use it, see [What is File System](https://www.alibabacloud.com/help/en/aibaba-cloud-storage-services/latest/apsara-file-storage-for-hdfs). -> **NOTE:** Available since v1.140.0. @@ -33,12 +35,10 @@ variable "name" { default = "tf-example" } -data "alicloud_dfs_zones" "default" {} - resource "alicloud_dfs_file_system" "default" { - storage_type = data.alicloud_dfs_zones.default.zones.0.options.0.storage_type - zone_id = data.alicloud_dfs_zones.default.zones.0.zone_id - protocol_type = "HDFS" + storage_type = "PERFORMANCE" + zone_id = "cn-hangzhou-b" + protocol_type = "PANGU" description = var.name file_system_name = var.name throughput_mode = "Provisioned" @@ -53,10 +53,11 @@ The following arguments are supported: * `data_redundancy_type` - (Optional) Redundancy mode of the file system. Value: - LRS (default): Local redundancy. - ZRS: Same-City redundancy. When ZRS is selected, zoneId is a string consisting of multiple zones that are expected to be redundant in the same city, for example, 'zoneId1,zoneId2 '. +* `dedicated_cluster_id` - (Optional) Dedicated cluster id, which is used to support scenarios such as group cloud migration. * `description` - (Optional) The description of the file system resource. No more than 32 characters in length. * `file_system_name` - (Required) The file system name. The naming rules are as follows: The length is 6~64 characters. Globally unique and cannot be an empty string. English letters are supported and can contain numbers, underscores (_), and dashes (-). * `partition_number` - (Optional, Available since v1.218.0) Save set sequence number, the user selects the content of the specified sequence number in the Save set. -* `protocol_type` - (Required, ForceNew) The protocol type. Only HDFS(Hadoop Distributed File System) is supported. +* `protocol_type` - (Required, ForceNew) The protocol type. Value: `HDFS`, `PANGU`. * `provisioned_throughput_in_mi_bps` - (Optional) Provisioned throughput. This parameter is required when ThroughputMode is set to Provisioned. Unit: MB/s Value range: 1~5120. * `space_capacity` - (Required) File system capacity. When the actual amount of data stored reaches the capacity of the file system, data cannot be written. Unit: GiB. * `storage_set_name` - (Optional, Available since v1.218.0) Save set identity, used to select a user-specified save set. @@ -69,6 +70,7 @@ The following arguments are supported: The following attributes are exported: * `id` - The ID of the resource supplied above. * `create_time` - The creation time of the file system instance. +* `region_id` - (Available since v1.242.0) The region ID of the File System. ## Timeouts @@ -79,8 +81,8 @@ The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/d ## Import -DFS File System can be imported using the id, e.g. +Apsara File Storage for HDFS (DFS) File System can be imported using the id, e.g. ```shell $ terraform import alicloud_dfs_file_system.example -``` \ No newline at end of file +```