diff --git a/tencentcloud/services/dnspod/resource_tc_dnspod_record.go b/tencentcloud/services/dnspod/resource_tc_dnspod_record.go index c7076f1b81..4c37e4a15e 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 + }, } } @@ -207,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