Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/3637.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/tencentcloud_private_dns_zone: update code logic
```
57 changes: 32 additions & 25 deletions tencentcloud/services/privatedns/resource_tc_private_dns_zone.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ func ResourceTencentCloudPrivateDnsZone() *schema.Resource {
"account_vpc_set": {
Type: schema.TypeList,
Optional: true,
Computed: true,
Description: "List of authorized accounts' VPCs to associate with the private domain.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
Expand Down Expand Up @@ -288,8 +289,8 @@ func resourceTencentCloudDPrivateDnsZoneRead(d *schema.ResourceData, meta interf
}

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

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

tagSets := make([]map[string]interface{}, 0, len(info.Tags))
for _, item := range info.Tags {
tagSets = append(tagSets, map[string]interface{}{
"tag_key": item.TagKey,
"tag_value": item.TagValue,
})
if info.Tags != nil {
tagSets := make([]map[string]interface{}, 0, len(info.Tags))
for _, item := range info.Tags {
tagSets = append(tagSets, map[string]interface{}{
"tag_key": item.TagKey,
"tag_value": item.TagValue,
})
}

_ = d.Set("tag_set", tagSets)
}

_ = d.Set("tag_set", tagSets)
if info.VpcSet != nil {
vpcSet := make([]map[string]interface{}, 0, len(info.VpcSet))
for _, item := range info.VpcSet {
vpcSet = append(vpcSet, map[string]interface{}{
"uniq_vpc_id": item.UniqVpcId,
"region": item.Region,
})
}

vpcSet := make([]map[string]interface{}, 0, len(info.VpcSet))
for _, item := range info.VpcSet {
vpcSet = append(vpcSet, map[string]interface{}{
"uniq_vpc_id": item.UniqVpcId,
"region": item.Region,
})
_ = d.Set("vpc_set", vpcSet)
}

_ = d.Set("vpc_set", vpcSet)

if info.Remark != nil {
_ = d.Set("remark", info.Remark)
}
Expand All @@ -330,16 +335,18 @@ func resourceTencentCloudDPrivateDnsZoneRead(d *schema.ResourceData, meta interf
_ = d.Set("cname_speedup_status", info.CnameSpeedupStatus)
}

accountVpcSet := make([]map[string]interface{}, 0, len(info.AccountVpcSet))
for _, item := range info.AccountVpcSet {
accountVpcSet = append(accountVpcSet, map[string]interface{}{
"uin": item.Uin,
"uniq_vpc_id": item.UniqVpcId,
"region": item.Region,
})
}
if info.AccountVpcSet != nil {
accountVpcSet := make([]map[string]interface{}, 0, len(info.AccountVpcSet))
for _, item := range info.AccountVpcSet {
accountVpcSet = append(accountVpcSet, map[string]interface{}{
"uin": item.Uin,
"uniq_vpc_id": item.UniqVpcId,
"region": item.Region,
})
}

_ = d.Set("account_vpc_set", accountVpcSet)
_ = d.Set("account_vpc_set", accountVpcSet)
}

client := meta.(tccommon.ProviderMeta).GetAPIV3Conn()
tagService := svctag.NewTagService(client)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ resource "tencentcloud_private_dns_zone_vpc_attachment" "example" {

Import

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

```
terraform import tencentcloud_private_dns_zone_vpc_attachment.example zone-6t11lof0#vpc-jdx11z0t
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ In addition to all arguments above, the following attributes are exported:

## Import

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

```
terraform import tencentcloud_private_dns_zone_vpc_attachment.example zone-6t11lof0#vpc-jdx11z0t
Expand Down
Loading