From 3db24a4614bb2674b187f68865b8592749c41f8d Mon Sep 17 00:00:00 2001 From: SevenEarth <391613297@qq.com> Date: Mon, 3 Mar 2025 16:36:11 +0800 Subject: [PATCH 1/3] add --- .../resource_tc_cfs_auto_snapshot_policy.go | 9 +++++ .../resource_tc_cfs_auto_snapshot_policy.md | 36 +++++++++---------- .../r/cfs_auto_snapshot_policy.html.markdown | 30 ++++++++-------- 3 files changed, 42 insertions(+), 33 deletions(-) diff --git a/tencentcloud/services/cfs/resource_tc_cfs_auto_snapshot_policy.go b/tencentcloud/services/cfs/resource_tc_cfs_auto_snapshot_policy.go index e785c70975..d8828345c7 100644 --- a/tencentcloud/services/cfs/resource_tc_cfs_auto_snapshot_policy.go +++ b/tencentcloud/services/cfs/resource_tc_cfs_auto_snapshot_policy.go @@ -105,6 +105,11 @@ func resourceTencentCloudCfsAutoSnapshotPolicyCreate(d *schema.ResourceData, met } 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 { + return resource.NonRetryableError(fmt.Errorf("Create cfs autoSnapshotPolicy failed, Response is nil.")) + } + response = result return nil }) @@ -113,6 +118,10 @@ func resourceTencentCloudCfsAutoSnapshotPolicyCreate(d *schema.ResourceData, met return err } + if response.Response.AutoSnapshotPolicyId == nil { + return fmt.Errorf("AutoSnapshotPolicyId is nil.") + } + autoSnapshotPolicyId = *response.Response.AutoSnapshotPolicyId d.SetId(autoSnapshotPolicyId) diff --git a/tencentcloud/services/cfs/resource_tc_cfs_auto_snapshot_policy.md b/tencentcloud/services/cfs/resource_tc_cfs_auto_snapshot_policy.md index 0be407d196..7c986cd06f 100644 --- a/tencentcloud/services/cfs/resource_tc_cfs_auto_snapshot_policy.md +++ b/tencentcloud/services/cfs/resource_tc_cfs_auto_snapshot_policy.md @@ -1,44 +1,44 @@ -Provides a resource to create a cfs auto_snapshot_policy +Provides a resource to create a cfs auto snapshot policy Example Usage -use day of week +Use day of week ```hcl -resource "tencentcloud_cfs_auto_snapshot_policy" "auto_snapshot_policy" { +resource "tencentcloud_cfs_auto_snapshot_policy" "example" { + policy_name = "tf-example" day_of_week = "1,2" - hour = "2,3" - policy_name = "policy_name" - alive_days = 7 + hour = "2,3" + alive_days = 7 } ``` -use day of month +Use day of month ```hcl -resource "tencentcloud_cfs_auto_snapshot_policy" "auto_snapshot_policy" { - hour = "2,3" - policy_name = "policy_name" - alive_days = 7 +resource "tencentcloud_cfs_auto_snapshot_policy" "example" { + policy_name = "tf-example" day_of_month = "2,3,4" + hour = "2,3" + alive_days = 7 } ``` -use interval days +Use interval days ```hcl -resource "tencentcloud_cfs_auto_snapshot_policy" "auto_snapshot_policy" { - hour = "2,3" - policy_name = "policy_name" - alive_days = 7 +resource "tencentcloud_cfs_auto_snapshot_policy" "example" { + policy_name = "policy_name" interval_days = 1 + hour = "2,3" + alive_days = 7 } ``` Import -cfs auto_snapshot_policy can be imported using the id, e.g. +cfs auto snapshot policy can be imported using the id, e.g. ``` -terraform import tencentcloud_cfs_auto_snapshot_policy.auto_snapshot_policy auto_snapshot_policy_id +terraform import tencentcloud_cfs_auto_snapshot_policy.example asp-f8q793kj ``` \ No newline at end of file diff --git a/website/docs/r/cfs_auto_snapshot_policy.html.markdown b/website/docs/r/cfs_auto_snapshot_policy.html.markdown index 3713416278..19bb2cdf36 100644 --- a/website/docs/r/cfs_auto_snapshot_policy.html.markdown +++ b/website/docs/r/cfs_auto_snapshot_policy.html.markdown @@ -4,45 +4,45 @@ layout: "tencentcloud" page_title: "TencentCloud: tencentcloud_cfs_auto_snapshot_policy" sidebar_current: "docs-tencentcloud-resource-cfs_auto_snapshot_policy" description: |- - Provides a resource to create a cfs auto_snapshot_policy + Provides a resource to create a cfs auto snapshot policy --- # tencentcloud_cfs_auto_snapshot_policy -Provides a resource to create a cfs auto_snapshot_policy +Provides a resource to create a cfs auto snapshot policy ## Example Usage -### use day of week +### Use day of week ```hcl -resource "tencentcloud_cfs_auto_snapshot_policy" "auto_snapshot_policy" { +resource "tencentcloud_cfs_auto_snapshot_policy" "example" { + policy_name = "tf-example" day_of_week = "1,2" hour = "2,3" - policy_name = "policy_name" alive_days = 7 } ``` -### use day of month +### Use day of month ```hcl -resource "tencentcloud_cfs_auto_snapshot_policy" "auto_snapshot_policy" { +resource "tencentcloud_cfs_auto_snapshot_policy" "example" { + policy_name = "tf-example" + day_of_month = "2,3,4" hour = "2,3" - policy_name = "policy_name" alive_days = 7 - day_of_month = "2,3,4" } ``` -### use interval days +### Use interval days ```hcl -resource "tencentcloud_cfs_auto_snapshot_policy" "auto_snapshot_policy" { - hour = "2,3" +resource "tencentcloud_cfs_auto_snapshot_policy" "example" { policy_name = "policy_name" - alive_days = 7 interval_days = 1 + hour = "2,3" + alive_days = 7 } ``` @@ -67,9 +67,9 @@ In addition to all arguments above, the following attributes are exported: ## Import -cfs auto_snapshot_policy can be imported using the id, e.g. +cfs auto snapshot policy can be imported using the id, e.g. ``` -terraform import tencentcloud_cfs_auto_snapshot_policy.auto_snapshot_policy auto_snapshot_policy_id +terraform import tencentcloud_cfs_auto_snapshot_policy.example asp-f8q793kj ``` From de48bf4cb8393ba9c7e4737b6a7a45d37353b43f Mon Sep 17 00:00:00 2001 From: SevenEarth <391613297@qq.com> Date: Mon, 3 Mar 2025 16:37:46 +0800 Subject: [PATCH 2/3] add --- .changelog/3176.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/3176.txt diff --git a/.changelog/3176.txt b/.changelog/3176.txt new file mode 100644 index 0000000000..19da5bfb78 --- /dev/null +++ b/.changelog/3176.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/tencentcloud_cfs_auto_snapshot_policy: update doc +``` From 0fb6ae6a8ca07e24c53f3e1926c68d9ee79c200d Mon Sep 17 00:00:00 2001 From: SevenEarth <391613297@qq.com> Date: Mon, 3 Mar 2025 17:10:14 +0800 Subject: [PATCH 3/3] add --- .../services/cfs/resource_tc_cfs_auto_snapshot_policy.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tencentcloud/services/cfs/resource_tc_cfs_auto_snapshot_policy.go b/tencentcloud/services/cfs/resource_tc_cfs_auto_snapshot_policy.go index d8828345c7..d04148153b 100644 --- a/tencentcloud/services/cfs/resource_tc_cfs_auto_snapshot_policy.go +++ b/tencentcloud/services/cfs/resource_tc_cfs_auto_snapshot_policy.go @@ -32,6 +32,7 @@ func ResourceTencentCloudCfsAutoSnapshotPolicy() *schema.Resource { "policy_name": { Optional: true, + Computed: true, Type: schema.TypeString, Description: "Policy name.", }, @@ -200,10 +201,8 @@ func resourceTencentCloudCfsAutoSnapshotPolicyUpdate(d *schema.ResourceData, met } } - if d.HasChange("policy_name") { - if v, ok := d.GetOk("policy_name"); ok { - request.PolicyName = helper.String(v.(string)) - } + if v, ok := d.GetOk("policy_name"); ok { + request.PolicyName = helper.String(v.(string)) } if d.HasChange("alive_days") {