@@ -3,6 +3,8 @@ Provides a resource to create a cfs auto_snapshot_policy
33
44Example Usage
55
6+ use day of week
7+
68```hcl
79resource "tencentcloud_cfs_auto_snapshot_policy" "auto_snapshot_policy" {
810 day_of_week = "1,2"
@@ -12,6 +14,29 @@ resource "tencentcloud_cfs_auto_snapshot_policy" "auto_snapshot_policy" {
1214}
1315```
1416
17+ use day of month
18+
19+ ```hcl
20+ resource "tencentcloud_cfs_auto_snapshot_policy" "auto_snapshot_policy" {
21+ hour = "2,3"
22+ policy_name = "policy_name"
23+ alive_days = 7
24+ day_of_month = "2,3,4"
25+ }
26+ ```
27+
28+ use interval days
29+
30+ ```hcl
31+ resource "tencentcloud_cfs_auto_snapshot_policy" "auto_snapshot_policy" {
32+ hour = "2,3"
33+ policy_name = "policy_name"
34+ alive_days = 7
35+ interval_days = 1
36+ }
37+ ```
38+
39+
1540Import
1641
1742cfs auto_snapshot_policy can be imported using the id, e.g.
@@ -43,12 +68,6 @@ func resourceTencentCloudCfsAutoSnapshotPolicy() *schema.Resource {
4368 State : schema .ImportStatePassthrough ,
4469 },
4570 Schema : map [string ]* schema.Schema {
46- "day_of_week" : {
47- Required : true ,
48- Type : schema .TypeString ,
49- Description : "The day of the week on which to repeat the snapshot operation." ,
50- },
51-
5271 "hour" : {
5372 Required : true ,
5473 Type : schema .TypeString ,
@@ -61,11 +80,29 @@ func resourceTencentCloudCfsAutoSnapshotPolicy() *schema.Resource {
6180 Description : "Policy name." ,
6281 },
6382
83+ "day_of_week" : {
84+ Optional : true ,
85+ Type : schema .TypeString ,
86+ Description : "The day of the week on which to repeat the snapshot operation." ,
87+ },
88+
6489 "alive_days" : {
6590 Optional : true ,
6691 Type : schema .TypeInt ,
6792 Description : "Snapshot retention period." ,
6893 },
94+
95+ "day_of_month" : {
96+ Optional : true ,
97+ Type : schema .TypeString ,
98+ Description : "The specific day (day 1 to day 31) of the month on which to create a snapshot." ,
99+ },
100+
101+ "interval_days" : {
102+ Optional : true ,
103+ Type : schema .TypeInt ,
104+ Description : "The snapshot interval, in days." ,
105+ },
69106 },
70107 }
71108}
@@ -93,10 +130,18 @@ func resourceTencentCloudCfsAutoSnapshotPolicyCreate(d *schema.ResourceData, met
93130 request .PolicyName = helper .String (v .(string ))
94131 }
95132
96- if v , _ := d .GetOk ("alive_days" ); v != nil {
133+ if v , ok := d .GetOkExists ("alive_days" ); ok {
97134 request .AliveDays = helper .IntUint64 (v .(int ))
98135 }
99136
137+ if v , ok := d .GetOk ("day_of_month" ); ok {
138+ request .DayOfMonth = helper .String (v .(string ))
139+ }
140+
141+ if v , ok := d .GetOkExists ("interval_days" ); ok {
142+ request .IntervalDays = helper .IntUint64 (v .(int ))
143+ }
144+
100145 err := resource .Retry (writeRetryTimeout , func () * resource.RetryError {
101146 result , e := meta .(* TencentCloudClient ).apiV3Conn .UseCfsClient ().CreateAutoSnapshotPolicy (request )
102147 if e != nil {
@@ -156,6 +201,14 @@ func resourceTencentCloudCfsAutoSnapshotPolicyRead(d *schema.ResourceData, meta
156201 _ = d .Set ("alive_days" , autoSnapshotPolicy .AliveDays )
157202 }
158203
204+ if autoSnapshotPolicy .DayOfMonth != nil {
205+ _ = d .Set ("day_of_month" , autoSnapshotPolicy .DayOfMonth )
206+ }
207+
208+ if autoSnapshotPolicy .IntervalDays != nil {
209+ _ = d .Set ("interval_days" , autoSnapshotPolicy .IntervalDays )
210+ }
211+
159212 return nil
160213}
161214
@@ -189,11 +242,23 @@ func resourceTencentCloudCfsAutoSnapshotPolicyUpdate(d *schema.ResourceData, met
189242 }
190243
191244 if d .HasChange ("alive_days" ) {
192- if v , _ := d .GetOk ("alive_days" ); v != nil {
245+ if v , ok := d .GetOkExists ("alive_days" ); ok {
193246 request .AliveDays = helper .IntUint64 (v .(int ))
194247 }
195248 }
196249
250+ if d .HasChange ("day_of_month" ) {
251+ if v , ok := d .GetOk ("day_of_month" ); ok {
252+ request .DayOfMonth = helper .String (v .(string ))
253+ }
254+ }
255+
256+ if d .HasChange ("interval_days" ) {
257+ if v , ok := d .GetOkExists ("interval_days" ); ok {
258+ request .IntervalDays = helper .IntUint64 (v .(int ))
259+ }
260+ }
261+
197262 err := resource .Retry (writeRetryTimeout , func () * resource.RetryError {
198263 result , e := meta .(* TencentCloudClient ).apiV3Conn .UseCfsClient ().UpdateAutoSnapshotPolicy (request )
199264 if e != nil {
0 commit comments