diff --git a/.changelog/2489.txt b/.changelog/2489.txt new file mode 100644 index 0000000000..402fa05432 --- /dev/null +++ b/.changelog/2489.txt @@ -0,0 +1,3 @@ +```release-note:bug +resource/tencentcloud_clb_target_group_attachments: Fixed the problem of not supporting four-layer LB +``` diff --git a/go.mod b/go.mod index b387aa1d25..0a237aa033 100644 --- a/go.mod +++ b/go.mod @@ -43,10 +43,10 @@ require ( github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/chdfs v1.0.600 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ciam v1.0.695 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ckafka v1.0.748 - github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb v1.0.847 + github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb v1.0.860 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cloudaudit v1.0.544 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls v1.0.711 - github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.859 + github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.860 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.624 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cwp v1.0.762 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cynosdb v1.0.692 diff --git a/go.sum b/go.sum index b045dfbaf3..6b3bc0b924 100644 --- a/go.sum +++ b/go.sum @@ -868,6 +868,8 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb v1.0.693 h1:3eI2Ciq github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb v1.0.693/go.mod h1:WhFqrn14QuRHB01xA5Q9sC+xw73BpqSE5+ZnqEznCW8= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb v1.0.847 h1:VfUval30/CDPnvS5KpvTpM6v7HcErCgwPTsyN9VDqpM= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb v1.0.847/go.mod h1:zR4WM8Cg+v4daLgPLfmmzFrXCQFrQYIn+7DqBL60uRc= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb v1.0.860 h1:P2TPFCB1oyJ6yOTgFDBdKByepog3iMg2fIUN/VHo9EM= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb v1.0.860/go.mod h1:eTGN2Qz4NxaYl+CwMpcj4vNImNOr74NC8WTCLSJN8Ks= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cloudaudit v1.0.544 h1:ApY6rS7I9otgujOdAFy0+Epno1PNVCQmsOoWQxx724Y= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cloudaudit v1.0.544/go.mod h1:c37rIdL3LrJXYwrfp9c8L4MabTqKIZUe1xvnWhN75oc= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls v1.0.711 h1:v6ffPkv3kmT6bC0d3JLVVJsh61zdvaLJZ5RHwmKNBHk= @@ -961,6 +963,8 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.856 h1:4Paa github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.856/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.859 h1:XXpytsYJilIk/koSWmpEcDZBILNqeEUprU9L5gqbA00= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.859/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.860 h1:d5/YwGX6b5YgFU/0thsbs5aBp4aJJXBi7JyU1JHAaw0= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.860/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.624 h1:nEZqsoqt1pEoaP9JjkHQy3/H00suCfzlHW1qOm2nYD8= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.624/go.mod h1:+TXSVyeKwt1IhZRqKPbTREteBcP+K07Q846/ilNzLWA= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cwp v1.0.762 h1:2egy69SP/wPsmnfozcQVZ6tUY6F6N/TpEe/7xtXrc/8= diff --git a/tencentcloud/services/clb/resource_tc_clb_target_group_attachments.go b/tencentcloud/services/clb/resource_tc_clb_target_group_attachments.go index d9b7599856..e9a18e59ec 100644 --- a/tencentcloud/services/clb/resource_tc_clb_target_group_attachments.go +++ b/tencentcloud/services/clb/resource_tc_clb_target_group_attachments.go @@ -21,7 +21,6 @@ func ResourceTencentCloudClbTargetGroupAttachments() *schema.Resource { return &schema.Resource{ Create: resourceTencentCloudClbTargetGroupAttachmentsCreate, Read: resourceTencentCloudClbTargetGroupAttachmentsRead, - Update: resourceTencentCloudClbTargetGroupAttachmentsUpdate, Delete: resourceTencentCloudClbTargetGroupAttachmentsDelete, Importer: &schema.ResourceImporter{ State: schema.ImportStatePassthrough, @@ -31,15 +30,18 @@ func ResourceTencentCloudClbTargetGroupAttachments() *schema.Resource { "load_balancer_id": { Type: schema.TypeString, Optional: true, + ForceNew: true, Description: "CLB instance ID, (load_balancer_id and target_group_id require at least one).", }, "target_group_id": { Type: schema.TypeString, Optional: true, + ForceNew: true, Description: "Target group ID, (load_balancer_id and target_group_id require at least one).", }, "associations": { Required: true, + ForceNew: true, Type: schema.TypeSet, MaxItems: 20, Description: "Association array, the combination cannot exceed 20.", @@ -48,20 +50,24 @@ func ResourceTencentCloudClbTargetGroupAttachments() *schema.Resource { "load_balancer_id": { Type: schema.TypeString, Optional: true, + ForceNew: true, Description: "CLB instance ID, when the binding target is target group, load_balancer_id in associations is required.", }, "target_group_id": { Type: schema.TypeString, Optional: true, + ForceNew: true, Description: "Target group ID, when the binding target is clb, the target_group_id in associations is required.", }, "listener_id": { Type: schema.TypeString, + ForceNew: true, Optional: true, Description: "Listener ID.", }, "location_id": { Type: schema.TypeString, + ForceNew: true, Optional: true, Description: "Forwarding rule ID.", }, @@ -203,10 +209,12 @@ func resourceTencentCloudClbTargetGroupAttachmentsRead(d *schema.ResourceData, m _ = d.Set("target_group_id", info[1]) associationsMap["load_balancer_id"] = info[0] } - - associationsMap["listener_id"] = info[2] - associationsMap["location_id"] = info[3] - + if info[2] != "" && info[2] != "null" { + associationsMap["listener_id"] = info[2] + } + if info[3] != "" && info[3] != "null" { + associationsMap["location_id"] = info[3] + } associationsList = append(associationsList, associationsMap) } @@ -215,13 +223,6 @@ func resourceTencentCloudClbTargetGroupAttachmentsRead(d *schema.ResourceData, m return nil } -func resourceTencentCloudClbTargetGroupAttachmentsUpdate(d *schema.ResourceData, meta interface{}) error { - defer tccommon.LogElapsed("resource.tencentcloud_clb_target_group_attachments.update")() - defer tccommon.InconsistentCheck(d, meta)() - - return resourceTencentCloudClbTargetGroupAttachmentsRead(d, meta) -} - func resourceTencentCloudClbTargetGroupAttachmentsDelete(d *schema.ResourceData, meta interface{}) error { defer tccommon.LogElapsed("resource.tencentcloud_clb_target_group_attachments.delete")() defer tccommon.InconsistentCheck(d, meta)() @@ -268,7 +269,9 @@ func parseParamToRequest(d *schema.ResourceData, param string, id string) (assoc targetGroupAssociation := clb.TargetGroupAssociation{} dMap[param] = id for name := range dMap { - setString(name, dMap[name].(string), &targetGroupAssociation) + if dMap[name] != nil && dMap[name].(string) != "" { + setString(name, dMap[name].(string), &targetGroupAssociation) + } } associations = append(associations, &targetGroupAssociation) } @@ -331,7 +334,7 @@ func processIds(id string, dMap map[string]interface{}, key string, clbFlag bool } else if !clbFlag && key == "target_group_id" { *ids = append(*ids, id) } else { - if v, ok := dMap[key]; ok { + if v, ok := dMap[key]; ok && v.(string) != "" { *ids = append(*ids, v.(string)) } else { *ids = append(*ids, "null") diff --git a/tencentcloud/services/clb/resource_tc_clb_target_group_attachments_test.go b/tencentcloud/services/clb/resource_tc_clb_target_group_attachments_test.go index 238ba68cfc..c3364492c3 100644 --- a/tencentcloud/services/clb/resource_tc_clb_target_group_attachments_test.go +++ b/tencentcloud/services/clb/resource_tc_clb_target_group_attachments_test.go @@ -67,6 +67,25 @@ func TestAccTencentCloudClbTargetGroupAttachmentsResource_sync(t *testing.T) { }) } +func TestAccTencentCloudClbTargetGroupAttachmentsResource_tcp(t *testing.T) { + t.Parallel() + resource.Test(t, resource.TestCase{ + PreCheck: func() { + tcacctest.AccPreCheck(t) + }, + Providers: tcacctest.AccProviders, + Steps: []resource.TestStep{ + { + Config: testAccClbTargetGroupAttachmentsTCP, + Check: resource.ComposeTestCheckFunc(resource.TestCheckResourceAttrSet("tencentcloud_clb_target_group_attachments.target_group_attachments", "id"), + resource.TestCheckResourceAttrSet("tencentcloud_clb_target_group_attachments.target_group_attachments", "target_group_id"), + resource.TestCheckResourceAttrSet("tencentcloud_clb_target_group_attachments.target_group_attachments", "associations.#"), + ), + }, + }, + }) +} + const testAccClbTargetGroupAttachments = ` resource "tencentcloud_clb_instance" "clb_basic" { @@ -353,3 +372,24 @@ resource "tencentcloud_clb_target_group_attachments" "target_group_attachments1" } } ` +const testAccClbTargetGroupAttachmentsTCP = ` +resource "tencentcloud_clb_instance" "clb_basic" { + network_type = "OPEN" + clb_name = "tf_test_clb_attach_1" + vpc_id = "vpc-efc9vddt" +} +resource "tencentcloud_clb_listener" "public_listeners" { + clb_id = tencentcloud_clb_instance.clb_basic.id + protocol = "TCP" + port = "8090" + listener_name = "iac-test-attach" + target_type = "TARGETGROUP" +} +resource "tencentcloud_clb_target_group_attachments" "target_group_attachments" { + target_group_id = "lbtg-nxd0dmcm" + associations { + load_balancer_id = tencentcloud_clb_instance.clb_basic.id + listener_id = tencentcloud_clb_listener.public_listeners.listener_id + } +} +` diff --git a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/http/request.go b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/http/request.go index 2d0e781955..80caf9eb3a 100644 --- a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/http/request.go +++ b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/http/request.go @@ -265,7 +265,7 @@ func CompleteCommonParams(request Request, region string, requestClient string) params["Action"] = request.GetAction() params["Timestamp"] = strconv.FormatInt(time.Now().Unix(), 10) params["Nonce"] = strconv.Itoa(rand.Int()) - params["RequestClient"] = "SDK_GO_1.0.859" + params["RequestClient"] = "SDK_GO_1.0.860" if requestClient != "" { params["RequestClient"] += ": " + requestClient } diff --git a/vendor/modules.txt b/vendor/modules.txt index d3027fda8e..633b9b7a8d 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1148,7 +1148,7 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ciam/v20220331 # github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ckafka v1.0.748 ## explicit; go 1.14 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ckafka/v20190819 -# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb v1.0.847 +# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb v1.0.860 ## explicit; go 1.14 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb/v20180317 # github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cloudaudit v1.0.544 @@ -1157,7 +1157,7 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cloudaudit/v20190319 # github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls v1.0.711 ## explicit; go 1.14 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls/v20201016 -# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.859 +# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.860 ## explicit; go 1.11 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors diff --git a/website/docs/r/clb_target_group_attachments.html.markdown b/website/docs/r/clb_target_group_attachments.html.markdown index b5d1b447d7..1a96726de8 100644 --- a/website/docs/r/clb_target_group_attachments.html.markdown +++ b/website/docs/r/clb_target_group_attachments.html.markdown @@ -45,16 +45,16 @@ resource "tencentcloud_clb_target_group_attachments" "target_group_attachments" The following arguments are supported: -* `associations` - (Required, Set) Association array, the combination cannot exceed 20. -* `load_balancer_id` - (Optional, String) CLB instance ID, (load_balancer_id and target_group_id require at least one). -* `target_group_id` - (Optional, String) Target group ID, (load_balancer_id and target_group_id require at least one). +* `associations` - (Required, Set, ForceNew) Association array, the combination cannot exceed 20. +* `load_balancer_id` - (Optional, String, ForceNew) CLB instance ID, (load_balancer_id and target_group_id require at least one). +* `target_group_id` - (Optional, String, ForceNew) Target group ID, (load_balancer_id and target_group_id require at least one). The `associations` object supports the following: -* `listener_id` - (Optional, String) Listener ID. -* `load_balancer_id` - (Optional, String) CLB instance ID, when the binding target is target group, load_balancer_id in associations is required. -* `location_id` - (Optional, String) Forwarding rule ID. -* `target_group_id` - (Optional, String) Target group ID, when the binding target is clb, the target_group_id in associations is required. +* `listener_id` - (Optional, String, ForceNew) Listener ID. +* `load_balancer_id` - (Optional, String, ForceNew) CLB instance ID, when the binding target is target group, load_balancer_id in associations is required. +* `location_id` - (Optional, String, ForceNew) Forwarding rule ID. +* `target_group_id` - (Optional, String, ForceNew) Target group ID, when the binding target is clb, the target_group_id in associations is required. ## Attributes Reference