diff --git a/go.mod b/go.mod index 546c645774..1aa1632def 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.1073 - github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb v1.0.1107 + github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb v1.0.1132 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cloudaudit v1.0.1033 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls v1.0.1078 - github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1130 + github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1132 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.1128 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cwp v1.0.762 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cynosdb v1.0.1111 diff --git a/go.sum b/go.sum index 424111020f..abb581cc62 100644 --- a/go.sum +++ b/go.sum @@ -860,6 +860,8 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ckafka v1.0.1073 h1:+nT github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ckafka v1.0.1073/go.mod h1:D9xdyB3utAtgGwTExSGxHSVQMfVHEUo/bfaBTxjHkao= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb v1.0.1107 h1:sUiyGfYHzNpHKJx6DlRu1K8xBEGaWlOQT+8W5Ws0v4U= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb v1.0.1107/go.mod h1:L1r6mc7XjFlyLlOVqRvPEhjXneHywnyjyv9EoiGBRvM= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb v1.0.1132 h1:dXKq4d4zTZYV0q1uyf7AJM+u00dd5ndL7lqGfjkmQW0= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb v1.0.1132/go.mod h1:nwCB78ZVNC6VC+rd31yxhUeff/Ve7z4+yrL3A2B+/dg= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cloudaudit v1.0.1033 h1:dIr+MVsZeUBiKZELfJh5HRJdI+BI6lCp5pv/2oXekuk= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cloudaudit v1.0.1033/go.mod h1:7oFlNimGSTHFy6JV7W/IZKuJWr+NUjCnGLTvb9MWNrY= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls v1.0.1078 h1:6yf63sgR2q1ikVedWTXldtrArDHXG01yIdcWSSI5e5Y= @@ -933,6 +935,8 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1128/go.mod github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1129/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1130 h1:pjtrqJUaidq1fFWwPvBorq7FScq0LXiQ7pZjJZx3Jsc= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1130/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1132 h1:ecdDh9up1kMKSZtEpvRHGF6BsIlfBtdCSBZm3SK5/Xk= +github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1132/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/controlcenter v1.0.993 h1:WlPgXldQCxt7qi5Xrc6j6zTrsXWzN5BcOGs7Irq7fwQ= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/controlcenter v1.0.993/go.mod h1:Z9U8zNtyuyKhjS0698wqsrG/kLx1TQ5CEixXBwVe7xY= github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/csip v1.0.860 h1:F3esKBIT3HW9+7Gt8cVgf8X06VdGIczpgLBUECzSEzU= diff --git a/tencentcloud/services/clb/resource_tc_clb_listener.go b/tencentcloud/services/clb/resource_tc_clb_listener.go index b5f4da9051..a628880a05 100644 --- a/tencentcloud/services/clb/resource_tc_clb_listener.go +++ b/tencentcloud/services/clb/resource_tc_clb_listener.go @@ -281,6 +281,12 @@ func ResourceTencentCloudClbListener() *schema.Resource { Optional: true, Description: "Whether to enable SNAT.", }, + "full_end_ports": { + Type: schema.TypeList, + Optional: true, + Description: "End port of the full port segment listener.", + Elem: &schema.Schema{Type: schema.TypeInt}, + }, //computed "listener_id": { Type: schema.TypeString, @@ -411,6 +417,15 @@ func resourceTencentCloudClbListenerCreate(d *schema.ResourceData, meta interfac request.SnatEnable = helper.Bool(v.(bool)) } + if v, ok := d.GetOk("full_end_ports"); ok { + fullEndPorts := v.([]interface{}) + request.FullEndPorts = make([]*int64, 0, len(fullEndPorts)) + for i := range fullEndPorts { + item := fullEndPorts[i].(int) + request.FullEndPorts = append(request.FullEndPorts, helper.IntInt64(item)) + } + } + var response *clb.CreateListenerResponse err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError { result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseClbClient().CreateListener(request) diff --git a/tencentcloud/services/clb/resource_tc_clb_target_group.go b/tencentcloud/services/clb/resource_tc_clb_target_group.go index 27bdf1e826..7144721142 100644 --- a/tencentcloud/services/clb/resource_tc_clb_target_group.go +++ b/tencentcloud/services/clb/resource_tc_clb_target_group.go @@ -2,9 +2,13 @@ package clb import ( "context" + "fmt" + "log" tccommon "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/common" + "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" clb "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb/v20180317" ) @@ -36,7 +40,7 @@ func ResourceTencentCloudClbTargetGroup() *schema.Resource { Type: schema.TypeInt, Optional: true, ValidateFunc: tccommon.ValidatePort, - Description: "The default port of target group, add server after can use it.", + Description: "The default port of target group, add server after can use it. If `full_listen_switch` is true, setting this parameter is not supported.", }, "target_group_instances": { Type: schema.TypeList, @@ -72,6 +76,49 @@ func ResourceTencentCloudClbTargetGroup() *schema.Resource { }, }, }, + "type": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ValidateFunc: tccommon.ValidateAllowedStringValue([]string{"v1", "v2"}), + Description: "Target group type, currently supports v1 (old version target group), v2 (new version target group), defaults to v1 (old version target group).", + }, + "protocol": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: tccommon.ValidateAllowedStringValue([]string{"TCP", "UDP"}), + Description: "Target group backend forwarding protocol. This item is required for the v2 new version target group. Currently supports `TCP`, `UDP`.", + }, + "tags": { + Optional: true, + Type: schema.TypeList, + Description: "Label.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "tag_key": { + Type: schema.TypeString, + Required: true, + Description: "Tag key.", + }, + "tag_value": { + Type: schema.TypeString, + Required: true, + Description: "Tag value.", + }, + }, + }, + }, + "weight": { + Type: schema.TypeInt, + Optional: true, + ValidateFunc: tccommon.ValidateIntegerInRange(0, 100), + Description: "Default weights for backend services. Value range [0, 100]. After setting this value, when adding backend services to the target group, if the backend services do not have separate weights set, the default weights here will be used.", + }, + "full_listen_switch": { + Type: schema.TypeBool, + Optional: true, + Description: "Full listening target group identifier, true indicates full listening target group, false indicates not full listening target group.", + }, }, } } @@ -80,40 +127,81 @@ func resourceTencentCloudClbTargetCreate(d *schema.ResourceData, meta interface{ defer tccommon.LogElapsed("resource.tencentcloud_clb_target_group.create")() var ( - logId = tccommon.GetLogId(tccommon.ContextNil) - ctx = context.WithValue(context.TODO(), tccommon.LogIdKey, logId) - clbService = ClbService{client: meta.(tccommon.ProviderMeta).GetAPIV3Conn()} - vpcId = d.Get("vpc_id").(string) - targetGroupName = d.Get("target_group_name").(string) - port = uint64(d.Get("port").(int)) - insAttachments = make([]*clb.TargetGroupInstance, 0) - targetGroupId string - err error + logId = tccommon.GetLogId(tccommon.ContextNil) + request = clb.NewCreateTargetGroupRequest() + response = clb.NewCreateTargetGroupResponse() ) - if v, ok := d.GetOk("target_group_instances"); ok { - targetGroupInstances := v.([]interface{}) - for _, v1 := range targetGroupInstances { - value := v1.(map[string]interface{}) - bindIP := value["bind_ip"].(string) - port := uint64(value["port"].(int)) - weight := uint64(value["weight"].(int)) - newPort := uint64(value["new_port"].(int)) - tgtGrp := &clb.TargetGroupInstance{ - BindIP: &bindIP, - Port: &port, - Weight: &weight, - NewPort: &newPort, + if v, ok := d.GetOk("target_group_name"); ok { + request.TargetGroupName = helper.String(v.(string)) + } + + if v, ok := d.GetOk("vpc_id"); ok { + request.VpcId = helper.String(v.(string)) + } + + if v, ok := d.GetOkExists("port"); ok { + request.Port = helper.IntUint64(v.(int)) + } + + if v, ok := d.GetOk("type"); ok { + request.Type = helper.String(v.(string)) + } + + if v, ok := d.GetOk("protocol"); ok { + request.Protocol = helper.String(v.(string)) + } + + if v, ok := d.GetOk("tags"); ok { + for _, item := range v.([]interface{}) { + dMap := item.(map[string]interface{}) + clbTags := clb.TagInfo{} + if v, ok := dMap["tag_key"]; ok { + clbTags.TagKey = helper.String(v.(string)) + } + + if v, ok := dMap["tag_value"]; ok { + clbTags.TagValue = helper.String(v.(string)) } - insAttachments = append(insAttachments, tgtGrp) + + request.Tags = append(request.Tags, &clbTags) } } - targetGroupId, err = clbService.CreateTargetGroup(ctx, targetGroupName, vpcId, port, insAttachments) + if v, ok := d.GetOkExists("weight"); ok { + request.Weight = helper.IntUint64(v.(int)) + } + + if v, ok := d.GetOkExists("full_listen_switch"); ok { + request.FullListenSwitch = helper.Bool(v.(bool)) + } + + err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError { + result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseClbClient().CreateTargetGroup(request) + if e != nil { + return tccommon.RetryError(e) + } else { + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString()) + } + + if result == nil || result.Response == nil { + return resource.NonRetryableError(fmt.Errorf("Create target group failed, Response is nil.")) + } + + response = result + return nil + }) + if err != nil { + log.Printf("[CRITAL]%s create target group failed, reason:%+v", logId, err) return err } - d.SetId(targetGroupId) + + if response.Response.TargetGroupId == nil { + return fmt.Errorf("TargetGroupId is nil.") + } + + d.SetId(*response.Response.TargetGroupId) return resourceTencentCloudClbTargetRead(d, meta) @@ -124,23 +212,64 @@ func resourceTencentCloudClbTargetRead(d *schema.ResourceData, meta interface{}) defer tccommon.InconsistentCheck(d, meta)() var ( - logId = tccommon.GetLogId(tccommon.ContextNil) - ctx = context.WithValue(context.TODO(), tccommon.LogIdKey, logId) - clbService = ClbService{client: meta.(tccommon.ProviderMeta).GetAPIV3Conn()} - id = d.Id() + logId = tccommon.GetLogId(tccommon.ContextNil) + ctx = context.WithValue(context.TODO(), tccommon.LogIdKey, logId) + clbService = ClbService{client: meta.(tccommon.ProviderMeta).GetAPIV3Conn()} + targetGroupId = d.Id() ) + filters := make(map[string]string) - targetGroupInfos, err := clbService.DescribeTargetGroups(ctx, id, filters) + targetGroupInfos, err := clbService.DescribeTargetGroups(ctx, targetGroupId, filters) if err != nil { return err } + if len(targetGroupInfos) < 1 { d.SetId("") return nil } - _ = d.Set("target_group_name", targetGroupInfos[0].TargetGroupName) - _ = d.Set("vpc_id", targetGroupInfos[0].VpcId) - _ = d.Set("port", targetGroupInfos[0].Port) + + if targetGroupInfos[0].TargetGroupName != nil { + _ = d.Set("target_group_name", targetGroupInfos[0].TargetGroupName) + } + + if targetGroupInfos[0].VpcId != nil { + _ = d.Set("vpc_id", targetGroupInfos[0].VpcId) + } + + if targetGroupInfos[0].Port != nil { + _ = d.Set("port", targetGroupInfos[0].Port) + } + + if targetGroupInfos[0].TargetGroupType != nil { + _ = d.Set("type", targetGroupInfos[0].TargetGroupType) + } + + if targetGroupInfos[0].Tag != nil { + tagsList := make([]interface{}, 0, len(targetGroupInfos[0].Tag)) + for _, tags := range targetGroupInfos[0].Tag { + tagsMap := map[string]interface{}{} + if tags.TagKey != nil { + tagsMap["tag_key"] = tags.TagKey + } + + if tags.TagValue != nil { + tagsMap["tag_value"] = tags.TagValue + } + + tagsList = append(tagsList, tagsMap) + } + + _ = d.Set("tags", tagsList) + } + + if targetGroupInfos[0].Weight != nil { + _ = d.Set("weight", targetGroupInfos[0].Weight) + } + + if targetGroupInfos[0].FullListenSwitch != nil { + _ = d.Set("full_listen_switch", targetGroupInfos[0].FullListenSwitch) + } return nil } @@ -150,23 +279,44 @@ func resourceTencentCloudClbTargetUpdate(d *schema.ResourceData, meta interface{ var ( logId = tccommon.GetLogId(tccommon.ContextNil) - ctx = context.WithValue(context.TODO(), tccommon.LogIdKey, logId) - clbService = ClbService{client: meta.(tccommon.ProviderMeta).GetAPIV3Conn()} targetGroupId = d.Id() - port uint64 - tgtGroupName string ) - isChanged := false - if d.HasChange("port") || d.HasChange("target_group_name") { - isChanged = true - port = uint64(d.Get("port").(int)) - tgtGroupName = d.Get("target_group_name").(string) + immutableArgs := []string{"type", "protocol", "tags", "full_listen_switch"} + for _, v := range immutableArgs { + if d.HasChange(v) { + return fmt.Errorf("argument `%s` cannot be changed", v) + } } - if isChanged { - err := clbService.ModifyTargetGroup(ctx, targetGroupId, tgtGroupName, port) + if d.HasChange("target_group_name") || d.HasChange("port") || d.HasChange("weight") { + request := clb.NewModifyTargetGroupAttributeRequest() + if v, ok := d.GetOk("target_group_name"); ok { + request.TargetGroupName = helper.String(v.(string)) + } + + if v, ok := d.GetOkExists("port"); ok { + request.Port = helper.IntUint64(v.(int)) + } + + if v, ok := d.GetOkExists("weight"); ok { + request.Weight = helper.IntUint64(v.(int)) + } + + request.TargetGroupId = &targetGroupId + err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError { + result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseClbClient().ModifyTargetGroupAttribute(request) + if e != nil { + return tccommon.RetryError(e) + } else { + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString()) + } + + return nil + }) + if err != nil { + log.Printf("[CRITAL]%s modify target group failed, reason:%+v", logId, err) return err } } @@ -185,9 +335,9 @@ func resourceTencentCloudClbTargetDelete(d *schema.ResourceData, meta interface{ ) err := clbService.DeleteTarget(ctx, targetGroupId) - if err != nil { return err } + return nil } diff --git a/tencentcloud/services/clb/resource_tc_clb_target_group.md b/tencentcloud/services/clb/resource_tc_clb_target_group.md index 4b73493049..5bb0765da4 100644 --- a/tencentcloud/services/clb/resource_tc_clb_target_group.md +++ b/tencentcloud/services/clb/resource_tc_clb_target_group.md @@ -2,10 +2,55 @@ Provides a resource to create a CLB target group. Example Usage +If type is v1 + +```hcl +resource "tencentcloud_clb_target_group" "example" { + target_group_name = "tf-example" + vpc_id = "vpc-jy6pwoy2" + port = 8090 + type = "v1" + + tags { + tag_key = "tagKey" + tag_value = "tagValue" + } +} +``` + +If type is v2 + ```hcl -resource "tencentcloud_clb_target_group" "test"{ - target_group_name = "test" - port = 33 +resource "tencentcloud_clb_target_group" "example" { + target_group_name = "tf-example" + vpc_id = "vpc-jy6pwoy2" + port = 8090 + type = "v2" + protocol = "TCP" + weight = 60 + + tags { + tag_key = "tagKey" + tag_value = "tagValue" + } +} +``` + +Or full_listen_switch is true + +```hcl +resource "tencentcloud_clb_target_group" "example" { + target_group_name = "tf-example" + vpc_id = "vpc-jy6pwoy2" + type = "v2" + protocol = "TCP" + weight = 60 + full_listen_switch = true + + tags { + tag_key = "tagKey" + tag_value = "tagValue" + } } ``` @@ -14,5 +59,5 @@ Import CLB target group can be imported using the id, e.g. ``` -$ terraform import tencentcloud_clb_target_group.test lbtg-3k3io0i0 -``` \ No newline at end of file +$ terraform import tencentcloud_clb_target_group.example lbtg-3k3io0i0 +``` diff --git a/tencentcloud/services/clb/resource_tc_clb_target_group_attachment.go b/tencentcloud/services/clb/resource_tc_clb_target_group_attachment.go index 85d59d957a..4461fd0c1a 100644 --- a/tencentcloud/services/clb/resource_tc_clb_target_group_attachment.go +++ b/tencentcloud/services/clb/resource_tc_clb_target_group_attachment.go @@ -49,6 +49,13 @@ func ResourceTencentCloudClbTargetGroupAttachment() *schema.Resource { ForceNew: true, Description: "ID of the CLB listener rule.", }, + "weight": { + Type: schema.TypeInt, + Optional: true, + ForceNew: true, + ValidateFunc: tccommon.ValidateIntegerInRange(0, 100), + Description: "Target group weight, range [0, 100]. It only takes effect when binding to the v2 target group. If it does not exist, it defaults to 10.", + }, }, } } @@ -89,6 +96,10 @@ func resourceTencentCloudClbTargetGroupAttachmentCreate(d *schema.ResourceData, locationId = v.(string) } + if v, ok := d.GetOkExists("weight"); ok { + targetGroupAssociation.Weight = helper.IntInt64(v.(int)) + } + //check listenerId checkErr := ListenerIdCheck(listenerId) if checkErr != nil { @@ -195,7 +206,7 @@ func resourceTencentCloudClbTargetGroupAttachmentRead(d *schema.ResourceData, me return fmt.Errorf("CLB target group attachment id is clb_id#listener_id#target_group_id#rule_id(only required for 7 layer CLB)") } - has, err := clbService.DescribeAssociateTargetGroups(ctx, ids) + targetInfo, has, err := clbService.DescribeAssociateTargetGroups(ctx, ids) if err != nil { return err } @@ -212,6 +223,10 @@ func resourceTencentCloudClbTargetGroupAttachmentRead(d *schema.ResourceData, me _ = d.Set("rule_id", ids[3]) } + if targetInfo.Weight != nil { + _ = d.Set("weight", targetInfo.Weight) + } + return nil } diff --git a/tencentcloud/services/clb/resource_tc_clb_target_group_attachment_test.go b/tencentcloud/services/clb/resource_tc_clb_target_group_attachment_test.go index 0de3babf64..e29ac84827 100644 --- a/tencentcloud/services/clb/resource_tc_clb_target_group_attachment_test.go +++ b/tencentcloud/services/clb/resource_tc_clb_target_group_attachment_test.go @@ -125,7 +125,7 @@ func testAccCheckClbTargetGroupAttachmentExists(n string) resource.TestCheckFunc return fmt.Errorf("CLB target group attachment id is clb_id#listener_id#target_group_id#rule_id(only required for 7 layer CLB)") } - has, err := clbService.DescribeAssociateTargetGroups(ctx, ids) + _, has, err := clbService.DescribeAssociateTargetGroups(ctx, ids) if err != nil { return err } 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 e9a18e59ec..4e2ab5beb7 100644 --- a/tencentcloud/services/clb/resource_tc_clb_target_group_attachments.go +++ b/tencentcloud/services/clb/resource_tc_clb_target_group_attachments.go @@ -71,6 +71,13 @@ func ResourceTencentCloudClbTargetGroupAttachments() *schema.Resource { Optional: true, Description: "Forwarding rule ID.", }, + "weight": { + Type: schema.TypeInt, + Optional: true, + ForceNew: true, + ValidateFunc: tccommon.ValidateIntegerInRange(0, 100), + Description: "Target group weight, range [0, 100]. It only takes effect when binding to the v2 target group. If it does not exist, it defaults to 10.", + }, }, }, }, @@ -269,8 +276,14 @@ func parseParamToRequest(d *schema.ResourceData, param string, id string) (assoc targetGroupAssociation := clb.TargetGroupAssociation{} dMap[param] = id for name := range dMap { - if dMap[name] != nil && dMap[name].(string) != "" { - setString(name, dMap[name].(string), &targetGroupAssociation) + if dMap[name] != nil { + if v, ok := dMap[name].(string); ok && v != "" { + setString(name, v, &targetGroupAssociation) + } + + if v, ok := dMap[name].(int); ok { + setInt(name, v, &targetGroupAssociation) + } } } associations = append(associations, &targetGroupAssociation) @@ -292,6 +305,15 @@ func setString(fieldName string, value string, request *clb.TargetGroupAssociati log.Printf("Invalid field name: %s\n", fieldName) } } + +func setInt(fieldName string, value int, request *clb.TargetGroupAssociation) { + switch fieldName { + case "weight": + request.Weight = helper.IntInt64(value) + default: + log.Printf("Invalid field name: %s\n", fieldName) + } +} func isBindFromClb(id string) bool { re := regexp.MustCompile(`^(.*?)-`) match := re.FindStringSubmatch(id) diff --git a/tencentcloud/services/clb/resource_tc_clb_target_group_instance_attachment.go b/tencentcloud/services/clb/resource_tc_clb_target_group_instance_attachment.go index a01c892579..a967556418 100644 --- a/tencentcloud/services/clb/resource_tc_clb_target_group_instance_attachment.go +++ b/tencentcloud/services/clb/resource_tc_clb_target_group_instance_attachment.go @@ -3,10 +3,11 @@ package clb import ( "context" "fmt" + "log" "strconv" "strings" - "time" + "github.com/pkg/errors" tccommon "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/common" "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper" @@ -29,26 +30,26 @@ func ResourceTencentCloudClbTGAttachmentInstance() *schema.Resource { "target_group_id": { Type: schema.TypeString, Required: true, - ValidateFunc: tccommon.ValidateNotEmpty, ForceNew: true, + ValidateFunc: tccommon.ValidateNotEmpty, Description: "Target group ID.", }, "bind_ip": { Type: schema.TypeString, Required: true, - ValidateFunc: tccommon.ValidateNotEmpty, ForceNew: true, + ValidateFunc: tccommon.ValidateNotEmpty, Description: "The Intranet IP of the target group instance.", }, "port": { Type: schema.TypeInt, - Required: true, + Optional: true, ForceNew: true, - Description: "Port of the target group instance.", + Description: "The port of the target group instance, fully listening to the target group does not support passing this field.", }, "weight": { Type: schema.TypeInt, - Required: true, + Optional: true, Description: "The weight of the target group instance.", }, }, @@ -60,21 +61,58 @@ func resourceTencentCloudClbTGAttachmentInstanceCreate(d *schema.ResourceData, m var ( logId = tccommon.GetLogId(tccommon.ContextNil) - ctx = context.WithValue(context.TODO(), tccommon.LogIdKey, logId) - clbService = ClbService{client: meta.(tccommon.ProviderMeta).GetAPIV3Conn()} - targetGroupId = d.Get("target_group_id").(string) - bindIp = d.Get("bind_ip").(string) - port = d.Get("port").(int) - weight = d.Get("weight").(int) - err error + request = clb.NewRegisterTargetGroupInstancesRequest() + targetGroupId string + bindIp string + port int ) - err = clbService.RegisterTargetInstances(ctx, targetGroupId, bindIp, uint64(port), uint64(weight)) + if v, ok := d.GetOk("target_group_id"); ok { + request.TargetGroupId = helper.String(v.(string)) + targetGroupId = v.(string) + } + + targetGroupInstances := clb.TargetGroupInstance{} + if v, ok := d.GetOk("bind_ip"); ok { + targetGroupInstances.BindIP = helper.String(v.(string)) + bindIp = v.(string) + } + + if v, ok := d.GetOkExists("port"); ok { + targetGroupInstances.Port = helper.IntUint64(v.(int)) + port = v.(int) + } + + if v, ok := d.GetOkExists("weight"); ok { + targetGroupInstances.Weight = helper.IntUint64(v.(int)) + } + + request.TargetGroupInstances = append(request.TargetGroupInstances, &targetGroupInstances) + err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError { + result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseClbClient().RegisterTargetGroupInstances(request) + if e != nil { + return tccommon.RetryError(e) + } else { + log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString()) + } + + if result == nil || result.Response == nil || result.Response.RequestId == nil { + return resource.NonRetryableError(fmt.Errorf("Register target group instance failed, Response is nil.")) + } + + requestId := *result.Response.RequestId + retryErr := waitForTaskFinish(requestId, meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseClbClient()) + if retryErr != nil { + return resource.NonRetryableError(errors.WithStack(retryErr)) + } + + return nil + }) if err != nil { + log.Printf("[CRITAL]%s register target group instance failed, reason:%+v", logId, err) return err } - time.Sleep(time.Duration(3) * time.Second) d.SetId(strings.Join([]string{targetGroupId, bindIp, strconv.Itoa(port)}, tccommon.FILED_SP)) @@ -91,10 +129,12 @@ func resourceTencentCloudClbTGAttachmentInstanceRead(d *schema.ResourceData, met id = d.Id() targetGroupInstances []*clb.TargetGroupBackend ) + idSplit := strings.Split(id, tccommon.FILED_SP) if len(idSplit) != 3 { return fmt.Errorf("target group instance attachment id is not set") } + targetGroupId := idSplit[0] bindIp := idSplit[1] port, err := strconv.ParseUint(idSplit[2], 0, 64) @@ -110,11 +150,14 @@ func resourceTencentCloudClbTGAttachmentInstanceRead(d *schema.ResourceData, met if err != nil { return tccommon.RetryError(err, tccommon.InternalError) } + return nil }) + if err != nil { return err } + for _, tgInstance := range targetGroupInstances { if *tgInstance.Port == port { _ = d.Set("target_group_id", idSplit[0]) @@ -123,9 +166,11 @@ func resourceTencentCloudClbTGAttachmentInstanceRead(d *schema.ResourceData, met if tgInstance.Weight != nil { _ = d.Set("weight", *tgInstance.Weight) } + return nil } } + d.SetId("") return nil } @@ -142,10 +187,12 @@ func resourceTencentCloudClbTGAttachmentInstanceUpdate(d *schema.ResourceData, m bindIp, targetGroupId string err error ) + idSplit := strings.Split(id, tccommon.FILED_SP) if len(idSplit) != 3 { return fmt.Errorf("target group instance attachment id is not set") } + targetGroupId = idSplit[0] bindIp = idSplit[1] port, err = strconv.Atoi(idSplit[2]) @@ -160,6 +207,7 @@ func resourceTencentCloudClbTGAttachmentInstanceUpdate(d *schema.ResourceData, m return err } } + return resourceTencentCloudClbTGAttachmentInstanceRead(d, meta) } @@ -172,10 +220,12 @@ func resourceTencentCloudClbTGAttachmentInstanceDelete(d *schema.ResourceData, m clbService = ClbService{client: meta.(tccommon.ProviderMeta).GetAPIV3Conn()} id = d.Id() ) + idSplit := strings.Split(id, tccommon.FILED_SP) if len(idSplit) != 3 { return fmt.Errorf("target group instance attachment id is not set") } + targetGroupId := idSplit[0] bindIp := idSplit[1] port, err := strconv.ParseUint(idSplit[2], 0, 64) @@ -184,9 +234,9 @@ func resourceTencentCloudClbTGAttachmentInstanceDelete(d *schema.ResourceData, m } err = clbService.DeregisterTargetInstances(ctx, targetGroupId, bindIp, port) - if err != nil { return err } + return nil } diff --git a/tencentcloud/services/clb/service_tencentcloud_clb.go b/tencentcloud/services/clb/service_tencentcloud_clb.go index a48787736d..48e1035ef2 100644 --- a/tencentcloud/services/clb/service_tencentcloud_clb.go +++ b/tencentcloud/services/clb/service_tencentcloud_clb.go @@ -1481,7 +1481,7 @@ func (me *ClbService) AssociateTargetGroups(ctx context.Context, listenerId, clb return } -func (me *ClbService) DescribeAssociateTargetGroups(ctx context.Context, ids []string) (has bool, err error) { +func (me *ClbService) DescribeAssociateTargetGroups(ctx context.Context, ids []string) (targetInfo *clb.TargetGroupInfo, has bool, err error) { var ( logId = tccommon.GetLogId(ctx) targetInfos []*clb.TargetGroupInfo @@ -1511,15 +1511,17 @@ func (me *ClbService) DescribeAssociateTargetGroups(ctx context.Context, ids []s if *rule.Protocol == CLB_LISTENER_PROTOCOL_TCP || *rule.Protocol == CLB_LISTENER_PROTOCOL_UDP || *rule.Protocol == CLB_LISTENER_PROTOCOL_TCPSSL || *rule.Protocol == CLB_LISTENER_PROTOCOL_QUIC { if originListenerId == ids[1] && originClbId == ids[2] { - return true, nil + targetInfo = info + return targetInfo, true, nil } } else if originListenerId == ids[1] && originClbId == ids[2] && originLocationId == ids[3] { - return true, nil + targetInfo = info + return targetInfo, true, nil } } } - return false, nil + return nil, false, nil } func (me *ClbService) DisassociateTargetGroups(ctx context.Context, targetGroupId, listenerId, clbId, locationId string) (errRet error) { diff --git a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb/v20180317/client.go b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb/v20180317/client.go index dc956f4f7d..03f5e346a0 100644 --- a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb/v20180317/client.go +++ b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb/v20180317/client.go @@ -1827,7 +1827,7 @@ func NewDeregisterFunctionTargetsResponse() (response *DeregisterFunctionTargets // // // -// - 仅广州、深圳金融、上海、上海金融、北京、成都、中国香港、新加坡、孟买、东京、硅谷地域支持绑定 SCF。 +// - 仅广州、深圳金融、上海、上海金融、北京、成都、中国香港、新加坡、东京、硅谷地域支持绑定 SCF。 // // - 仅标准账户类型支持绑定 SCF,传统账户类型不支持。建议升级为标准账户类型,详情可参见 [账户类型升级说明](https://cloud.tencent.com/document/product/1199/49090)。 // @@ -1868,7 +1868,7 @@ func (c *Client) DeregisterFunctionTargets(request *DeregisterFunctionTargetsReq // // // -// - 仅广州、深圳金融、上海、上海金融、北京、成都、中国香港、新加坡、孟买、东京、硅谷地域支持绑定 SCF。 +// - 仅广州、深圳金融、上海、上海金融、北京、成都、中国香港、新加坡、东京、硅谷地域支持绑定 SCF。 // // - 仅标准账户类型支持绑定 SCF,传统账户类型不支持。建议升级为标准账户类型,详情可参见 [账户类型升级说明](https://cloud.tencent.com/document/product/1199/49090)。 // @@ -5556,7 +5556,7 @@ func NewRegisterFunctionTargetsResponse() (response *RegisterFunctionTargetsResp // // 限制说明: // -// - 仅广州、深圳金融、上海、上海金融、北京、成都、中国香港、新加坡、孟买、东京、硅谷地域支持绑定 SCF。 +// - 仅广州、深圳金融、上海、上海金融、北京、成都、中国香港、新加坡、东京、硅谷地域支持绑定 SCF。 // // - 仅标准账户类型支持绑定 SCF,传统账户类型不支持。建议升级为标准账户类型,详情可参见 [账户类型升级说明](https://cloud.tencent.com/document/product/1199/49090)。 // @@ -5600,7 +5600,7 @@ func (c *Client) RegisterFunctionTargets(request *RegisterFunctionTargetsRequest // // 限制说明: // -// - 仅广州、深圳金融、上海、上海金融、北京、成都、中国香港、新加坡、孟买、东京、硅谷地域支持绑定 SCF。 +// - 仅广州、深圳金融、上海、上海金融、北京、成都、中国香港、新加坡、东京、硅谷地域支持绑定 SCF。 // // - 仅标准账户类型支持绑定 SCF,传统账户类型不支持。建议升级为标准账户类型,详情可参见 [账户类型升级说明](https://cloud.tencent.com/document/product/1199/49090)。 // diff --git a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb/v20180317/models.go b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb/v20180317/models.go index 7d319a9fbd..5ceb4bf5ac 100644 --- a/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb/v20180317/models.go +++ b/vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb/v20180317/models.go @@ -331,7 +331,7 @@ type Backend struct { // 后端服务的唯一 ID,如 ins-abcd1234 InstanceId *string `json:"InstanceId,omitnil,omitempty" name:"InstanceId"` - // 后端服务的监听端口 + // 后端服务的监听端口,如果是全端口段监听器绑定的全监听目标组场景,此端口返回0,表示无效端口,绑定的后端服务的端口随监听器端口。 Port *int64 `json:"Port,omitnil,omitempty" name:"Port"` // 后端服务的转发权重,取值范围:[0, 100],默认为 10。 @@ -746,6 +746,9 @@ type CertificateInput struct { // 认证类型,UNIDIRECTIONAL:单向认证,MUTUAL:双向认证 SSLMode *string `json:"SSLMode,omitnil,omitempty" name:"SSLMode"` + // 双向认证时,是否开启客户端认证,ON:开启,OPTIONAL:自适应,默认ON。 + SSLVerifyClient *string `json:"SSLVerifyClient,omitnil,omitempty" name:"SSLVerifyClient"` + // 服务端证书的 ID,如果不填写此项则必须上传证书,包括 CertContent,CertKey,CertName。 CertId *string `json:"CertId,omitnil,omitempty" name:"CertId"` @@ -772,6 +775,9 @@ type CertificateOutput struct { // 认证类型,UNIDIRECTIONAL:单向认证,MUTUAL:双向认证 SSLMode *string `json:"SSLMode,omitnil,omitempty" name:"SSLMode"` + // 是否开启客户端证书验证,只在双向认证时生效。 + SSLVerifyClient *string `json:"SSLVerifyClient,omitnil,omitempty" name:"SSLVerifyClient"` + // 服务端证书的ID。 CertId *string `json:"CertId,omitnil,omitempty" name:"CertId"` @@ -1350,12 +1356,8 @@ type CreateListenerRequestParams struct { HealthCheck *HealthCheck `json:"HealthCheck,omitnil,omitempty" name:"HealthCheck"` // 证书相关信息。参数限制如下: - //
  • - // 此参数仅适用于TCP_SSL监听器和未开启SNI特性的HTTPS监听器。 - //
  • - //
  • - // 创建TCP_SSL监听器和未开启SNI特性的HTTPS监听器时,此参数和参数MultiCertInfo至少需要传一个, 但不能同时传入。 - //
  • + //
  • 此参数仅适用于TCP_SSL监听器和未开启SNI特性的HTTPS监听器。
  • + //
  • 创建TCP_SSL监听器和未开启SNI特性的HTTPS监听器时,此参数和参数MultiCertInfo至少需要传一个, 但不能同时传入。
  • Certificate *CertificateInput `json:"Certificate,omitnil,omitempty" name:"Certificate"` // 会话保持时间,单位:秒。可选值:30~3600,默认 0,表示不开启。此参数仅适用于TCP/UDP监听器。 @@ -1384,12 +1386,8 @@ type CreateListenerRequestParams struct { DeregisterTargetRst *bool `json:"DeregisterTargetRst,omitnil,omitempty" name:"DeregisterTargetRst"` // 证书信息,支持同时传入不同算法类型的多本服务端证书,参数限制如下: - //
  • - // 此参数仅适用于TCP_SSL监听器和未开启SNI特性的HTTPS监听器。 - //
  • - //
  • - // 创建TCP_SSL监听器和未开启SNI特性的HTTPS监听器时,此参数和参数Certificate至少需要传一个, 但不能同时传入。 - //
  • + //
  • 此参数仅适用于TCP_SSL监听器和未开启SNI特性的HTTPS监听器。
  • + //
  • 创建TCP_SSL监听器和未开启SNI特性的HTTPS监听器时,此参数和参数Certificate至少需要传一个, 但不能同时传入。
  • MultiCertInfo *MultiCertInfo `json:"MultiCertInfo,omitnil,omitempty" name:"MultiCertInfo"` // 监听器最大连接数,当前仅性能容量型实例且仅TCP/UDP/TCP_SSL/QUIC监听器支持,不传或者传-1表示监听器维度不限速。基础网络实例不支持该参数。 @@ -1412,6 +1410,9 @@ type CreateListenerRequestParams struct { // TCP_SSL监听器支持关闭SSL后仍然支持混绑,此参数为关闭开关 SslCloseSwitch *bool `json:"SslCloseSwitch,omitnil,omitempty" name:"SslCloseSwitch"` + + // 数据压缩模式 + DataCompressMode *string `json:"DataCompressMode,omitnil,omitempty" name:"DataCompressMode"` } type CreateListenerRequest struct { @@ -1433,12 +1434,8 @@ type CreateListenerRequest struct { HealthCheck *HealthCheck `json:"HealthCheck,omitnil,omitempty" name:"HealthCheck"` // 证书相关信息。参数限制如下: - //
  • - // 此参数仅适用于TCP_SSL监听器和未开启SNI特性的HTTPS监听器。 - //
  • - //
  • - // 创建TCP_SSL监听器和未开启SNI特性的HTTPS监听器时,此参数和参数MultiCertInfo至少需要传一个, 但不能同时传入。 - //
  • + //
  • 此参数仅适用于TCP_SSL监听器和未开启SNI特性的HTTPS监听器。
  • + //
  • 创建TCP_SSL监听器和未开启SNI特性的HTTPS监听器时,此参数和参数MultiCertInfo至少需要传一个, 但不能同时传入。
  • Certificate *CertificateInput `json:"Certificate,omitnil,omitempty" name:"Certificate"` // 会话保持时间,单位:秒。可选值:30~3600,默认 0,表示不开启。此参数仅适用于TCP/UDP监听器。 @@ -1467,12 +1464,8 @@ type CreateListenerRequest struct { DeregisterTargetRst *bool `json:"DeregisterTargetRst,omitnil,omitempty" name:"DeregisterTargetRst"` // 证书信息,支持同时传入不同算法类型的多本服务端证书,参数限制如下: - //
  • - // 此参数仅适用于TCP_SSL监听器和未开启SNI特性的HTTPS监听器。 - //
  • - //
  • - // 创建TCP_SSL监听器和未开启SNI特性的HTTPS监听器时,此参数和参数Certificate至少需要传一个, 但不能同时传入。 - //
  • + //
  • 此参数仅适用于TCP_SSL监听器和未开启SNI特性的HTTPS监听器。
  • + //
  • 创建TCP_SSL监听器和未开启SNI特性的HTTPS监听器时,此参数和参数Certificate至少需要传一个, 但不能同时传入。
  • MultiCertInfo *MultiCertInfo `json:"MultiCertInfo,omitnil,omitempty" name:"MultiCertInfo"` // 监听器最大连接数,当前仅性能容量型实例且仅TCP/UDP/TCP_SSL/QUIC监听器支持,不传或者传-1表示监听器维度不限速。基础网络实例不支持该参数。 @@ -1495,6 +1488,9 @@ type CreateListenerRequest struct { // TCP_SSL监听器支持关闭SSL后仍然支持混绑,此参数为关闭开关 SslCloseSwitch *bool `json:"SslCloseSwitch,omitnil,omitempty" name:"SslCloseSwitch"` + + // 数据压缩模式 + DataCompressMode *string `json:"DataCompressMode,omitnil,omitempty" name:"DataCompressMode"` } func (r *CreateListenerRequest) ToJsonString() string { @@ -1531,6 +1527,7 @@ func (r *CreateListenerRequest) FromJsonString(s string) error { delete(f, "FullEndPorts") delete(f, "H2cSwitch") delete(f, "SslCloseSwitch") + delete(f, "DataCompressMode") if len(f) > 0 { return tcerr.NewTencentCloudSDKError("ClientError.BuildRequestError", "CreateListenerRequest has unknown keys!", "") } @@ -1987,15 +1984,18 @@ type CreateTargetGroupRequestParams struct { // 目标组的vpcid属性,不填则使用默认vpc VpcId *string `json:"VpcId,omitnil,omitempty" name:"VpcId"` - // 目标组的默认端口, 后续添加服务器时可使用该默认端口。Port和TargetGroupInstances.N中的port二者必填其一。 + // 目标组的默认端口, 后续添加服务器时可使用该默认端口。全监听目标组不支持此参数,非全监听目标组Port和TargetGroupInstances.N中的port二者必填其一。 Port *uint64 `json:"Port,omitnil,omitempty" name:"Port"` - // 目标组绑定的后端服务器 + // 目标组绑定的后端服务器,单次最多支持50个。 TargetGroupInstances []*TargetGroupInstance `json:"TargetGroupInstances,omitnil,omitempty" name:"TargetGroupInstances"` // 目标组类型,当前支持v1(旧版目标组), v2(新版目标组), 默认为v1(旧版目标组)。 Type *string `json:"Type,omitnil,omitempty" name:"Type"` + // 目标组后端转发协议。v2新版目标组该项必填。目前支持tcp、udp。 + Protocol *string `json:"Protocol,omitnil,omitempty" name:"Protocol"` + // 标签。 Tags []*TagInfo `json:"Tags,omitnil,omitempty" name:"Tags"` @@ -2005,6 +2005,9 @@ type CreateTargetGroupRequestParams struct { //
  • 设置该值后,添加后端服务到目标组时, 若后端服务不单独设置权重, 则使用这里的默认权重。
  • // Weight *uint64 `json:"Weight,omitnil,omitempty" name:"Weight"` + + // 全监听目标组标识,为true表示是全监听目标组,false表示不是全监听目标组。 + FullListenSwitch *bool `json:"FullListenSwitch,omitnil,omitempty" name:"FullListenSwitch"` } type CreateTargetGroupRequest struct { @@ -2016,15 +2019,18 @@ type CreateTargetGroupRequest struct { // 目标组的vpcid属性,不填则使用默认vpc VpcId *string `json:"VpcId,omitnil,omitempty" name:"VpcId"` - // 目标组的默认端口, 后续添加服务器时可使用该默认端口。Port和TargetGroupInstances.N中的port二者必填其一。 + // 目标组的默认端口, 后续添加服务器时可使用该默认端口。全监听目标组不支持此参数,非全监听目标组Port和TargetGroupInstances.N中的port二者必填其一。 Port *uint64 `json:"Port,omitnil,omitempty" name:"Port"` - // 目标组绑定的后端服务器 + // 目标组绑定的后端服务器,单次最多支持50个。 TargetGroupInstances []*TargetGroupInstance `json:"TargetGroupInstances,omitnil,omitempty" name:"TargetGroupInstances"` // 目标组类型,当前支持v1(旧版目标组), v2(新版目标组), 默认为v1(旧版目标组)。 Type *string `json:"Type,omitnil,omitempty" name:"Type"` + // 目标组后端转发协议。v2新版目标组该项必填。目前支持tcp、udp。 + Protocol *string `json:"Protocol,omitnil,omitempty" name:"Protocol"` + // 标签。 Tags []*TagInfo `json:"Tags,omitnil,omitempty" name:"Tags"` @@ -2034,6 +2040,9 @@ type CreateTargetGroupRequest struct { //
  • 设置该值后,添加后端服务到目标组时, 若后端服务不单独设置权重, 则使用这里的默认权重。
  • // Weight *uint64 `json:"Weight,omitnil,omitempty" name:"Weight"` + + // 全监听目标组标识,为true表示是全监听目标组,false表示不是全监听目标组。 + FullListenSwitch *bool `json:"FullListenSwitch,omitnil,omitempty" name:"FullListenSwitch"` } func (r *CreateTargetGroupRequest) ToJsonString() string { @@ -2053,8 +2062,10 @@ func (r *CreateTargetGroupRequest) FromJsonString(s string) error { delete(f, "Port") delete(f, "TargetGroupInstances") delete(f, "Type") + delete(f, "Protocol") delete(f, "Tags") delete(f, "Weight") + delete(f, "FullListenSwitch") if len(f) > 0 { return tcerr.NewTencentCloudSDKError("ClientError.BuildRequestError", "CreateTargetGroupRequest has unknown keys!", "") } @@ -2097,7 +2108,9 @@ type CreateTopicRequestParams struct { // 日志类型,ACCESS:访问日志,HEALTH:健康检查日志,默认ACCESS。 TopicType *string `json:"TopicType,omitnil,omitempty" name:"TopicType"` - // 日志集的保存周期,单位:天,默认30天,范围[1, 3600]。 + // 存储时间,单位天 + // - 日志接入标准存储时,支持1至3600天,值为3640时代表永久保存。 + // - 日志接入低频存储时,支持7至3600天,值为3640时代表永久保存。 Period *uint64 `json:"Period,omitnil,omitempty" name:"Period"` // 日志主题的存储类型,可选值 HOT(标准存储),COLD(低频存储);默认为HOT。 @@ -2116,7 +2129,9 @@ type CreateTopicRequest struct { // 日志类型,ACCESS:访问日志,HEALTH:健康检查日志,默认ACCESS。 TopicType *string `json:"TopicType,omitnil,omitempty" name:"TopicType"` - // 日志集的保存周期,单位:天,默认30天,范围[1, 3600]。 + // 存储时间,单位天 + // - 日志接入标准存储时,支持1至3600天,值为3640时代表永久保存。 + // - 日志接入低频存储时,支持7至3600天,值为3640时代表永久保存。 Period *uint64 `json:"Period,omitnil,omitempty" name:"Period"` // 日志主题的存储类型,可选值 HOT(标准存储),COLD(低频存储);默认为HOT。 @@ -2379,6 +2394,9 @@ func (r *DeleteLoadBalancerListenersResponse) FromJsonString(s string) error { type DeleteLoadBalancerRequestParams struct { // 要删除的负载均衡实例 ID数组,数组大小最大支持20。 LoadBalancerIds []*string `json:"LoadBalancerIds,omitnil,omitempty" name:"LoadBalancerIds"` + + // 是否强制删除clb。为true表示强制删除,为false表示不是强制删除,需要做拦截校验。 + ForceDelete *bool `json:"ForceDelete,omitnil,omitempty" name:"ForceDelete"` } type DeleteLoadBalancerRequest struct { @@ -2386,6 +2404,9 @@ type DeleteLoadBalancerRequest struct { // 要删除的负载均衡实例 ID数组,数组大小最大支持20。 LoadBalancerIds []*string `json:"LoadBalancerIds,omitnil,omitempty" name:"LoadBalancerIds"` + + // 是否强制删除clb。为true表示强制删除,为false表示不是强制删除,需要做拦截校验。 + ForceDelete *bool `json:"ForceDelete,omitnil,omitempty" name:"ForceDelete"` } func (r *DeleteLoadBalancerRequest) ToJsonString() string { @@ -2401,6 +2422,7 @@ func (r *DeleteLoadBalancerRequest) FromJsonString(s string) error { return err } delete(f, "LoadBalancerIds") + delete(f, "ForceDelete") if len(f) > 0 { return tcerr.NewTencentCloudSDKError("ClientError.BuildRequestError", "DeleteLoadBalancerRequest has unknown keys!", "") } @@ -5840,7 +5862,7 @@ func (r *InquiryPriceRenewLoadBalancerResponse) FromJsonString(s string) error { } type InternetAccessible struct { - // TRAFFIC_POSTPAID_BY_HOUR 按流量按小时后计费 ; BANDWIDTH_POSTPAID_BY_HOUR 按带宽按小时后计费; BANDWIDTH_PACKAGE 按带宽包计费;BANDWIDTH_PREPAID按带宽预付费。 + // TRAFFIC_POSTPAID_BY_HOUR 按流量按小时后计费 ; BANDWIDTH_POSTPAID_BY_HOUR 按带宽按小时后计费,国际站用户不支持该计费模式; BANDWIDTH_PACKAGE 按带宽包计费;BANDWIDTH_PREPAID按带宽预付费。 // 注意:此字段可能返回 null,表示取不到有效值。 InternetChargeType *string `json:"InternetChargeType,omitnil,omitempty" name:"InternetChargeType"` @@ -6183,7 +6205,12 @@ type LoadBalancer struct { // 注意:此字段可能返回 null,表示取不到有效值。 NumericalVpcId *uint64 `json:"NumericalVpcId,omitnil,omitempty" name:"NumericalVpcId"` - // 负载均衡IP地址所属的运营商。取值范围(BGP、CMCC、CTCC、CUCC) + // 负载均衡IP地址所属的运营商。 + // + // - BGP : BGP(多线) + // - CMCC:中国移动单线 + // - CTCC:中国电信单线 + // - CUCC:中国联通单线 // 注意:此字段可能返回 null,表示取不到有效值。 VipIsp *string `json:"VipIsp,omitnil,omitempty" name:"VipIsp"` @@ -6331,7 +6358,7 @@ type LoadBalancerDetail struct { LoadBalancerName *string `json:"LoadBalancerName,omitnil,omitempty" name:"LoadBalancerName"` // 负载均衡实例的网络类型: - // OPEN:公网属性,INTERNAL:内网属性;对于内网属性的负载均衡,可通过绑定EIP出公网,具体可参考EIP文档。 + // Public:公网属性,Private:内网属性;对于内网属性的负载均衡,可通过绑定EIP出公网,具体可参考EIP文档。 // 注意:此字段可能返回 null,表示取不到有效值。 LoadBalancerType *string `json:"LoadBalancerType,omitnil,omitempty" name:"LoadBalancerType"` @@ -7407,7 +7434,7 @@ func (r *ModifyLoadBalancerAttributesResponse) FromJsonString(s string) error { // Predefined struct for user type ModifyLoadBalancerMixIpTargetRequestParams struct { - // 负载均衡实例ID数组。 + // 负载均衡实例ID数组,默认支持20个负载均衡实例ID。 LoadBalancerIds []*string `json:"LoadBalancerIds,omitnil,omitempty" name:"LoadBalancerIds"` // 开启/关闭IPv6FullChain负载均衡7层监听器支持混绑IPv4/IPv6目标特性。 @@ -7417,7 +7444,7 @@ type ModifyLoadBalancerMixIpTargetRequestParams struct { type ModifyLoadBalancerMixIpTargetRequest struct { *tchttp.BaseRequest - // 负载均衡实例ID数组。 + // 负载均衡实例ID数组,默认支持20个负载均衡实例ID。 LoadBalancerIds []*string `json:"LoadBalancerIds,omitnil,omitempty" name:"LoadBalancerIds"` // 开启/关闭IPv6FullChain负载均衡7层监听器支持混绑IPv4/IPv6目标特性。 @@ -7722,7 +7749,7 @@ type ModifyTargetGroupAttributeRequestParams struct { // 目标组的新名称。 TargetGroupName *string `json:"TargetGroupName,omitnil,omitempty" name:"TargetGroupName"` - // 目标组的新默认端口。 + // 目标组的新默认端口。全监听目标组不支持此参数。 Port *uint64 `json:"Port,omitnil,omitempty" name:"Port"` // 后端服务默认权重。 @@ -7742,7 +7769,7 @@ type ModifyTargetGroupAttributeRequest struct { // 目标组的新名称。 TargetGroupName *string `json:"TargetGroupName,omitnil,omitempty" name:"TargetGroupName"` - // 目标组的新默认端口。 + // 目标组的新默认端口。全监听目标组不支持此参数。 Port *uint64 `json:"Port,omitnil,omitempty" name:"Port"` // 后端服务默认权重。 @@ -8117,6 +8144,9 @@ type MultiCertInfo struct { // 监听器或规则证书列表,单双向认证,多本服务端证书算法类型不能重复;若SSLMode为双向认证,证书列表必须包含一本ca证书。 CertList []*CertInfo `json:"CertList,omitnil,omitempty" name:"CertList"` + + // 双向认证时,是否开启客户端认证,ON:开启,OPTIONAL:自适应,默认ON + SSLVerifyClient *string `json:"SSLVerifyClient,omitnil,omitempty" name:"SSLVerifyClient"` } type OAuth struct { @@ -8568,13 +8598,11 @@ type RewriteLocationMap struct { } type RewriteTarget struct { - // 重定向目标的监听器ID - // 注意:此字段可能返回 null,表示无重定向。 + // 重定向目标的监听器ID,该字段仅配置了重定向时有效。 // 注意:此字段可能返回 null,表示取不到有效值。 TargetListenerId *string `json:"TargetListenerId,omitnil,omitempty" name:"TargetListenerId"` - // 重定向目标的转发规则ID - // 注意:此字段可能返回 null,表示无重定向。 + // 重定向目标的转发规则ID,该字段仅配置了重定向时有效。 // 注意:此字段可能返回 null,表示取不到有效值。 TargetLocationId *string `json:"TargetLocationId,omitnil,omitempty" name:"TargetLocationId"` @@ -8917,12 +8945,12 @@ type SetLoadBalancerClsLogRequestParams struct { // 日志服务(CLS)的日志集 ID。 //
  • 增加和更新日志主题时可调用 [DescribeLogsets](https://cloud.tencent.com/document/product/614/58624) 接口获取日志集 ID。
  • - //
  • 删除日志主题时,此参数填写为null即可。
  • + //
  • 删除日志主题时,此参数填写为**空字符串**即可。
  • LogSetId *string `json:"LogSetId,omitnil,omitempty" name:"LogSetId"` // 日志服务(CLS)的日志主题 ID。 //
  • 增加和更新日志主题时可调用 [DescribeTopics](https://cloud.tencent.com/document/product/614/56454) 接口获取日志主题 ID。
  • - //
  • 删除日志主题时,此参数填写为null即可。
  • + //
  • 删除日志主题时,此参数填写为**空字符串**即可。
  • LogTopicId *string `json:"LogTopicId,omitnil,omitempty" name:"LogTopicId"` // 日志类型: @@ -8940,12 +8968,12 @@ type SetLoadBalancerClsLogRequest struct { // 日志服务(CLS)的日志集 ID。 //
  • 增加和更新日志主题时可调用 [DescribeLogsets](https://cloud.tencent.com/document/product/614/58624) 接口获取日志集 ID。
  • - //
  • 删除日志主题时,此参数填写为null即可。
  • + //
  • 删除日志主题时,此参数填写为**空字符串**即可。
  • LogSetId *string `json:"LogSetId,omitnil,omitempty" name:"LogSetId"` // 日志服务(CLS)的日志主题 ID。 //
  • 增加和更新日志主题时可调用 [DescribeTopics](https://cloud.tencent.com/document/product/614/56454) 接口获取日志主题 ID。
  • - //
  • 删除日志主题时,此参数填写为null即可。
  • + //
  • 删除日志主题时,此参数填写为**空字符串**即可。
  • LogTopicId *string `json:"LogTopicId,omitnil,omitempty" name:"LogTopicId"` // 日志类型: @@ -9297,7 +9325,7 @@ type TargetGroupBackend struct { // 后端服务的唯一 ID InstanceId *string `json:"InstanceId,omitnil,omitempty" name:"InstanceId"` - // 后端服务的监听端口 + // 后端服务的监听端口,全端口段监听器此字段返回0,代表无效端口,即不支持设置。 Port *uint64 `json:"Port,omitnil,omitempty" name:"Port"` // 后端服务的转发权重,取值范围:[0, 100],默认为 10。 @@ -9338,7 +9366,7 @@ type TargetGroupInfo struct { // 目标组的名字 TargetGroupName *string `json:"TargetGroupName,omitnil,omitempty" name:"TargetGroupName"` - // 目标组的默认端口 + // 目标组的默认端口,全监听目标组此字段返回0,表示无效端口。 // 注意:此字段可能返回 null,表示取不到有效值。 Port *uint64 `json:"Port,omitnil,omitempty" name:"Port"` @@ -9370,19 +9398,24 @@ type TargetGroupInfo struct { // 默认权重。只有v2类型目标组返回该字段。当返回为NULL时, 表示未设置默认权重。 // 注意:此字段可能返回 null,表示取不到有效值。 Weight *uint64 `json:"Weight,omitnil,omitempty" name:"Weight"` + + // 是否全监听目标组 + FullListenSwitch *bool `json:"FullListenSwitch,omitnil,omitempty" name:"FullListenSwitch"` } type TargetGroupInstance struct { // 目标组实例的内网IP BindIP *string `json:"BindIP,omitnil,omitempty" name:"BindIP"` - // 目标组实例的端口 + // 目标组实例的端口,全监听目标组不支持传此字段。 Port *uint64 `json:"Port,omitnil,omitempty" name:"Port"` // 目标组实例的权重 + // + // v2目标组需要配置权重,调用CreateTargetGroup接口创建目标组时该参数与创建接口中的Weight参数必填其一。 Weight *uint64 `json:"Weight,omitnil,omitempty" name:"Weight"` - // 目标组实例的新端口 + // 目标组实例的新端口,全监听目标组不支持传此字段。 NewPort *uint64 `json:"NewPort,omitnil,omitempty" name:"NewPort"` } 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 e608e71db1..0200299573 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.1130" + params["RequestClient"] = "SDK_GO_1.0.1132" if requestClient != "" { params["RequestClient"] += ": " + requestClient } diff --git a/vendor/modules.txt b/vendor/modules.txt index 58e7360a42..2e57c611e1 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1157,7 +1157,7 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ciam/v20220331 # github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ckafka v1.0.1073 ## explicit; go 1.14 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ckafka/v20190819 -# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb v1.0.1107 +# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb v1.0.1132 ## explicit; go 1.14 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb/v20180317 # github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cloudaudit v1.0.1033 @@ -1166,7 +1166,7 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cloudaudit/v20190319 # github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls v1.0.1078 ## explicit; go 1.14 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls/v20201016 -# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1130 +# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1132 ## 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_listener.html.markdown b/website/docs/r/clb_listener.html.markdown index ee908076fc..e42005a6df 100644 --- a/website/docs/r/clb_listener.html.markdown +++ b/website/docs/r/clb_listener.html.markdown @@ -201,6 +201,7 @@ The following arguments are supported: * `certificate_id` - (Optional, String) ID of the server certificate. NOTES: Only supports listeners of `HTTPS` and `TCP_SSL` protocol and must be set when it is available. * `certificate_ssl_mode` - (Optional, String) Type of certificate. Valid values: `UNIDIRECTIONAL`, `MUTUAL`. NOTES: Only supports listeners of `HTTPS` and `TCP_SSL` protocol and must be set when it is available. * `end_port` - (Optional, Int, ForceNew) This parameter is used to specify the end port and is required when creating a port range listener. Only one member can be passed in when inputting the `Ports` parameter, which is used to specify the start port. If you want to try the port range feature, please [submit a ticket](https://console.cloud.tencent.com/workorder/category). +* `full_end_ports` - (Optional, List: [`Int`]) End port of the full port segment listener. * `h2c_switch` - (Optional, Bool, ForceNew) Enable H2C switch for intranet HTTP listener. * `health_check_context_type` - (Optional, String) Health check protocol. When the value of `health_check_type` of the health check protocol is `CUSTOM`, this field is required, which represents the input format of the health check. Valid values: `HEX`, `TEXT`. * `health_check_health_num` - (Optional, Int) Health threshold of health check, and the default is `3`. If a success result is returned for the health check for 3 consecutive times, the backend CVM is identified as healthy. The value range is 2-10. NOTES: TCP/UDP/TCP_SSL listener allows direct configuration, HTTP/HTTPS listener needs to be configured in tencentcloud_clb_listener_rule. diff --git a/website/docs/r/clb_target_group.html.markdown b/website/docs/r/clb_target_group.html.markdown index 3e4922ad7e..7d1df86ce5 100644 --- a/website/docs/r/clb_target_group.html.markdown +++ b/website/docs/r/clb_target_group.html.markdown @@ -13,10 +13,55 @@ Provides a resource to create a CLB target group. ## Example Usage +### If type is v1 + ```hcl -resource "tencentcloud_clb_target_group" "test" { - target_group_name = "test" - port = 33 +resource "tencentcloud_clb_target_group" "example" { + target_group_name = "tf-example" + vpc_id = "vpc-jy6pwoy2" + port = 8090 + type = "v1" + + tags { + tag_key = "tagKey" + tag_value = "tagValue" + } +} +``` + +### If type is v2 + +```hcl +resource "tencentcloud_clb_target_group" "example" { + target_group_name = "tf-example" + vpc_id = "vpc-jy6pwoy2" + port = 8090 + type = "v2" + protocol = "TCP" + weight = 60 + + tags { + tag_key = "tagKey" + tag_value = "tagValue" + } +} +``` + +### Or full_listen_switch is true + +```hcl +resource "tencentcloud_clb_target_group" "example" { + target_group_name = "tf-example" + vpc_id = "vpc-jy6pwoy2" + type = "v2" + protocol = "TCP" + weight = 60 + full_listen_switch = true + + tags { + tag_key = "tagKey" + tag_value = "tagValue" + } } ``` @@ -24,10 +69,20 @@ resource "tencentcloud_clb_target_group" "test" { The following arguments are supported: -* `port` - (Optional, Int) The default port of target group, add server after can use it. +* `full_listen_switch` - (Optional, Bool) Full listening target group identifier, true indicates full listening target group, false indicates not full listening target group. +* `port` - (Optional, Int) The default port of target group, add server after can use it. If `full_listen_switch` is true, setting this parameter is not supported. +* `protocol` - (Optional, String) Target group backend forwarding protocol. This item is required for the v2 new version target group. Currently supports `TCP`, `UDP`. +* `tags` - (Optional, List) Label. * `target_group_instances` - (Optional, List, **Deprecated**) It has been deprecated from version 1.77.3. please use `tencentcloud_clb_target_group_instance_attachment` instead. The backend server of target group bind. * `target_group_name` - (Optional, String) Target group name. +* `type` - (Optional, String) Target group type, currently supports v1 (old version target group), v2 (new version target group), defaults to v1 (old version target group). * `vpc_id` - (Optional, String, ForceNew) VPC ID, default is based on the network. +* `weight` - (Optional, Int) Default weights for backend services. Value range [0, 100]. After setting this value, when adding backend services to the target group, if the backend services do not have separate weights set, the default weights here will be used. + +The `tags` object supports the following: + +* `tag_key` - (Required, String) Tag key. +* `tag_value` - (Required, String) Tag value. The `target_group_instances` object supports the following: @@ -49,6 +104,6 @@ In addition to all arguments above, the following attributes are exported: CLB target group can be imported using the id, e.g. ``` -$ terraform import tencentcloud_clb_target_group.test lbtg-3k3io0i0 +$ terraform import tencentcloud_clb_target_group.example lbtg-3k3io0i0 ``` diff --git a/website/docs/r/clb_target_group_attachment.html.markdown b/website/docs/r/clb_target_group_attachment.html.markdown index a5725ae0d5..d9de0d02e4 100644 --- a/website/docs/r/clb_target_group_attachment.html.markdown +++ b/website/docs/r/clb_target_group_attachment.html.markdown @@ -83,6 +83,7 @@ The following arguments are supported: * `target_group_id` - (Required, String, ForceNew) ID of the CLB target group. * `listener_id` - (Optional, String, ForceNew) ID of the CLB listener. * `rule_id` - (Optional, String, ForceNew) ID of the CLB listener rule. +* `weight` - (Optional, Int, ForceNew) Target group weight, range [0, 100]. It only takes effect when binding to the v2 target group. If it does not exist, it defaults to 10. ## Attributes Reference diff --git a/website/docs/r/clb_target_group_attachments.html.markdown b/website/docs/r/clb_target_group_attachments.html.markdown index 1a96726de8..ca6d89744e 100644 --- a/website/docs/r/clb_target_group_attachments.html.markdown +++ b/website/docs/r/clb_target_group_attachments.html.markdown @@ -55,6 +55,7 @@ The `associations` object supports the following: * `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. +* `weight` - (Optional, Int, ForceNew) Target group weight, range [0, 100]. It only takes effect when binding to the v2 target group. If it does not exist, it defaults to 10. ## Attributes Reference diff --git a/website/docs/r/clb_target_group_instance_attachment.html.markdown b/website/docs/r/clb_target_group_instance_attachment.html.markdown index a01155dbbd..54372a2148 100644 --- a/website/docs/r/clb_target_group_instance_attachment.html.markdown +++ b/website/docs/r/clb_target_group_instance_attachment.html.markdown @@ -88,9 +88,9 @@ resource "tencentcloud_clb_target_group_instance_attachment" "example" { The following arguments are supported: * `bind_ip` - (Required, String, ForceNew) The Intranet IP of the target group instance. -* `port` - (Required, Int, ForceNew) Port of the target group instance. * `target_group_id` - (Required, String, ForceNew) Target group ID. -* `weight` - (Required, Int) The weight of the target group instance. +* `port` - (Optional, Int, ForceNew) The port of the target group instance, fully listening to the target group does not support passing this field. +* `weight` - (Optional, Int) The weight of the target group instance. ## Attributes Reference