Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions tencentcloud/services/dnspod/resource_tc_dnspod_record.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dnspod

import (
"context"
"fmt"
"log"
"strconv"
Expand Down Expand Up @@ -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,
Expand All @@ -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
},
}
}

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/dnspod_record.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading