Skip to content

Commit 71113b7

Browse files
authored
feat(privatedns): [120490271] Add new resource tencentcloud_subscribe_private_zone_service (#2929)
* add * add
1 parent 750fde6 commit 71113b7

8 files changed

+161
-0
lines changed

.changelog/2929.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:new-resource
2+
tencentcloud_subscribe_private_zone_service
3+
```

tencentcloud/provider.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1683,6 +1683,7 @@ func Provider() *schema.Provider {
16831683
"tencentcloud_private_dns_zone": privatedns.ResourceTencentCloudPrivateDnsZone(),
16841684
"tencentcloud_private_dns_record": privatedns.ResourceTencentCloudPrivateDnsRecord(),
16851685
"tencentcloud_private_dns_zone_vpc_attachment": privatedns.ResourceTencentCloudPrivateDnsZoneVpcAttachment(),
1686+
"tencentcloud_subscribe_private_zone_service": privatedns.ResourceTencentCloudSubscribePrivateZoneService(),
16861687
"tencentcloud_cls_logset": cls.ResourceTencentCloudClsLogset(),
16871688
"tencentcloud_cls_topic": cls.ResourceTencentCloudClsTopic(),
16881689
"tencentcloud_cls_config": cls.ResourceTencentCloudClsConfig(),

tencentcloud/provider.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,6 +1348,7 @@ PrivateDNS
13481348
tencentcloud_private_dns_zone
13491349
tencentcloud_private_dns_record
13501350
tencentcloud_private_dns_zone_vpc_attachment
1351+
tencentcloud_subscribe_private_zone_service
13511352
Data Source
13521353
tencentcloud_private_dns_records
13531354
tencentcloud_private_dns_private_zone_list
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
package privatedns
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"log"
7+
8+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
9+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
10+
privatedns "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/privatedns/v20201028"
11+
12+
tccommon "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/common"
13+
)
14+
15+
func ResourceTencentCloudSubscribePrivateZoneService() *schema.Resource {
16+
return &schema.Resource{
17+
Create: resourceTencentCloudSubscribePrivateZoneServiceCreate,
18+
Read: resourceTencentCloudSubscribePrivateZoneServiceRead,
19+
Delete: resourceTencentCloudSubscribePrivateZoneServiceDelete,
20+
Schema: map[string]*schema.Schema{
21+
"service_status": {
22+
Type: schema.TypeString,
23+
Computed: true,
24+
Description: "Private domain resolution service activation status.",
25+
},
26+
},
27+
}
28+
}
29+
30+
func resourceTencentCloudSubscribePrivateZoneServiceCreate(d *schema.ResourceData, meta interface{}) error {
31+
defer tccommon.LogElapsed("resource.tencentcloud_subscribe_private_zone_service.create")()
32+
defer tccommon.InconsistentCheck(d, meta)()
33+
34+
var (
35+
logId = tccommon.GetLogId(tccommon.ContextNil)
36+
ctx = tccommon.NewResourceLifeCycleHandleFuncContext(context.Background(), logId, d, meta)
37+
request = privatedns.NewSubscribePrivateZoneServiceRequest()
38+
response = privatedns.NewSubscribePrivateZoneServiceResponse()
39+
)
40+
41+
err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
42+
result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UsePrivateDnsClient().SubscribePrivateZoneServiceWithContext(ctx, request)
43+
if e != nil {
44+
return tccommon.RetryError(e)
45+
} else {
46+
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString())
47+
}
48+
49+
if result == nil || result.Response == nil {
50+
e = fmt.Errorf("create subscribe private zone service failed.")
51+
return resource.NonRetryableError(e)
52+
}
53+
54+
response = result
55+
return nil
56+
})
57+
58+
if err != nil {
59+
log.Printf("[CRITAL]%s create subscribe private zone service failed, reason:%+v", logId, err)
60+
return err
61+
}
62+
63+
if response.Response.ServiceStatus != nil {
64+
_ = d.Set("service_status", response.Response.ServiceStatus)
65+
}
66+
67+
d.SetId(*response.Response.RequestId)
68+
69+
return resourceTencentCloudSubscribePrivateZoneServiceRead(d, meta)
70+
}
71+
72+
func resourceTencentCloudSubscribePrivateZoneServiceRead(d *schema.ResourceData, meta interface{}) error {
73+
defer tccommon.LogElapsed("resource.tencentcloud_subscribe_private_zone_service.read")()
74+
defer tccommon.InconsistentCheck(d, meta)()
75+
76+
return nil
77+
}
78+
79+
func resourceTencentCloudSubscribePrivateZoneServiceDelete(d *schema.ResourceData, meta interface{}) error {
80+
defer tccommon.LogElapsed("resource.tencentcloud_subscribe_private_zone_service.delete")()
81+
defer tccommon.InconsistentCheck(d, meta)()
82+
83+
return nil
84+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Provides a resource to create a privatedns subscribe private zone service
2+
3+
Example Usage
4+
5+
```hcl
6+
resource "tencentcloud_subscribe_private_zone_service" "example" {}
7+
```
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package privatedns_test
2+
3+
import (
4+
"testing"
5+
6+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
7+
8+
tcacctest "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/acctest"
9+
)
10+
11+
func TestAccTencentCloudSubscribePrivateZoneServiceResource_basic(t *testing.T) {
12+
t.Parallel()
13+
resource.Test(t, resource.TestCase{
14+
PreCheck: func() {
15+
tcacctest.AccPreCheck(t)
16+
},
17+
Providers: tcacctest.AccProviders,
18+
Steps: []resource.TestStep{{
19+
Config: testAccSubscribePrivateZoneService,
20+
Check: resource.ComposeTestCheckFunc(
21+
resource.TestCheckResourceAttrSet("tencentcloud_subscribe_private_zone_service.example", "id"),
22+
),
23+
}},
24+
})
25+
}
26+
27+
const testAccSubscribePrivateZoneService = `
28+
resource "tencentcloud_subscribe_private_zone_service" "example" {}
29+
`
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
subcategory: "PrivateDNS"
3+
layout: "tencentcloud"
4+
page_title: "TencentCloud: tencentcloud_subscribe_private_zone_service"
5+
sidebar_current: "docs-tencentcloud-resource-subscribe_private_zone_service"
6+
description: |-
7+
Provides a resource to create a privatedns subscribe private zone service
8+
---
9+
10+
# tencentcloud_subscribe_private_zone_service
11+
12+
Provides a resource to create a privatedns subscribe private zone service
13+
14+
## Example Usage
15+
16+
```hcl
17+
resource "tencentcloud_subscribe_private_zone_service" "example" {}
18+
```
19+
20+
## Argument Reference
21+
22+
The following arguments are supported:
23+
24+
25+
26+
## Attributes Reference
27+
28+
In addition to all arguments above, the following attributes are exported:
29+
30+
* `id` - ID of the resource.
31+
* `service_status` - Private domain resolution service activation status.
32+
33+

website/tencentcloud.erb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3185,6 +3185,9 @@
31853185
<li>
31863186
<a href="/docs/providers/tencentcloud/r/private_dns_zone_vpc_attachment.html">tencentcloud_private_dns_zone_vpc_attachment</a>
31873187
</li>
3188+
<li>
3189+
<a href="/docs/providers/tencentcloud/r/subscribe_private_zone_service.html">tencentcloud_subscribe_private_zone_service</a>
3190+
</li>
31883191
</ul>
31893192
</li>
31903193
</ul>

0 commit comments

Comments
 (0)