Skip to content

feat(privatedns): [120490271] Add new resource tencentcloud_subscribe_private_zone_service #2929

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 1, 2024
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/2929.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:new-resource
tencentcloud_subscribe_private_zone_service
```
1 change: 1 addition & 0 deletions tencentcloud/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -1683,6 +1683,7 @@ func Provider() *schema.Provider {
"tencentcloud_private_dns_zone": privatedns.ResourceTencentCloudPrivateDnsZone(),
"tencentcloud_private_dns_record": privatedns.ResourceTencentCloudPrivateDnsRecord(),
"tencentcloud_private_dns_zone_vpc_attachment": privatedns.ResourceTencentCloudPrivateDnsZoneVpcAttachment(),
"tencentcloud_subscribe_private_zone_service": privatedns.ResourceTencentCloudSubscribePrivateZoneService(),
"tencentcloud_cls_logset": cls.ResourceTencentCloudClsLogset(),
"tencentcloud_cls_topic": cls.ResourceTencentCloudClsTopic(),
"tencentcloud_cls_config": cls.ResourceTencentCloudClsConfig(),
Expand Down
1 change: 1 addition & 0 deletions tencentcloud/provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -1348,6 +1348,7 @@ PrivateDNS
tencentcloud_private_dns_zone
tencentcloud_private_dns_record
tencentcloud_private_dns_zone_vpc_attachment
tencentcloud_subscribe_private_zone_service
Data Source
tencentcloud_private_dns_records
tencentcloud_private_dns_private_zone_list
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package privatedns

import (
"context"
"fmt"
"log"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
privatedns "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/privatedns/v20201028"

tccommon "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/common"
)

func ResourceTencentCloudSubscribePrivateZoneService() *schema.Resource {
return &schema.Resource{
Create: resourceTencentCloudSubscribePrivateZoneServiceCreate,
Read: resourceTencentCloudSubscribePrivateZoneServiceRead,
Delete: resourceTencentCloudSubscribePrivateZoneServiceDelete,
Schema: map[string]*schema.Schema{
"service_status": {
Type: schema.TypeString,
Computed: true,
Description: "Private domain resolution service activation status.",
},
},
}
}

func resourceTencentCloudSubscribePrivateZoneServiceCreate(d *schema.ResourceData, meta interface{}) error {
defer tccommon.LogElapsed("resource.tencentcloud_subscribe_private_zone_service.create")()
defer tccommon.InconsistentCheck(d, meta)()

var (
logId = tccommon.GetLogId(tccommon.ContextNil)
ctx = tccommon.NewResourceLifeCycleHandleFuncContext(context.Background(), logId, d, meta)
request = privatedns.NewSubscribePrivateZoneServiceRequest()
response = privatedns.NewSubscribePrivateZoneServiceResponse()
)

err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UsePrivateDnsClient().SubscribePrivateZoneServiceWithContext(ctx, request)
if e != nil {
return tccommon.RetryError(e)
} else {
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString())
}

if result == nil || result.Response == nil {
e = fmt.Errorf("create subscribe private zone service failed.")
return resource.NonRetryableError(e)
}

response = result
return nil
})

if err != nil {
log.Printf("[CRITAL]%s create subscribe private zone service failed, reason:%+v", logId, err)
return err
}

if response.Response.ServiceStatus != nil {
_ = d.Set("service_status", response.Response.ServiceStatus)
}

d.SetId(*response.Response.RequestId)

return resourceTencentCloudSubscribePrivateZoneServiceRead(d, meta)
}

func resourceTencentCloudSubscribePrivateZoneServiceRead(d *schema.ResourceData, meta interface{}) error {
defer tccommon.LogElapsed("resource.tencentcloud_subscribe_private_zone_service.read")()
defer tccommon.InconsistentCheck(d, meta)()

return nil
}

func resourceTencentCloudSubscribePrivateZoneServiceDelete(d *schema.ResourceData, meta interface{}) error {
defer tccommon.LogElapsed("resource.tencentcloud_subscribe_private_zone_service.delete")()
defer tccommon.InconsistentCheck(d, meta)()

return nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Provides a resource to create a privatedns subscribe private zone service

Example Usage

```hcl
resource "tencentcloud_subscribe_private_zone_service" "example" {}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package privatedns_test

import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"

tcacctest "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/acctest"
)

func TestAccTencentCloudSubscribePrivateZoneServiceResource_basic(t *testing.T) {
t.Parallel()
resource.Test(t, resource.TestCase{
PreCheck: func() {
tcacctest.AccPreCheck(t)
},
Providers: tcacctest.AccProviders,
Steps: []resource.TestStep{{
Config: testAccSubscribePrivateZoneService,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet("tencentcloud_subscribe_private_zone_service.example", "id"),
),
}},
})
}

const testAccSubscribePrivateZoneService = `
resource "tencentcloud_subscribe_private_zone_service" "example" {}
`
33 changes: 33 additions & 0 deletions website/docs/r/subscribe_private_zone_service.html.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
subcategory: "PrivateDNS"
layout: "tencentcloud"
page_title: "TencentCloud: tencentcloud_subscribe_private_zone_service"
sidebar_current: "docs-tencentcloud-resource-subscribe_private_zone_service"
description: |-
Provides a resource to create a privatedns subscribe private zone service
---

# tencentcloud_subscribe_private_zone_service

Provides a resource to create a privatedns subscribe private zone service

## Example Usage

```hcl
resource "tencentcloud_subscribe_private_zone_service" "example" {}
```

## Argument Reference

The following arguments are supported:



## Attributes Reference

In addition to all arguments above, the following attributes are exported:

* `id` - ID of the resource.
* `service_status` - Private domain resolution service activation status.


3 changes: 3 additions & 0 deletions website/tencentcloud.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3185,6 +3185,9 @@
<li>
<a href="/docs/providers/tencentcloud/r/private_dns_zone_vpc_attachment.html">tencentcloud_private_dns_zone_vpc_attachment</a>
</li>
<li>
<a href="/docs/providers/tencentcloud/r/subscribe_private_zone_service.html">tencentcloud_subscribe_private_zone_service</a>
</li>
</ul>
</li>
</ul>
Expand Down
Loading