From 10625076f6782671e1861542df96811a481892ec Mon Sep 17 00:00:00 2001 From: SevenEarth <391613297@qq.com> Date: Mon, 8 Dec 2025 11:13:58 +0800 Subject: [PATCH 1/2] add --- .../resource_tc_private_dns_zone.go | 57 +++++++++++-------- ...urce_tc_private_dns_zone_vpc_attachment.md | 2 +- ...vate_dns_zone_vpc_attachment.html.markdown | 2 +- 3 files changed, 34 insertions(+), 27 deletions(-) diff --git a/tencentcloud/services/privatedns/resource_tc_private_dns_zone.go b/tencentcloud/services/privatedns/resource_tc_private_dns_zone.go index 0a2d43b77b..1b69df6a6a 100644 --- a/tencentcloud/services/privatedns/resource_tc_private_dns_zone.go +++ b/tencentcloud/services/privatedns/resource_tc_private_dns_zone.go @@ -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{ @@ -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 } @@ -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) } @@ -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) diff --git a/tencentcloud/services/privatedns/resource_tc_private_dns_zone_vpc_attachment.md b/tencentcloud/services/privatedns/resource_tc_private_dns_zone_vpc_attachment.md index 759b960475..9ead87915a 100644 --- a/tencentcloud/services/privatedns/resource_tc_private_dns_zone_vpc_attachment.md +++ b/tencentcloud/services/privatedns/resource_tc_private_dns_zone_vpc_attachment.md @@ -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 diff --git a/website/docs/r/private_dns_zone_vpc_attachment.html.markdown b/website/docs/r/private_dns_zone_vpc_attachment.html.markdown index 4dac053d0f..e7ae7aecd1 100644 --- a/website/docs/r/private_dns_zone_vpc_attachment.html.markdown +++ b/website/docs/r/private_dns_zone_vpc_attachment.html.markdown @@ -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 From d6b24f072ea826b21d165a7c0e96234c71338e32 Mon Sep 17 00:00:00 2001 From: SevenEarth <391613297@qq.com> Date: Mon, 8 Dec 2025 11:15:34 +0800 Subject: [PATCH 2/2] add --- .changelog/3637.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/3637.txt diff --git a/.changelog/3637.txt b/.changelog/3637.txt new file mode 100644 index 0000000000..6984669b2f --- /dev/null +++ b/.changelog/3637.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/tencentcloud_private_dns_zone: update code logic +``` \ No newline at end of file