Skip to content

Commit 0185788

Browse files
authored
fix(privatedns): [129144574] tencentcloud_private_dns_zone update code logic (#3637)
* add * add
1 parent f0c72ae commit 0185788

File tree

4 files changed

+37
-27
lines changed

4 files changed

+37
-27
lines changed

.changelog/3637.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: update code logic
3+
```

tencentcloud/services/privatedns/resource_tc_private_dns_zone.go

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ func ResourceTencentCloudPrivateDnsZone() *schema.Resource {
9696
"account_vpc_set": {
9797
Type: schema.TypeList,
9898
Optional: true,
99+
Computed: true,
99100
Description: "List of authorized accounts' VPCs to associate with the private domain.",
100101
Elem: &schema.Resource{
101102
Schema: map[string]*schema.Schema{
@@ -288,8 +289,8 @@ func resourceTencentCloudDPrivateDnsZoneRead(d *schema.ResourceData, meta interf
288289
}
289290

290291
if response.Response.PrivateZone == nil {
291-
d.SetId("")
292292
log.Printf("[WARN]%s resource `tencentcloud_private_dns_zone` [%s] not found, please check if it has been deleted.\n", logId, zoneId)
293+
d.SetId("")
293294
return nil
294295
}
295296

@@ -298,26 +299,30 @@ func resourceTencentCloudDPrivateDnsZoneRead(d *schema.ResourceData, meta interf
298299
_ = d.Set("domain", info.Domain)
299300
}
300301

301-
tagSets := make([]map[string]interface{}, 0, len(info.Tags))
302-
for _, item := range info.Tags {
303-
tagSets = append(tagSets, map[string]interface{}{
304-
"tag_key": item.TagKey,
305-
"tag_value": item.TagValue,
306-
})
302+
if info.Tags != nil {
303+
tagSets := make([]map[string]interface{}, 0, len(info.Tags))
304+
for _, item := range info.Tags {
305+
tagSets = append(tagSets, map[string]interface{}{
306+
"tag_key": item.TagKey,
307+
"tag_value": item.TagValue,
308+
})
309+
}
310+
311+
_ = d.Set("tag_set", tagSets)
307312
}
308313

309-
_ = d.Set("tag_set", tagSets)
314+
if info.VpcSet != nil {
315+
vpcSet := make([]map[string]interface{}, 0, len(info.VpcSet))
316+
for _, item := range info.VpcSet {
317+
vpcSet = append(vpcSet, map[string]interface{}{
318+
"uniq_vpc_id": item.UniqVpcId,
319+
"region": item.Region,
320+
})
321+
}
310322

311-
vpcSet := make([]map[string]interface{}, 0, len(info.VpcSet))
312-
for _, item := range info.VpcSet {
313-
vpcSet = append(vpcSet, map[string]interface{}{
314-
"uniq_vpc_id": item.UniqVpcId,
315-
"region": item.Region,
316-
})
323+
_ = d.Set("vpc_set", vpcSet)
317324
}
318325

319-
_ = d.Set("vpc_set", vpcSet)
320-
321326
if info.Remark != nil {
322327
_ = d.Set("remark", info.Remark)
323328
}
@@ -330,16 +335,18 @@ func resourceTencentCloudDPrivateDnsZoneRead(d *schema.ResourceData, meta interf
330335
_ = d.Set("cname_speedup_status", info.CnameSpeedupStatus)
331336
}
332337

333-
accountVpcSet := make([]map[string]interface{}, 0, len(info.AccountVpcSet))
334-
for _, item := range info.AccountVpcSet {
335-
accountVpcSet = append(accountVpcSet, map[string]interface{}{
336-
"uin": item.Uin,
337-
"uniq_vpc_id": item.UniqVpcId,
338-
"region": item.Region,
339-
})
340-
}
338+
if info.AccountVpcSet != nil {
339+
accountVpcSet := make([]map[string]interface{}, 0, len(info.AccountVpcSet))
340+
for _, item := range info.AccountVpcSet {
341+
accountVpcSet = append(accountVpcSet, map[string]interface{}{
342+
"uin": item.Uin,
343+
"uniq_vpc_id": item.UniqVpcId,
344+
"region": item.Region,
345+
})
346+
}
341347

342-
_ = d.Set("account_vpc_set", accountVpcSet)
348+
_ = d.Set("account_vpc_set", accountVpcSet)
349+
}
343350

344351
client := meta.(tccommon.ProviderMeta).GetAPIV3Conn()
345352
tagService := svctag.NewTagService(client)

tencentcloud/services/privatedns/resource_tc_private_dns_zone_vpc_attachment.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ resource "tencentcloud_private_dns_zone_vpc_attachment" "example" {
5050

5151
Import
5252

53-
PrivateDns zone vpc attachment can be imported using the id, e.g.
53+
PrivateDns zone vpc attachment can be imported using the zoneId#uniqVpcId, e.g.
5454

5555
```
5656
terraform import tencentcloud_private_dns_zone_vpc_attachment.example zone-6t11lof0#vpc-jdx11z0t

website/docs/r/private_dns_zone_vpc_attachment.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ In addition to all arguments above, the following attributes are exported:
8888

8989
## Import
9090

91-
PrivateDns zone vpc attachment can be imported using the id, e.g.
91+
PrivateDns zone vpc attachment can be imported using the zoneId#uniqVpcId, e.g.
9292

9393
```
9494
terraform import tencentcloud_private_dns_zone_vpc_attachment.example zone-6t11lof0#vpc-jdx11z0t

0 commit comments

Comments
 (0)