Skip to content

Commit 284ea37

Browse files
committed
add
1 parent c290d73 commit 284ea37

File tree

3 files changed

+14
-84
lines changed

3 files changed

+14
-84
lines changed

tencentcloud/services/privatedns/resource_tc_private_dns_record.go

Lines changed: 6 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ func ResourceTencentCloudPrivateDnsRecord() *schema.Resource {
2424
Importer: &schema.ResourceImporter{
2525
State: schema.ImportStatePassthrough,
2626
},
27-
2827
Schema: map[string]*schema.Schema{
2928
"zone_id": {
3029
Type: schema.TypeString,
@@ -35,12 +34,12 @@ func ResourceTencentCloudPrivateDnsRecord() *schema.Resource {
3534
"record_type": {
3635
Type: schema.TypeString,
3736
Required: true,
38-
Description: "Record type. Valid values: \"A\", \"AAAA\", \"CNAME\", \"MX\", \"TXT\", \"PTR\".",
37+
Description: "Record type. Valid values: `A`, `AAAA`, `CNAME`, `MX`, `TXT`, `PTR`.",
3938
},
4039
"sub_domain": {
4140
Type: schema.TypeString,
4241
Required: true,
43-
Description: "Subdomain, such as \"www\", \"m\", and \"@\".",
42+
Description: "Subdomain, such as `www`, `m`, and `@`.",
4443
},
4544
"record_value": {
4645
Type: schema.TypeString,
@@ -252,7 +251,7 @@ func resourceTencentCloudDPrivateDnsRecordDelete(d *schema.ResourceData, meta in
252251

253252
var (
254253
logId = tccommon.GetLogId(tccommon.ContextNil)
255-
request = privatedns.NewDescribePrivateZoneRequest()
254+
request = privatedns.NewDeletePrivateZoneRecordRequest()
256255
)
257256

258257
idSplit := strings.Split(d.Id(), tccommon.FILED_SP)
@@ -263,54 +262,10 @@ func resourceTencentCloudDPrivateDnsRecordDelete(d *schema.ResourceData, meta in
263262
zoneId := idSplit[0]
264263
recordId := idSplit[1]
265264

266-
// unbind
267-
var response *privatedns.DescribePrivateZoneResponse
268265
request.ZoneId = helper.String(zoneId)
269-
err := resource.Retry(tccommon.ReadRetryTimeout, func() *resource.RetryError {
270-
result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UsePrivateDnsClient().DescribePrivateZone(request)
271-
if e != nil {
272-
return tccommon.RetryError(e)
273-
}
274-
275-
response = result
276-
return nil
277-
})
278-
279-
if err != nil {
280-
log.Printf("[CRITAL]%s read private dns failed, reason:%s\n", logId, err.Error())
281-
return err
282-
}
283-
284-
info := response.Response.PrivateZone
285-
oldVpcSet := info.VpcSet
286-
oldAccVpcSet := info.AccountVpcSet
287-
288-
unBindRequest := privatedns.NewModifyPrivateZoneVpcRequest()
289-
unBindRequest.ZoneId = helper.String(zoneId)
290-
unBindRequest.VpcSet = []*privatedns.VpcInfo{}
291-
unBindRequest.AccountVpcSet = []*privatedns.AccountVpcInfo{}
292-
293-
err = resource.Retry(tccommon.ReadRetryTimeout, func() *resource.RetryError {
294-
_, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UsePrivateDnsClient().ModifyPrivateZoneVpc(unBindRequest)
295-
if e != nil {
296-
return tccommon.RetryError(e)
297-
}
298-
299-
return nil
300-
})
301-
302-
if err != nil {
303-
log.Printf("[CRITAL]%s unbind privateDns zone vpc failed, reason:%s\n", logId, err.Error())
304-
return err
305-
}
306-
307-
// delete
308-
recordRequest := privatedns.NewDeletePrivateZoneRecordRequest()
309-
recordRequest.ZoneId = helper.String(zoneId)
310-
recordRequest.RecordId = helper.String(recordId)
311-
312-
err = resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
313-
_, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UsePrivateDnsClient().DeletePrivateZoneRecord(recordRequest)
266+
request.RecordId = helper.String(recordId)
267+
err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
268+
_, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UsePrivateDnsClient().DeletePrivateZoneRecord(request)
314269
if e != nil {
315270
return tccommon.RetryError(e)
316271
}
@@ -323,36 +278,5 @@ func resourceTencentCloudDPrivateDnsRecordDelete(d *schema.ResourceData, meta in
323278
return err
324279
}
325280

326-
// rebind
327-
unBindRequest = privatedns.NewModifyPrivateZoneVpcRequest()
328-
unBindRequest.ZoneId = helper.String(zoneId)
329-
unBindRequest.VpcSet = oldVpcSet
330-
331-
accountVpcSet := make([]*privatedns.AccountVpcInfo, 0, len(oldAccVpcSet))
332-
for _, item := range oldAccVpcSet {
333-
info := privatedns.AccountVpcInfo{
334-
Uin: item.Uin,
335-
UniqVpcId: item.UniqVpcId,
336-
Region: item.Region,
337-
}
338-
accountVpcSet = append(accountVpcSet, &info)
339-
}
340-
341-
unBindRequest.AccountVpcSet = accountVpcSet
342-
343-
err = resource.Retry(tccommon.ReadRetryTimeout, func() *resource.RetryError {
344-
_, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UsePrivateDnsClient().ModifyPrivateZoneVpc(unBindRequest)
345-
if e != nil {
346-
return tccommon.RetryError(e)
347-
}
348-
349-
return nil
350-
})
351-
352-
if err != nil {
353-
log.Printf("[CRITAL]%s rebind privateDns zone vpc failed, reason:%s\n", logId, err.Error())
354-
return err
355-
}
356-
357281
return nil
358282
}

tencentcloud/services/privatedns/resource_tc_private_dns_record.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ Provide a resource to create a Private Dns Record.
33
Example Usage
44

55
```hcl
6+
# create vpc
67
resource "tencentcloud_vpc" "vpc" {
78
name = "vpc-example"
89
cidr_block = "10.0.0.0/16"
910
}
1011
12+
# create private dns zone
1113
resource "tencentcloud_private_dns_zone" "example" {
1214
domain = "domain.com"
1315
remark = "remark."
@@ -25,6 +27,7 @@ resource "tencentcloud_private_dns_zone" "example" {
2527
}
2628
}
2729
30+
# create private dns record
2831
resource "tencentcloud_private_dns_record" "example" {
2932
zone_id = tencentcloud_private_dns_zone.example.id
3033
record_type = "A"

website/docs/r/private_dns_record.html.markdown

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ Provide a resource to create a Private Dns Record.
1414
## Example Usage
1515

1616
```hcl
17+
# create vpc
1718
resource "tencentcloud_vpc" "vpc" {
1819
name = "vpc-example"
1920
cidr_block = "10.0.0.0/16"
2021
}
2122
23+
# create private dns zone
2224
resource "tencentcloud_private_dns_zone" "example" {
2325
domain = "domain.com"
2426
remark = "remark."
@@ -36,6 +38,7 @@ resource "tencentcloud_private_dns_zone" "example" {
3638
}
3739
}
3840
41+
# create private dns record
3942
resource "tencentcloud_private_dns_record" "example" {
4043
zone_id = tencentcloud_private_dns_zone.example.id
4144
record_type = "A"
@@ -51,9 +54,9 @@ resource "tencentcloud_private_dns_record" "example" {
5154

5255
The following arguments are supported:
5356

54-
* `record_type` - (Required, String) Record type. Valid values: "A", "AAAA", "CNAME", "MX", "TXT", "PTR".
57+
* `record_type` - (Required, String) Record type. Valid values: `A`, `AAAA`, `CNAME`, `MX`, `TXT`, `PTR`.
5558
* `record_value` - (Required, String) Record value, such as IP: 192.168.10.2, CNAME: cname.qcloud.com, and MX: mail.qcloud.com.
56-
* `sub_domain` - (Required, String) Subdomain, such as "www", "m", and "@".
59+
* `sub_domain` - (Required, String) Subdomain, such as `www`, `m`, and `@`.
5760
* `zone_id` - (Required, String, ForceNew) Private domain ID.
5861
* `mx` - (Optional, Int) MX priority, which is required when the record type is MX. Valid values: 5, 10, 15, 20, 30, 40, 50.
5962
* `ttl` - (Optional, Int) Record cache time. The smaller the value, the faster the record will take effect. Value range: 1~86400s.

0 commit comments

Comments
 (0)