Skip to content

Commit a18e594

Browse files
authored
feat(privatedns): [120224824] Support unbind all VPCs bound to the current private dns zone (#2914)
* support unbind vpc * support unbind vpc
1 parent caba6f2 commit a18e594

File tree

5 files changed

+27
-13
lines changed

5 files changed

+27
-13
lines changed

.changelog/2914.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
resource/tencentcloud_private_dns_zone: Support unbind all VPCs bound to the current private dns zone.
3+
```

tencentcloud/services/privatedns/resource_tc_private_dns_zone.go

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,15 @@ func resourceTencentCloudDPrivateDnsZoneCreate(d *schema.ResourceData, meta inte
165165
if v, ok := d.GetOk("vpc_set"); ok {
166166
vpcSet := make([]*privatedns.VpcInfo, 0, 10)
167167
for _, item := range v.([]interface{}) {
168-
m := item.(map[string]interface{})
169-
vpcInfo := privatedns.VpcInfo{
170-
UniqVpcId: helper.String(m["uniq_vpc_id"].(string)),
171-
Region: helper.String(m["region"].(string)),
172-
}
168+
if item != nil {
169+
m := item.(map[string]interface{})
170+
vpcInfo := privatedns.VpcInfo{
171+
UniqVpcId: helper.String(m["uniq_vpc_id"].(string)),
172+
Region: helper.String(m["region"].(string)),
173+
}
173174

174-
vpcSet = append(vpcSet, &vpcInfo)
175+
vpcSet = append(vpcSet, &vpcInfo)
176+
}
175177
}
176178

177179
request.VpcSet = vpcSet
@@ -371,12 +373,16 @@ func resourceTencentCloudDPrivateDnsZoneUpdate(d *schema.ResourceData, meta inte
371373
var vpcSets = make([]*privatedns.VpcInfo, 0)
372374
items := v.([]interface{})
373375
for _, item := range items {
374-
value := item.(map[string]interface{})
375-
vpcInfo := &privatedns.VpcInfo{
376-
UniqVpcId: helper.String(value["uniq_vpc_id"].(string)),
377-
Region: helper.String(value["region"].(string)),
376+
if item != nil {
377+
value := item.(map[string]interface{})
378+
if value["uniq_vpc_id"].(string) != "" && value["region"].(string) != "" {
379+
vpcInfo := &privatedns.VpcInfo{
380+
UniqVpcId: helper.String(value["uniq_vpc_id"].(string)),
381+
Region: helper.String(value["region"].(string)),
382+
}
383+
vpcSets = append(vpcSets, vpcInfo)
384+
}
378385
}
379-
vpcSets = append(vpcSets, vpcInfo)
380386
}
381387
request.VpcSet = vpcSets
382388
}

tencentcloud/services/privatedns/resource_tc_private_dns_zone.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
Provide a resource to create a Private Dns Zone.
22

3+
~> **NOTE:** If you want to unbind all VPCs bound to the current private dns zone, simply clearing the declaration will not take effect; you need to set the `region` and `uniq_vpc_id` in `vpc_set` to an empty string.
4+
35
Example Usage
46

57
Create a basic Private Dns Zone

tencentcloud/services/tke/resource_tc_kubernetes_scale_worker.go

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

website/docs/r/private_dns_zone.html.markdown

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ description: |-
1111

1212
Provide a resource to create a Private Dns Zone.
1313

14+
~> **NOTE:** If you want to unbind all VPCs bound to the current private dns zone, simply clearing the declaration will not take effect; you need to set the `region` and `uniq_vpc_id` in `vpc_set` to an empty string.
15+
1416
## Example Usage
1517

1618
### Create a basic Private Dns Zone

0 commit comments

Comments
 (0)