From 37d083c491566e6e5c2a69a4c764f4d5fbb4fcf0 Mon Sep 17 00:00:00 2001 From: mikatong Date: Thu, 4 Sep 2025 15:50:10 +0800 Subject: [PATCH 1/2] fix weight --- .../services/dnspod/resource_tc_dnspod_record.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tencentcloud/services/dnspod/resource_tc_dnspod_record.go b/tencentcloud/services/dnspod/resource_tc_dnspod_record.go index c7076f1b81..9254393373 100644 --- a/tencentcloud/services/dnspod/resource_tc_dnspod_record.go +++ b/tencentcloud/services/dnspod/resource_tc_dnspod_record.go @@ -1,6 +1,7 @@ package dnspod import ( + "context" "fmt" "log" "strconv" @@ -69,8 +70,7 @@ func ResourceTencentCloudDnspodRecord() *schema.Resource { "weight": { Type: schema.TypeInt, Optional: true, - Default: 0, - Description: "Weight information. An integer from 0 to 100. Only enterprise VIP domain names are available, 0 means off, does not pass this parameter, means that the weight information is not set. Default is 0.", + Description: "Weight information. An integer from 1 to 100. Only enterprise VIP domain names are available, does not pass this parameter, means that the weight information is not set.", }, "status": { Type: schema.TypeString, @@ -89,6 +89,16 @@ func ResourceTencentCloudDnspodRecord() *schema.Resource { Description: "The Remark of record.", }, }, + CustomizeDiff: func(ctx context.Context, d *schema.ResourceDiff, meta interface{}) error { + // weight设置后不能单独关闭 + if d.HasChange("weight") { + old, new := d.GetChange("weight") + if old.(int) != 0 && new.(int) == 0 { + return fmt.Errorf("field `weight` cannot be unset once specified") + } + } + return nil + }, } } From e975d64c77785d2fa75c459a2862d83837c4fa59 Mon Sep 17 00:00:00 2001 From: mikatong Date: Mon, 15 Sep 2025 15:25:14 +0800 Subject: [PATCH 2/2] update --- tencentcloud/services/dnspod/resource_tc_dnspod_record.go | 4 +++- website/docs/r/dnspod_record.html.markdown | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tencentcloud/services/dnspod/resource_tc_dnspod_record.go b/tencentcloud/services/dnspod/resource_tc_dnspod_record.go index 9254393373..4c37e4a15e 100644 --- a/tencentcloud/services/dnspod/resource_tc_dnspod_record.go +++ b/tencentcloud/services/dnspod/resource_tc_dnspod_record.go @@ -217,7 +217,9 @@ func resourceTencentCloudDnspodRecordRead(d *schema.ResourceData, meta interface _ = d.Set("mx", recordInfo.MX) _ = d.Set("ttl", recordInfo.TTL) _ = d.Set("monitor_status", recordInfo.MonitorStatus) - _ = d.Set("weight", recordInfo.Weight) + if recordInfo.Weight != nil { + _ = d.Set("weight", recordInfo.Weight) + } _ = d.Set("domain", items[0]) _ = d.Set("record_line", recordInfo.RecordLine) _ = d.Set("record_type", recordInfo.RecordType) diff --git a/website/docs/r/dnspod_record.html.markdown b/website/docs/r/dnspod_record.html.markdown index 87a9154a0b..0bff0754b3 100644 --- a/website/docs/r/dnspod_record.html.markdown +++ b/website/docs/r/dnspod_record.html.markdown @@ -38,7 +38,7 @@ The following arguments are supported: * `status` - (Optional, String) Records the initial state, with values ranging from ENABLE and DISABLE. The default is ENABLE, and if DISABLE is passed in, resolution will not take effect and the limits of load balancing will not be verified. * `sub_domain` - (Optional, String) The host records, default value is `@`. * `ttl` - (Optional, Int) TTL, the range is 1-604800, and the minimum value of different levels of domain names is different. Default is 600. -* `weight` - (Optional, Int) Weight information. An integer from 0 to 100. Only enterprise VIP domain names are available, 0 means off, does not pass this parameter, means that the weight information is not set. Default is 0. +* `weight` - (Optional, Int) Weight information. An integer from 1 to 100. Only enterprise VIP domain names are available, does not pass this parameter, means that the weight information is not set. ## Attributes Reference