From aed7d0270085a9f5ce9c275f293f0cb5ca1e4c49 Mon Sep 17 00:00:00 2001 From: shanye Date: Fri, 13 Sep 2024 11:33:37 +0800 Subject: [PATCH] resource/alicloud_alb_acl: modify acl_name to optional --- alicloud/resource_alicloud_alb_acl.go | 4 +--- alicloud/resource_alicloud_alb_acl_test.go | 10 ++++++++-- website/docs/r/alb_acl.html.markdown | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/alicloud/resource_alicloud_alb_acl.go b/alicloud/resource_alicloud_alb_acl.go index fb2347c690bd..b17bf4b7ed8b 100644 --- a/alicloud/resource_alicloud_alb_acl.go +++ b/alicloud/resource_alicloud_alb_acl.go @@ -3,7 +3,6 @@ package alicloud import ( "fmt" "log" - "regexp" "time" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" @@ -56,8 +55,7 @@ func resourceAlicloudAlbAcl() *schema.Resource { }, "acl_name": { Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`^[a-zA-Z][A-Za-z0-9._-]{2,128}$`), "The name must be `2` to `128` characters in length, and can contain letters, digits, hyphens (-) and underscores (_). It must start with a letter."), + Optional: true, }, "dry_run": { Type: schema.TypeBool, diff --git a/alicloud/resource_alicloud_alb_acl_test.go b/alicloud/resource_alicloud_alb_acl_test.go index e335d8ab6344..fa4be8d52e45 100644 --- a/alicloud/resource_alicloud_alb_acl_test.go +++ b/alicloud/resource_alicloud_alb_acl_test.go @@ -109,7 +109,7 @@ func testSweepAlbAcl(region string) error { return nil } -func TestAccAlicloudALBAcl_basic0(t *testing.T) { +func TestAccAliCloudALBAcl_basic0(t *testing.T) { var v map[string]interface{} resourceId := "alicloud_alb_acl.default" ra := resourceAttrInit(resourceId, AlicloudALBAclMap0) @@ -130,6 +130,12 @@ func TestAccAlicloudALBAcl_basic0(t *testing.T) { Providers: testAccProviders, CheckDestroy: rac.checkResourceDestroy(), Steps: []resource.TestStep{ + { + Config: testAccConfig(map[string]interface{}{}), + Check: resource.ComposeTestCheckFunc( + testAccCheck(map[string]string{}), + ), + }, { Config: testAccConfig(map[string]interface{}{ "acl_name": "${var.name}", @@ -380,7 +386,7 @@ func TestAccAlicloudALBAcl_basic0(t *testing.T) { }) } -func TestAccAlicloudALBAcl_basic1(t *testing.T) { +func TestAccAliCloudALBAcl_basic1(t *testing.T) { var v map[string]interface{} resourceId := "alicloud_alb_acl.default" ra := resourceAttrInit(resourceId, AlicloudALBAclMap0) diff --git a/website/docs/r/alb_acl.html.markdown b/website/docs/r/alb_acl.html.markdown index 18677c12c6ba..ac16d913f5d2 100644 --- a/website/docs/r/alb_acl.html.markdown +++ b/website/docs/r/alb_acl.html.markdown @@ -40,7 +40,7 @@ The following arguments are supported: * `acl_entries` - (Optional, Deprecated from v1.166.0+) The list of the ACL entries. You can add up to `20` entries in each call. See [`acl_entries`](#acl_entries) below for details. **NOTE:** "Field 'acl_entries' has been deprecated from provider version 1.166.0 and it will be removed in the future version. Please use the new resource 'alicloud_alb_acl_entry_attachment'.", -* `acl_name` - (Required) The name of the ACL. The name must be `2` to `128` characters in length, and can contain letters, digits, hyphens (-) and underscores (_). It must start with a letter. +* `acl_name` - (Optional) The name of the ACL. The name must be `2` to `128` characters in length, and can contain letters, digits, hyphens (-) and underscores (_). It must start with a letter. * `dry_run` - (Optional) Specifies whether to precheck the API request. * `resource_group_id` - (Optional, ForceNew) The ID of the resource group. * `tags` - (Optional) A mapping of tags to assign to the resource.