Skip to content

Commit 459d7d8

Browse files
authored
fix(dnspod): modify record remark (#2288)
* fix(dnspod): modify remark * fix(dnspod): modify remark * fix(dnspod): modify remark
1 parent 5f6726a commit 459d7d8

File tree

4 files changed

+54
-18
lines changed

4 files changed

+54
-18
lines changed

.changelog/2288.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
tencentcloud_dnspod_record: Fix modify dnspod record remark
3+
```

tencentcloud/resource_tc_dnspod_record.go

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/*
22
Provide a resource to create a DnsPod record.
33
4+
~> **NOTE:** Versions before v1.81.43 (including v1.81.43) do not support modifying remark or modifying remark has bug.
5+
46
Example Usage
57
68
```hcl
@@ -103,7 +105,7 @@ func resourceTencentCloudDnspodRecord() *schema.Resource {
103105
},
104106
"remark": {
105107
Type: schema.TypeString,
106-
Computed: true,
108+
Optional: true,
107109
Description: "The Remark of record.",
108110
},
109111
},
@@ -113,8 +115,12 @@ func resourceTencentCloudDnspodRecord() *schema.Resource {
113115
func resourceTencentCloudDnspodRecordCreate(d *schema.ResourceData, meta interface{}) error {
114116
defer logElapsed("resource.tencentcloud_dnspod_record.create")()
115117
logId := getLogId(contextNil)
118+
119+
var (
120+
recordId uint64
121+
)
116122
request := dnspod.NewCreateRecordRequest()
117-
requestRemark := dnspod.NewModifyDomainRemarkRequest()
123+
requestRemark := dnspod.NewModifyRecordRemarkRequest()
118124

119125
domain := d.Get("domain").(string)
120126
recordType := d.Get("record_type").(string)
@@ -142,10 +148,9 @@ func resourceTencentCloudDnspodRecordCreate(d *schema.ResourceData, meta interfa
142148
if e != nil {
143149
return retryError(e)
144150
}
145-
recordId := *response.Response.RecordId
151+
recordId = *response.Response.RecordId
146152

147153
d.SetId(domain + FILED_SP + fmt.Sprint(recordId))
148-
149154
return nil
150155
})
151156
if err != nil {
@@ -155,9 +160,10 @@ func resourceTencentCloudDnspodRecordCreate(d *schema.ResourceData, meta interfa
155160

156161
if v, ok := d.GetOk("remark"); ok {
157162
requestRemark.Domain = helper.String(domain)
163+
requestRemark.RecordId = helper.Uint64(recordId)
158164
requestRemark.Remark = helper.String(v.(string))
159165
err := resource.Retry(readRetryTimeout, func() *resource.RetryError {
160-
_, e := meta.(*TencentCloudClient).apiV3Conn.UseDnsPodClient().ModifyDomainRemark(requestRemark)
166+
_, e := meta.(*TencentCloudClient).apiV3Conn.UseDnsPodClient().ModifyRecordRemark(requestRemark)
161167
if e != nil {
162168
return retryError(e)
163169
}
@@ -239,7 +245,7 @@ func resourceTencentCloudDnspodRecordUpdate(d *schema.ResourceData, meta interfa
239245
return err
240246
}
241247
request := dnspod.NewModifyRecordRequest()
242-
requestRemark := dnspod.NewModifyDomainRemarkRequest()
248+
requestRemark := dnspod.NewModifyRecordRemarkRequest()
243249
request.Domain = &domain
244250
request.RecordId = helper.IntUint64(recordId)
245251
recordType := d.Get("record_type").(string)
@@ -285,8 +291,9 @@ func resourceTencentCloudDnspodRecordUpdate(d *schema.ResourceData, meta interfa
285291
remark := d.Get("remark").(string)
286292
requestRemark.Domain = helper.String(domain)
287293
requestRemark.Remark = helper.String(remark)
294+
requestRemark.RecordId = helper.IntUint64(recordId)
288295
err := resource.Retry(readRetryTimeout, func() *resource.RetryError {
289-
_, e := meta.(*TencentCloudClient).apiV3Conn.UseDnsPodClient().ModifyDomainRemark(requestRemark)
296+
_, e := meta.(*TencentCloudClient).apiV3Conn.UseDnsPodClient().ModifyRecordRemark(requestRemark)
290297
if e != nil {
291298
return retryError(e)
292299
}

tencentcloud/resource_tc_dnspod_record_test.go

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,18 @@ import (
1313
"github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper"
1414
)
1515

16-
func TestAccTencentCloudDnspodRecord(t *testing.T) {
16+
func TestAccTencentCloudDnspodRecordResource_basic(t *testing.T) {
1717
t.Parallel()
1818
resource.Test(t, resource.TestCase{
19+
PreCheck: func() { testAccPreCheckCommon(t, ACCOUNT_TYPE_PREPAY) },
1920
Providers: testAccProviders,
2021
CheckDestroy: testAccCheckDnspodRecordDestroy,
2122
Steps: []resource.TestStep{
2223
{
2324
Config: testAccTencentCloudDnspodRecord,
2425
Check: resource.ComposeTestCheckFunc(
2526
testAccCheckDnspodRecordExists("tencentcloud_dnspod_record.demo"),
26-
resource.TestCheckResourceAttr("tencentcloud_dnspod_record.demo", "domain", "terraform.com"),
27+
resource.TestCheckResourceAttr("tencentcloud_dnspod_record.demo", "domain", "iac-tf.cloud"),
2728
resource.TestCheckResourceAttr("tencentcloud_dnspod_record.demo", "value", "1.2.3.9"),
2829
resource.TestCheckResourceAttr("tencentcloud_dnspod_record.demo", "sub_domain", "demo"),
2930
resource.TestCheckResourceAttr("tencentcloud_dnspod_record.demo", "status", "ENABLE"),
@@ -32,6 +33,19 @@ func TestAccTencentCloudDnspodRecord(t *testing.T) {
3233
resource.TestCheckResourceAttr("tencentcloud_dnspod_record.demo", "remark", "terraform-test"),
3334
),
3435
},
36+
{
37+
Config: testAccTencentCloudDnspodRecordRemarkUp,
38+
Check: resource.ComposeTestCheckFunc(
39+
testAccCheckDnspodRecordExists("tencentcloud_dnspod_record.demo"),
40+
resource.TestCheckResourceAttr("tencentcloud_dnspod_record.demo", "domain", "iac-tf.cloud"),
41+
resource.TestCheckResourceAttr("tencentcloud_dnspod_record.demo", "value", "1.2.3.9"),
42+
resource.TestCheckResourceAttr("tencentcloud_dnspod_record.demo", "sub_domain", "demo"),
43+
resource.TestCheckResourceAttr("tencentcloud_dnspod_record.demo", "status", "ENABLE"),
44+
resource.TestCheckResourceAttr("tencentcloud_dnspod_record.demo", "record_type", "A"),
45+
resource.TestCheckResourceAttr("tencentcloud_dnspod_record.demo", "record_line", "默认"),
46+
resource.TestCheckResourceAttr("tencentcloud_dnspod_record.demo", "remark", "terraform-test1"),
47+
),
48+
},
3549
{
3650
ResourceName: "tencentcloud_dnspod_record.demo",
3751
ImportState: true,
@@ -119,12 +133,22 @@ func testAccCheckDnspodRecordDestroy(s *terraform.State) error {
119133
}
120134

121135
const testAccTencentCloudDnspodRecord = `
122-
resource "tencentcloud_dnspod_record" "demo" {
123-
domain="terraform.com"
124-
record_type="A"
125-
record_line="默认"
126-
value="1.2.3.9"
127-
sub_domain="demo"
128-
remark="terraform-test"
129-
}
136+
resource "tencentcloud_dnspod_record" "demo" {
137+
domain="iac-tf.cloud"
138+
record_type="A"
139+
record_line="默认"
140+
value="1.2.3.9"
141+
sub_domain="demo"
142+
remark="terraform-test"
143+
}
144+
`
145+
const testAccTencentCloudDnspodRecordRemarkUp = `
146+
resource "tencentcloud_dnspod_record" "demo" {
147+
domain="iac-tf.cloud"
148+
record_type="A"
149+
record_line="默认"
150+
value="1.2.3.9"
151+
sub_domain="demo"
152+
remark="terraform-test1"
153+
}
130154
`

website/docs/r/dnspod_record.html.markdown

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ description: |-
1111

1212
Provide a resource to create a DnsPod record.
1313

14+
~> **NOTE:** Versions before v1.81.43 (including v1.81.43) do not support modifying remark or modifying remark has bug.
15+
1416
## Example Usage
1517

1618
```hcl
@@ -32,6 +34,7 @@ The following arguments are supported:
3234
* `record_type` - (Required, String) The record type.
3335
* `value` - (Required, String) The record value.
3436
* `mx` - (Optional, Int) MX priority, valid when the record type is MX, range 1-20. Note: must set when record type equal MX.
37+
* `remark` - (Optional, String) The Remark of record.
3538
* `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.
3639
* `sub_domain` - (Optional, String) The host records, default value is `@`.
3740
* `ttl` - (Optional, Int) TTL, the range is 1-604800, and the minimum value of different levels of domain names is different. Default is 600.
@@ -43,7 +46,6 @@ In addition to all arguments above, the following attributes are exported:
4346

4447
* `id` - ID of the resource.
4548
* `monitor_status` - The monitoring status of the record.
46-
* `remark` - The Remark of record.
4749

4850

4951
## Import

0 commit comments

Comments
 (0)