@@ -31,11 +31,9 @@ import (
3131 "fmt"
3232 "log"
3333 "strings"
34- "time"
3534
3635 "github.com/hashicorp/terraform-plugin-sdk/helper/resource"
3736 "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
38- "github.com/terraform-providers/terraform-provider-tencentcloud/tencentcloud/internal/helper"
3937)
4038
4139func resourceTencentCloudVpcAclAttachment () * schema.Resource {
@@ -49,19 +47,17 @@ func resourceTencentCloudVpcAclAttachment() *schema.Resource {
4947
5048 Schema : map [string ]* schema.Schema {
5149 "acl_id" : {
50+ Type : schema .TypeString ,
51+ Required : true ,
52+ ForceNew : true ,
53+ ValidateFunc : validateNotEmpty ,
54+ Description : "Id of the attached ACL." ,
55+ },
56+ "subnet_id" : {
5257 Type : schema .TypeString ,
5358 Required : true ,
5459 ForceNew : true ,
55- Description : "Id of the attached ACL." ,
56- },
57- "subnet_ids" : {
58- Type : schema .TypeList ,
59- Required : true ,
60- ForceNew : true ,
61- Elem : & schema.Schema {
62- Type : schema .TypeString ,
63- },
64- Description : "ID list of the Subnet instance ID." ,
60+ Description : " the Subnet instance ID." ,
6561 },
6662 },
6763 }
@@ -75,28 +71,23 @@ func resourceTencentCloudVpcAclAttachmentCreate(d *schema.ResourceData, meta int
7571 service = VpcService {client : meta .(* TencentCloudClient ).apiV3Conn }
7672 aclId string
7773 subnetIds []string
78- sub_id string
74+ subnetId string
7975 )
8076
8177 if temp , ok := d .GetOk ("acl_id" ); ok {
8278 aclId = temp .(string )
83- if len (aclId ) < 1 {
84- return fmt .Errorf ("acl_id should be not empty string" )
85- }
8679 }
87- if temp , ok := d .GetOk ("subnet_ids " ); ok {
88- subnetIds = helper . InterfacesStrings ( temp .([] interface {}) )
80+ if temp , ok := d .GetOk ("subnet_id " ); ok {
81+ subnetId = temp .(string )
8982 }
83+ subnetIds = append (subnetIds , subnetId )
9084
9185 err := service .AssociateAclSubnets (ctx , aclId , subnetIds )
9286 if err != nil {
9387 return err
9488 }
9589
96- for _ , temp_id := range subnetIds {
97- sub_id = sub_id + "#" + temp_id
98- }
99- d .SetId (aclId + "#" + sub_id )
90+ d .SetId (aclId + "#" + subnetId )
10091
10192 aclAttachmentId := d .Id ()
10293 err = resource .Retry (readRetryTimeout , func () * resource.RetryError {
@@ -110,7 +101,6 @@ func resourceTencentCloudVpcAclAttachmentCreate(d *schema.ResourceData, meta int
110101 log .Printf ("[CRITAL]%s read acl attachment failed, reason:%s\n " , logId , err .Error ())
111102 return err
112103 }
113- time .Sleep (10 * time .Second )
114104
115105 return resourceTencentCloudVpcAclAttachmentRead (d , meta )
116106}
@@ -158,6 +148,7 @@ func resourceTencentCloudVpcAclAttachmentDelete(d *schema.ResourceData, meta int
158148 log .Printf ("[CRITAL]%s delete acl attachment failed, reason:%s\n " , logId , err .Error ())
159149 return err
160150 }
151+ d .SetId ("" )
161152
162153 return nil
163154
0 commit comments