@@ -5,15 +5,17 @@ Example Usage
55
66```hcl
77resource "tencentcloud_chdfs_life_cycle_rule" "life_cycle_rule" {
8- file_system_id = "xxxx"
8+ file_system_id = "f14mpfy5lh4e"
9+
910 life_cycle_rule {
10- life_cycle_rule_name = "test"
11- path = "/"
11+ life_cycle_rule_name = "terraform-test"
12+ path = "/test"
13+ status = 1
14+
1215 transitions {
13- days = 1
16+ days = 30
1417 type = 1
1518 }
16- status = 1
1719 }
1820}
1921```
@@ -121,10 +123,9 @@ func resourceTencentCloudChdfsLifeCycleRuleCreate(d *schema.ResourceData, meta i
121123 logId := getLogId (contextNil )
122124
123125 var (
124- request = chdfs .NewCreateLifeCycleRulesRequest ()
125- //response = chdfs.NewCreateLifeCycleRulesResponse()
126- fileSystemId string
127- lifeCycleRuleId uint64
126+ request = chdfs .NewCreateLifeCycleRulesRequest ()
127+ fileSystemId string
128+ path string
128129 )
129130 if v , ok := d .GetOk ("file_system_id" ); ok {
130131 fileSystemId = v .(string )
@@ -137,6 +138,7 @@ func resourceTencentCloudChdfsLifeCycleRuleCreate(d *schema.ResourceData, meta i
137138 lifeCycleRule .LifeCycleRuleName = helper .String (v .(string ))
138139 }
139140 if v , ok := dMap ["path" ]; ok {
141+ path = v .(string )
140142 lifeCycleRule .Path = helper .String (v .(string ))
141143 }
142144 if v , ok := dMap ["transitions" ]; ok {
@@ -173,7 +175,14 @@ func resourceTencentCloudChdfsLifeCycleRuleCreate(d *schema.ResourceData, meta i
173175 return err
174176 }
175177
176- d .SetId (fileSystemId + FILED_SP + helper .UInt64ToStr (lifeCycleRuleId ))
178+ ctx := context .WithValue (context .TODO (), logIdKey , logId )
179+ service := ChdfsService {client : meta .(* TencentCloudClient ).apiV3Conn }
180+ lifeCycleRule , err := service .DescribeChdfsLifeCycleRuleByPath (ctx , fileSystemId , path )
181+ if err != nil {
182+ return err
183+ }
184+
185+ d .SetId (fileSystemId + FILED_SP + helper .UInt64ToStr (* lifeCycleRule .LifeCycleRuleId ))
177186
178187 return resourceTencentCloudChdfsLifeCycleRuleRead (d , meta )
179188}
@@ -239,7 +248,7 @@ func resourceTencentCloudChdfsLifeCycleRuleRead(d *schema.ResourceData, meta int
239248 transitionsList = append (transitionsList , transitionsMap )
240249 }
241250
242- lifeCycleRuleMap ["transitions" ] = [] interface {}{ transitionsList }
251+ lifeCycleRuleMap ["transitions" ] = transitionsList
243252 }
244253
245254 if lifeCycleRule .Status != nil {
0 commit comments