Skip to content

Commit 583f3c2

Browse files
authored
feat: dnspod record import (#1260)
* feat: dnspod record import * feat: update domain Co-authored-by: arunma <arunma@tencent.com>
1 parent 1e3c869 commit 583f3c2

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

tencentcloud/resource_tc_dnspod_record.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ resource "tencentcloud_dnspod_record" "demo" {
1212
sub_domain="demo"
1313
}
1414
```
15+
16+
Import
17+
18+
DnsPod Domain record can be imported using the Domain#RecordId, e.g.
19+
20+
```
21+
$ terraform import tencentcloud_dnspod_record.demo arunma.com#1194109872
22+
```
1523
*/
1624
package tencentcloud
1725

@@ -33,6 +41,9 @@ func resourceTencentCloudDnspodRecord() *schema.Resource {
3341
Read: resourceTencentCloudDnspodRecordRead,
3442
Update: resourceTencentCloudDnspodRecordUpdate,
3543
Delete: resourceTencentCloudDnspodRecordDelete,
44+
Importer: &schema.ResourceImporter{
45+
State: schema.ImportStatePassthrough,
46+
},
3647

3748
Schema: map[string]*schema.Schema{
3849
"domain": {
@@ -171,6 +182,10 @@ func resourceTencentCloudDnspodRecordRead(d *schema.ResourceData, meta interface
171182
_ = d.Set("ttl", recordInfo.TTL)
172183
_ = d.Set("monitor_status", recordInfo.MonitorStatus)
173184
_ = d.Set("weight", recordInfo.Weight)
185+
_ = d.Set("domain", items[0])
186+
_ = d.Set("record_line", recordInfo.RecordLine)
187+
_ = d.Set("record_type", recordInfo.RecordType)
188+
_ = d.Set("value", recordInfo.Value)
174189
if *recordInfo.Enabled == uint64(0) {
175190
_ = d.Set("status", "DISABLE")
176191
} else {

tencentcloud/resource_tc_dnspod_record_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ func TestAccTencentCloudDnspodRecord(t *testing.T) {
3131
resource.TestCheckResourceAttr("tencentcloud_dnspod_record.demo", "record_line", "默认"),
3232
),
3333
},
34+
{
35+
ResourceName: "tencentcloud_dnspod_record.demo",
36+
ImportState: true,
37+
ImportStateVerify: true,
38+
},
3439
},
3540
})
3641
}

website/docs/r/dnspod_record.html.markdown

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,11 @@ In addition to all arguments above, the following attributes are exported:
4545
* `monitor_status` - The D monitoring status of the record.
4646

4747

48+
## Import
49+
50+
DnsPod Domain record can be imported using the Domain#RecordId, e.g.
51+
52+
```
53+
$ terraform import tencentcloud_dnspod_record.demo arunma.com#1194109872
54+
```
55+

0 commit comments

Comments
 (0)