diff --git a/.changelog/2816.txt b/.changelog/2816.txt new file mode 100644 index 0000000000..46fcef7da4 --- /dev/null +++ b/.changelog/2816.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/tencentcloud_gaap_layer4_listener: support udp listener enable `health_check` +``` diff --git a/tencentcloud/services/gaap/resource_tc_gaap_layer4_listener.go b/tencentcloud/services/gaap/resource_tc_gaap_layer4_listener.go index 98dff02ee1..3fa33bda8c 100644 --- a/tencentcloud/services/gaap/resource_tc_gaap_layer4_listener.go +++ b/tencentcloud/services/gaap/resource_tc_gaap_layer4_listener.go @@ -67,14 +67,14 @@ func ResourceTencentCloudGaapLayer4Listener() *schema.Resource { Type: schema.TypeBool, Optional: true, Default: false, - Description: "Indicates whether health check is enable, default value is `false`. NOTES: Only supports listeners of `TCP` protocol.", + Description: "Indicates whether health check is enable, default value is `false`.", }, "interval": { Type: schema.TypeInt, Optional: true, Default: 5, ValidateFunc: tccommon.ValidateIntegerInRange(5, 300), - Description: "Interval of the health check, default value is 5s. NOTES: Only supports listeners of `TCP` protocol.", + Description: "Interval of the health check, default value is 5s.", }, "connect_timeout": { Type: schema.TypeInt, @@ -83,6 +83,52 @@ func ResourceTencentCloudGaapLayer4Listener() *schema.Resource { ValidateFunc: tccommon.ValidateIntegerInRange(2, 60), Description: "Timeout of the health check response, should less than interval, default value is 2s. NOTES: Only supports listeners of `TCP` protocol and require less than `interval`.", }, + "healthy_threshold": { + Type: schema.TypeInt, + Optional: true, + Default: 1, + ValidateFunc: tccommon.ValidateIntegerInRange(1, 10), + Description: "Health threshold, which indicates how many consecutive inspections are successful, the source station is determined to be healthy. Range from 1 to 10. Default value is 1.", + }, + "unhealthy_threshold": { + Type: schema.TypeInt, + Optional: true, + Default: 1, + ValidateFunc: tccommon.ValidateIntegerInRange(1, 10), + Description: "Unhealthy threshold, which indicates how many consecutive check failures the source station is considered unhealthy. Range from 1 to 10. Default value is 1.", + }, + "check_type": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ValidateFunc: tccommon.ValidateAllowedStringValue([]string{"PORT", "PING"}), + Description: "UDP origin server health type. PORT means check port, and PING means PING.", + }, + "check_port": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "UDP origin station health check probe port.", + }, + "context_type": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ValidateFunc: tccommon.ValidateAllowedStringValue([]string{"TEXT"}), + Description: "UDP source station health check port probe message type: TEXT represents text. Only used when the health check type is PORT.", + }, + "send_context": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "UDP source server health check port detection sends messages. Only used when health check type is PORT.", + }, + "recv_context": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "UDP source server health check port detects received messages. Only used when the health check type is PORT.", + }, "client_ip_method": { Type: schema.TypeInt, Optional: true, @@ -164,12 +210,10 @@ func resourceTencentCloudGaapLayer4ListenerCreate(d *schema.ResourceData, m inte proxyId := d.Get("proxy_id").(string) healthCheck := d.Get("health_check").(bool) - if protocol == "UDP" && healthCheck { - return errors.New("UDP listener can't use health check") - } - interval := d.Get("interval").(int) connectTimeout := d.Get("connect_timeout").(int) + healthyThreshold := d.Get("healthy_threshold").(int) + unhealthyThreshold := d.Get("unhealthy_threshold").(int) // only check for TCP listener if protocol == "TCP" && connectTimeout >= interval { @@ -206,13 +250,33 @@ func resourceTencentCloudGaapLayer4ListenerCreate(d *schema.ResourceData, m inte switch protocol { case "TCP": - id, err = service.CreateTCPListener(ctx, name, scheduler, realserverType, proxyId, port, interval, connectTimeout, clientIPMethod, healthCheck) + id, err = service.CreateTCPListener(ctx, name, scheduler, realserverType, proxyId, port, interval, connectTimeout, clientIPMethod, healthyThreshold, unhealthyThreshold, healthCheck) if err != nil { return err } case "UDP": - id, err = service.CreateUDPListener(ctx, name, scheduler, realserverType, proxyId, port) + optionalParams := make(map[string]interface{}) + if v, ok := d.GetOk("check_type"); ok { + optionalParams["check_type"] = v.(string) + } else { + if healthCheck { + return errors.New("Must set check_type when enable health_check.") + } + } + if v, ok := d.GetOk("check_port"); ok { + optionalParams["check_port"] = v.(int) + } + if v, ok := d.GetOk("context_type"); ok { + optionalParams["context_type"] = v.(string) + } + if v, ok := d.GetOk("send_context"); ok { + optionalParams["send_context"] = v.(string) + } + if v, ok := d.GetOk("recv_context"); ok { + optionalParams["recv_context"] = v.(string) + } + id, err = service.CreateUDPListener(ctx, name, scheduler, realserverType, proxyId, port, interval, connectTimeout, healthyThreshold, unhealthyThreshold, healthCheck, optionalParams) if err != nil { return err } @@ -239,19 +303,26 @@ func resourceTencentCloudGaapLayer4ListenerRead(d *schema.ResourceData, m interf id := d.Id() var ( - protocol string - name *string - port *uint64 - scheduler *string - realServerType *string - healthCheck *bool - interval *uint64 - connectTimeout *uint64 - status *uint64 - createTime string - realservers []map[string]interface{} - clientIpMethod *uint64 - proxyId *string + protocol string + name *string + port *uint64 + scheduler *string + realServerType *string + healthCheck *bool + interval *uint64 + connectTimeout *uint64 + status *uint64 + createTime string + realservers []map[string]interface{} + clientIpMethod *uint64 + proxyId *string + healthyThreshold *uint64 + unhealthyThreshold *uint64 + checkType *string + checkPort *int64 + contextType *string + sendContext *string + recvContext *string ) service := GaapService{client: m.(tccommon.ProviderMeta).GetAPIV3Conn()} @@ -285,6 +356,8 @@ func resourceTencentCloudGaapLayer4ListenerRead(d *schema.ResourceData, m interf interval = listener.DelayLoop connectTimeout = listener.ConnectTimeout + healthyThreshold = listener.HealthyThreshold + unhealthyThreshold = listener.UnhealthyThreshold if len(listener.RealServerSet) > 0 { realservers = make([]map[string]interface{}, 0, len(listener.RealServerSet)) @@ -316,11 +389,16 @@ func resourceTencentCloudGaapLayer4ListenerRead(d *schema.ResourceData, m interf realServerType = listener.RealServerType proxyId = listener.ProxyId - healthCheck = helper.Bool(false) - connectTimeout = helper.IntUint64(2) - interval = helper.IntUint64(5) - clientIpMethod = helper.IntUint64(0) - + healthCheck = helper.Bool(*listener.HealthCheck == 1) + connectTimeout = listener.ConnectTimeout + interval = listener.DelayLoop + healthyThreshold = listener.HealthyThreshold + unhealthyThreshold = listener.UnhealthyThreshold + checkType = listener.CheckType + checkPort = listener.CheckPort + contextType = listener.ContextType + sendContext = listener.SendContext + recvContext = listener.RecvContext if len(listener.RealServerSet) > 0 { realservers = make([]map[string]interface{}, 0, len(listener.RealServerSet)) for _, rs := range listener.RealServerSet { @@ -353,12 +431,22 @@ func resourceTencentCloudGaapLayer4ListenerRead(d *schema.ResourceData, m interf _ = d.Set("health_check", healthCheck) _ = d.Set("interval", interval) _ = d.Set("connect_timeout", connectTimeout) - _ = d.Set("client_ip_method", clientIpMethod) _ = d.Set("realserver_bind_set", realservers) _ = d.Set("status", status) _ = d.Set("create_time", createTime) _ = d.Set("proxy_id", proxyId) - + _ = d.Set("healthy_threshold", healthyThreshold) + _ = d.Set("unhealthy_threshold", unhealthyThreshold) + if protocol == "TCP" { + _ = d.Set("client_ip_method", clientIpMethod) + } + if protocol == "UDP" { + _ = d.Set("check_type", checkType) + _ = d.Set("check_port", checkPort) + _ = d.Set("context_type", contextType) + _ = d.Set("send_context", sendContext) + _ = d.Set("recv_context", recvContext) + } return nil } @@ -374,12 +462,14 @@ func resourceTencentCloudGaapLayer4ListenerUpdate(d *schema.ResourceData, m inte protocol := d.Get("protocol").(string) proxyId := d.Get("proxy_id").(string) var ( - name *string - scheduler *string - healthCheck *bool - interval int - connectTimeout int - attrChange []string + name *string + scheduler *string + healthCheck *bool + interval int + connectTimeout int + attrChange []string + healthyThreshold int + unhealthyThreshold int ) service := GaapService{client: m.(tccommon.ProviderMeta).GetAPIV3Conn()} @@ -388,21 +478,18 @@ func resourceTencentCloudGaapLayer4ListenerUpdate(d *schema.ResourceData, m inte if d.HasChange("name") { attrChange = append(attrChange, "name") - name = helper.String(d.Get("name").(string)) } + name = helper.String(d.Get("name").(string)) if d.HasChange("scheduler") { attrChange = append(attrChange, "scheduler") - scheduler = helper.String(d.Get("scheduler").(string)) } + scheduler = helper.String(d.Get("scheduler").(string)) if d.HasChange("health_check") { attrChange = append(attrChange, "health_check") - healthCheck = helper.Bool(d.Get("health_check").(bool)) - } - if protocol == "UDP" && healthCheck != nil && *healthCheck { - return errors.New("UDP listener can't enable health check") } + healthCheck = helper.Bool(d.Get("health_check").(bool)) if d.HasChange("interval") { attrChange = append(attrChange, "interval") @@ -414,6 +501,47 @@ func resourceTencentCloudGaapLayer4ListenerUpdate(d *schema.ResourceData, m inte } connectTimeout = d.Get("connect_timeout").(int) + if d.HasChange("healthy_threshold") { + attrChange = append(attrChange, "healthy_threshold") + } + healthyThreshold = d.Get("healthy_threshold").(int) + + if d.HasChange("unhealthy_threshold") { + attrChange = append(attrChange, "unhealthy_threshold") + } + unhealthyThreshold = d.Get("unhealthy_threshold").(int) + + optionalParams := make(map[string]interface{}) + if d.HasChange("check_type") { + attrChange = append(attrChange, "check_type") + } + if d.HasChange("check_port") { + attrChange = append(attrChange, "check_port") + } + if d.HasChange("context_type") { + attrChange = append(attrChange, "context_type") + } + if d.HasChange("send_context") { + attrChange = append(attrChange, "send_context") + } + if d.HasChange("recv_context") { + attrChange = append(attrChange, "recv_context") + } + if v, ok := d.GetOk("check_type"); ok { + optionalParams["check_type"] = v.(string) + } + if v, ok := d.GetOk("check_port"); ok { + optionalParams["check_port"] = v.(int) + } + if v, ok := d.GetOk("context_type"); ok { + optionalParams["context_type"] = v.(string) + } + if v, ok := d.GetOk("send_context"); ok { + optionalParams["send_context"] = v.(string) + } + if v, ok := d.GetOk("recv_context"); ok { + optionalParams["recv_context"] = v.(string) + } // only check for TCP listener if protocol == "TCP" && connectTimeout >= interval { return errors.New("connect_timeout must be less than interval") @@ -422,12 +550,12 @@ func resourceTencentCloudGaapLayer4ListenerUpdate(d *schema.ResourceData, m inte if len(attrChange) > 0 { switch protocol { case "TCP": - if err := service.ModifyTCPListenerAttribute(ctx, proxyId, id, name, scheduler, healthCheck, interval, connectTimeout); err != nil { + if err := service.ModifyTCPListenerAttribute(ctx, proxyId, id, name, scheduler, healthCheck, interval, connectTimeout, healthyThreshold, unhealthyThreshold); err != nil { return err } case "UDP": - if err := service.ModifyUDPListenerAttribute(ctx, proxyId, id, name, scheduler); err != nil { + if err := service.ModifyUDPListenerAttribute(ctx, proxyId, id, name, scheduler, connectTimeout, interval, healthyThreshold, unhealthyThreshold, healthCheck, optionalParams); err != nil { return err } } diff --git a/tencentcloud/services/gaap/resource_tc_gaap_layer4_listener_test.go b/tencentcloud/services/gaap/resource_tc_gaap_layer4_listener_test.go index f5c5912efb..b37273ede4 100644 --- a/tencentcloud/services/gaap/resource_tc_gaap_layer4_listener_test.go +++ b/tencentcloud/services/gaap/resource_tc_gaap_layer4_listener_test.go @@ -240,9 +240,63 @@ func TestAccTencentCloudGaapLayer4Listener_udp_basic(t *testing.T) { ), }, { - ResourceName: "tencentcloud_gaap_layer4_listener.foo", - ImportState: true, - ImportStateVerify: true, + ResourceName: "tencentcloud_gaap_layer4_listener.foo", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"client_ip_method"}, + }, + }, + }) +} + +func TestAccTencentCloudGaapLayer4Listener_udpHealthCheck(t *testing.T) { + t.Parallel() + id := new(string) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { tcacctest.AccPreCheckCommon(t, tcacctest.ACCOUNT_TYPE_PREPAY) }, + Providers: tcacctest.AccProviders, + CheckDestroy: testAccCheckGaapLayer4ListenerDestroy(id, "UDP"), + Steps: []resource.TestStep{ + { + Config: testAccGaapLayer4ListenerUdpHealthCheckUpdatePing, + Check: resource.ComposeTestCheckFunc( + testAccCheckGaapLayer4ListenerExists("tencentcloud_gaap_layer4_listener.foo", id, "UDP"), + resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "protocol", "UDP"), + resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "name", "layer4-udp-listener-hc"), + resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "port", "9093"), + resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "scheduler", "rr"), + resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "realserver_type", "IP"), + resource.TestCheckResourceAttrSet("tencentcloud_gaap_layer4_listener.foo", "proxy_id"), + resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "health_check", "true"), + resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "realserver_bind_set.#", "2"), + resource.TestCheckResourceAttrSet("tencentcloud_gaap_layer4_listener.foo", "status"), + resource.TestCheckResourceAttrSet("tencentcloud_gaap_layer4_listener.foo", "create_time"), + resource.TestCheckResourceAttrSet("tencentcloud_gaap_layer4_listener.foo", "proxy_id"), + resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "check_type", "PING"), + ), + }, + { + Config: testAccGaapLayer4ListenerUdpHealthCheckUpdatePort, + Check: resource.ComposeTestCheckFunc( + testAccCheckGaapLayer4ListenerExists("tencentcloud_gaap_layer4_listener.foo", id, "UDP"), + resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "protocol", "UDP"), + resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "name", "layer4-udp-listener-hc"), + resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "port", "9093"), + resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "scheduler", "rr"), + resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "realserver_type", "IP"), + resource.TestCheckResourceAttrSet("tencentcloud_gaap_layer4_listener.foo", "proxy_id"), + resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "health_check", "true"), + resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "realserver_bind_set.#", "2"), + resource.TestCheckResourceAttrSet("tencentcloud_gaap_layer4_listener.foo", "status"), + resource.TestCheckResourceAttrSet("tencentcloud_gaap_layer4_listener.foo", "create_time"), + resource.TestCheckResourceAttrSet("tencentcloud_gaap_layer4_listener.foo", "proxy_id"), + resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "check_type", "PORT"), + resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "check_port", "6666"), + resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "context_type", "TEXT"), + resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "send_context", "111"), + resource.TestCheckResourceAttr("tencentcloud_gaap_layer4_listener.foo", "recv_context", "222"), + ), }, }, }) @@ -562,6 +616,58 @@ resource tencentcloud_gaap_layer4_listener "foo" { } `, tcacctest.DefaultGaapProxyId, tcacctest.DefaultGaapRealserverIpId1, tcacctest.DefaultGaapRealserverIp1, tcacctest.DefaultGaapRealserverIpId2, tcacctest.DefaultGaapRealserverIp2) +var testAccGaapLayer4ListenerUdpHealthCheckUpdatePort = fmt.Sprintf(` +resource tencentcloud_gaap_layer4_listener "foo" { + protocol = "UDP" + name = "layer4-udp-listener-hc" + port = 9093 + realserver_type = "IP" + proxy_id = "%s" + + realserver_bind_set { + id = "%s" + ip = "%s" + port = 80 + } + + realserver_bind_set { + id = "%s" + ip = "%s" + port = 80 + } + health_check = true + check_type = "PORT" + check_port = "6666" + context_type = "TEXT" + send_context = "111" + recv_context = "222" +} +`, tcacctest.DefaultGaapProxyId, tcacctest.DefaultGaapRealserverIpId1, tcacctest.DefaultGaapRealserverIp1, tcacctest.DefaultGaapRealserverIpId2, tcacctest.DefaultGaapRealserverIp2) + +var testAccGaapLayer4ListenerUdpHealthCheckUpdatePing = fmt.Sprintf(` +resource tencentcloud_gaap_layer4_listener "foo" { + protocol = "UDP" + name = "layer4-udp-listener-hc" + port = 9093 + realserver_type = "IP" + proxy_id = "%s" + + realserver_bind_set { + id = "%s" + ip = "%s" + port = 80 + } + + realserver_bind_set { + id = "%s" + ip = "%s" + port = 80 + } + health_check = true + check_type = "PING" +} +`, tcacctest.DefaultGaapProxyId, tcacctest.DefaultGaapRealserverIpId1, tcacctest.DefaultGaapRealserverIp1, tcacctest.DefaultGaapRealserverIpId2, tcacctest.DefaultGaapRealserverIp2) + var testAccGaapLayer4ListenerUdpDomain = fmt.Sprintf(` resource tencentcloud_gaap_layer4_listener "foo" { diff --git a/tencentcloud/services/gaap/service_tencentcloud_gaap.go b/tencentcloud/services/gaap/service_tencentcloud_gaap.go index d448db64c8..b56677f631 100644 --- a/tencentcloud/services/gaap/service_tencentcloud_gaap.go +++ b/tencentcloud/services/gaap/service_tencentcloud_gaap.go @@ -815,7 +815,7 @@ func (me *GaapService) DeleteProxy(ctx context.Context, id string) error { func (me *GaapService) CreateTCPListener( ctx context.Context, name, scheduler, realserverType, proxyId string, - port, interval, connectTimeout, clientIPMethod int, + port, interval, connectTimeout, clientIPMethod, healthyThreshold, unhealthyThreshold int, healthCheck bool, ) (id string, err error) { logId := tccommon.GetLogId(ctx) @@ -835,6 +835,8 @@ func (me *GaapService) CreateTCPListener( request.DelayLoop = helper.IntUint64(interval) request.ConnectTimeout = helper.IntUint64(connectTimeout) request.ClientIPMethod = helper.IntInt64(clientIPMethod) + request.HealthyThreshold = helper.IntUint64(healthyThreshold) + request.UnhealthyThreshold = helper.IntUint64(unhealthyThreshold) if err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError { ratelimit.Check(request.GetAction()) @@ -870,7 +872,9 @@ func (me *GaapService) CreateTCPListener( func (me *GaapService) CreateUDPListener( ctx context.Context, name, scheduler, realserverType, proxyId string, - port int, + port, interval, connectTimeout, healthyThreshold, unhealthyThreshold int, + healthCheck bool, + optionalParams map[string]interface{}, ) (id string, err error) { logId := tccommon.GetLogId(ctx) client := me.client.UseGaapClient() @@ -881,6 +885,30 @@ func (me *GaapService) CreateUDPListener( request.RealServerType = &realserverType request.ProxyId = &proxyId request.Ports = []*uint64{helper.IntUint64(port)} + request.ConnectTimeout = helper.IntUint64(connectTimeout) + request.DelayLoop = helper.IntUint64(interval) + request.HealthyThreshold = helper.IntUint64(healthyThreshold) + request.UnhealthyThreshold = helper.IntUint64(unhealthyThreshold) + if healthCheck { + request.HealthCheck = helper.IntUint64(1) + } else { + request.HealthCheck = helper.IntUint64(0) + } + if v, ok := optionalParams["check_type"]; ok { + request.CheckType = helper.String(v.(string)) + } + if v, ok := optionalParams["check_port"]; ok { + request.CheckPort = helper.IntInt64(v.(int)) + } + if v, ok := optionalParams["context_type"]; ok { + request.ContextType = helper.String(v.(string)) + } + if v, ok := optionalParams["send_context"]; ok { + request.SendContext = helper.String(v.(string)) + } + if v, ok := optionalParams["recv_context"]; ok { + request.RecvContext = helper.String(v.(string)) + } if err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError { ratelimit.Check(request.GetAction()) @@ -1078,7 +1106,7 @@ func (me *GaapService) ModifyTCPListenerAttribute( proxyId, id string, name, scheduler *string, healthCheck *bool, - interval, connectTimeout int, + interval, connectTimeout, healthyThreshold, unhealthyThreshold int, ) error { logId := tccommon.GetLogId(ctx) client := me.client.UseGaapClient() @@ -1097,6 +1125,8 @@ func (me *GaapService) ModifyTCPListenerAttribute( } request.DelayLoop = helper.IntUint64(interval) request.ConnectTimeout = helper.IntUint64(connectTimeout) + request.HealthyThreshold = helper.IntUint64(healthyThreshold) + request.UnhealthyThreshold = helper.IntUint64(unhealthyThreshold) if err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError { ratelimit.Check(request.GetAction()) @@ -1124,6 +1154,9 @@ func (me *GaapService) ModifyUDPListenerAttribute( ctx context.Context, proxyId, id string, name, scheduler *string, + connectTimeout, interval, healthyThreshold, unhealthyThreshold int, + healthCheck *bool, + optionalParams map[string]interface{}, ) error { logId := tccommon.GetLogId(ctx) client := me.client.UseGaapClient() @@ -1133,6 +1166,32 @@ func (me *GaapService) ModifyUDPListenerAttribute( request.ListenerId = &id request.ListenerName = name request.Scheduler = scheduler + request.ConnectTimeout = helper.IntUint64(connectTimeout) + request.DelayLoop = helper.IntUint64(interval) + if healthCheck != nil { + if *healthCheck { + request.HealthCheck = helper.IntUint64(1) + } else { + request.HealthCheck = helper.IntUint64(0) + } + } + request.HealthyThreshold = helper.IntUint64(healthyThreshold) + request.UnhealthyThreshold = helper.IntUint64(unhealthyThreshold) + if v, ok := optionalParams["check_type"]; ok { + request.CheckType = helper.String(v.(string)) + } + if v, ok := optionalParams["check_port"]; ok { + request.CheckPort = helper.IntInt64(v.(int)) + } + if v, ok := optionalParams["context_type"]; ok { + request.ContextType = helper.String(v.(string)) + } + if v, ok := optionalParams["send_context"]; ok { + request.SendContext = helper.String(v.(string)) + } + if v, ok := optionalParams["recv_context"]; ok { + request.RecvContext = helper.String(v.(string)) + } if err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError { ratelimit.Check(request.GetAction()) diff --git a/website/docs/r/gaap_layer4_listener.html.markdown b/website/docs/r/gaap_layer4_listener.html.markdown index 5a68691f57..ebd04a2239 100644 --- a/website/docs/r/gaap_layer4_listener.html.markdown +++ b/website/docs/r/gaap_layer4_listener.html.markdown @@ -63,12 +63,19 @@ The following arguments are supported: * `protocol` - (Required, String, ForceNew) Protocol of the layer4 listener. Valid value: `TCP` and `UDP`. * `proxy_id` - (Required, String, ForceNew) ID of the GAAP proxy. * `realserver_type` - (Required, String, ForceNew) Type of the realserver. Valid value: `IP` and `DOMAIN`. NOTES: when the `protocol` is specified as `TCP` and the `scheduler` is specified as `wrr`, the item can only be set to `IP`. +* `check_port` - (Optional, Int) UDP origin station health check probe port. +* `check_type` - (Optional, String) UDP origin server health type. PORT means check port, and PING means PING. * `client_ip_method` - (Optional, Int, ForceNew) The way the listener gets the client IP, 0 for TOA, 1 for Proxy Protocol, default value is 0. NOTES: Only supports listeners of `TCP` protocol. * `connect_timeout` - (Optional, Int) Timeout of the health check response, should less than interval, default value is 2s. NOTES: Only supports listeners of `TCP` protocol and require less than `interval`. -* `health_check` - (Optional, Bool) Indicates whether health check is enable, default value is `false`. NOTES: Only supports listeners of `TCP` protocol. -* `interval` - (Optional, Int) Interval of the health check, default value is 5s. NOTES: Only supports listeners of `TCP` protocol. +* `context_type` - (Optional, String) UDP source station health check port probe message type: TEXT represents text. Only used when the health check type is PORT. +* `health_check` - (Optional, Bool) Indicates whether health check is enable, default value is `false`. +* `healthy_threshold` - (Optional, Int) Health threshold, which indicates how many consecutive inspections are successful, the source station is determined to be healthy. Range from 1 to 10. Default value is 1. +* `interval` - (Optional, Int) Interval of the health check, default value is 5s. * `realserver_bind_set` - (Optional, Set) An information list of GAAP realserver. +* `recv_context` - (Optional, String) UDP source server health check port detects received messages. Only used when the health check type is PORT. * `scheduler` - (Optional, String) Scheduling policy of the layer4 listener, default value is `rr`. Valid value: `rr`, `wrr` and `lc`. +* `send_context` - (Optional, String) UDP source server health check port detection sends messages. Only used when health check type is PORT. +* `unhealthy_threshold` - (Optional, Int) Unhealthy threshold, which indicates how many consecutive check failures the source station is considered unhealthy. Range from 1 to 10. Default value is 1. The `realserver_bind_set` object supports the following: