Skip to content

Commit a6c3404

Browse files
committed
add
1 parent 81f4af1 commit a6c3404

File tree

2 files changed

+117
-127
lines changed

2 files changed

+117
-127
lines changed

tencentcloud/services/cvm/resource_tc_cvm_action_timer.go

Lines changed: 115 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ package cvm
33
import (
44
"context"
55
"fmt"
6+
"log"
7+
68
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
79
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
810
cvm "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm/v20170312"
911
tccommon "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/common"
1012
"github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper"
11-
"log"
1213
)
1314

1415
func ResourceTencentCloudCvmActionTimer() *schema.Resource {
@@ -38,59 +39,61 @@ func ResourceTencentCloudCvmActionTimer() *schema.Resource {
3839
"timer_action": {
3940
Type: schema.TypeString,
4041
Optional: true,
42+
ForceNew: true,
4143
Description: "Timer action, currently only supports destroying one value: TerminateInstances.",
4244
},
4345
"action_time": {
4446
Type: schema.TypeString,
4547
Optional: true,
48+
ForceNew: true,
4649
Description: "Execution time, expressed according to ISO8601 standard and using UTC time. The format is YYYY-MM-DDThh:mm:ssZ. For example, 2018-05-29T11:26:40Z, the execution time must be 5 minutes longer than the current time.",
4750
},
48-
"externals": {
49-
Type: schema.TypeList,
50-
MaxItems: 1,
51-
Optional: true,
52-
Description: "Extended data.",
53-
Elem: &schema.Resource{
54-
Schema: map[string]*schema.Schema{
55-
"release_address": {
56-
Type: schema.TypeBool,
57-
Optional: true,
58-
Description: "Whether to release address of this instance.",
59-
},
60-
"unsupport_networks": {
61-
Type: schema.TypeSet,
62-
Elem: &schema.Schema{Type: schema.TypeString},
63-
Optional: true,
64-
Description: "Unsupported network type, Value range: BASIC - Basic Network; VPC1.0 - Private Network VPC1.0.",
65-
},
66-
"storage_block_attr": {
67-
Type: schema.TypeList,
68-
MaxItems: 1,
69-
Optional: true,
70-
Description: "HDD local storage properties.",
71-
Elem: &schema.Resource{
72-
Schema: map[string]*schema.Schema{
73-
"type": {
74-
Type: schema.TypeString,
75-
Optional: true,
76-
Description: "HDD local storage type, Value is: LOCAL_PRO.",
77-
},
78-
"min_size": {
79-
Type: schema.TypeInt,
80-
Optional: true,
81-
Description: "Minimum capacity for HDD local storage.",
82-
},
83-
"max_size": {
84-
Type: schema.TypeInt,
85-
Optional: true,
86-
Description: "Maximum capacity of HDD local storage.",
87-
},
88-
},
89-
},
90-
},
91-
},
92-
},
93-
},
51+
//"externals": {
52+
// Type: schema.TypeList,
53+
// MaxItems: 1,
54+
// Optional: true,
55+
// Description: "Extended data.",
56+
// Elem: &schema.Resource{
57+
// Schema: map[string]*schema.Schema{
58+
// "release_address": {
59+
// Type: schema.TypeBool,
60+
// Optional: true,
61+
// Description: "Whether to release address of this instance.",
62+
// },
63+
// "unsupport_networks": {
64+
// Type: schema.TypeSet,
65+
// Elem: &schema.Schema{Type: schema.TypeString},
66+
// Optional: true,
67+
// Description: "Unsupported network type, Value range: BASIC - Basic Network; VPC1.0 - Private Network VPC1.0.",
68+
// },
69+
// "storage_block_attr": {
70+
// Type: schema.TypeList,
71+
// MaxItems: 1,
72+
// Optional: true,
73+
// Description: "HDD local storage properties.",
74+
// Elem: &schema.Resource{
75+
// Schema: map[string]*schema.Schema{
76+
// "type": {
77+
// Type: schema.TypeString,
78+
// Optional: true,
79+
// Description: "HDD local storage type, Value is: LOCAL_PRO.",
80+
// },
81+
// "min_size": {
82+
// Type: schema.TypeInt,
83+
// Optional: true,
84+
// Description: "Minimum capacity for HDD local storage.",
85+
// },
86+
// "max_size": {
87+
// Type: schema.TypeInt,
88+
// Optional: true,
89+
// Description: "Maximum capacity of HDD local storage.",
90+
// },
91+
// },
92+
// },
93+
// },
94+
// },
95+
// },
96+
//},
9497
},
9598
},
9699
},
@@ -122,41 +125,41 @@ func resourceTencentCloudCvmActionTimerCreate(d *schema.ResourceData, meta inter
122125
actionTimer.ActionTime = helper.String(v.(string))
123126
}
124127

125-
if externalsMap, ok := helper.InterfaceToMap(dMap, "externals"); ok {
126-
externals := cvm.Externals{}
127-
if v, ok := externalsMap["release_address"]; ok {
128-
externals.ReleaseAddress = helper.Bool(v.(bool))
129-
}
130-
131-
if v, ok := externalsMap["unsupport_networks"]; ok {
132-
unsupportNetworksSet := v.(*schema.Set).List()
133-
for i := range unsupportNetworksSet {
134-
if unsupportNetworksSet[i] != nil {
135-
unsupportNetworks := unsupportNetworksSet[i].(string)
136-
externals.UnsupportNetworks = append(externals.UnsupportNetworks, &unsupportNetworks)
137-
}
138-
}
139-
}
140-
141-
if storageBlockAttrMap, ok := helper.InterfaceToMap(externalsMap, "storage_block_attr"); ok {
142-
storageBlock := cvm.StorageBlock{}
143-
if v, ok := storageBlockAttrMap["type"]; ok {
144-
storageBlock.Type = helper.String(v.(string))
145-
}
146-
147-
if v, ok := storageBlockAttrMap["min_size"]; ok {
148-
storageBlock.MinSize = helper.IntInt64(v.(int))
149-
}
150-
151-
if v, ok := storageBlockAttrMap["max_size"]; ok {
152-
storageBlock.MaxSize = helper.IntInt64(v.(int))
153-
}
154-
155-
externals.StorageBlockAttr = &storageBlock
156-
}
157-
158-
actionTimer.Externals = &externals
159-
}
128+
//if externalsMap, ok := helper.InterfaceToMap(dMap, "externals"); ok {
129+
// externals := cvm.Externals{}
130+
// if v, ok := externalsMap["release_address"]; ok {
131+
// externals.ReleaseAddress = helper.Bool(v.(bool))
132+
// }
133+
//
134+
// if v, ok := externalsMap["unsupport_networks"]; ok {
135+
// unsupportNetworksSet := v.(*schema.Set).List()
136+
// for i := range unsupportNetworksSet {
137+
// if unsupportNetworksSet[i] != nil {
138+
// unsupportNetworks := unsupportNetworksSet[i].(string)
139+
// externals.UnsupportNetworks = append(externals.UnsupportNetworks, &unsupportNetworks)
140+
// }
141+
// }
142+
// }
143+
//
144+
// if storageBlockAttrMap, ok := helper.InterfaceToMap(externalsMap, "storage_block_attr"); ok {
145+
// storageBlock := cvm.StorageBlock{}
146+
// if v, ok := storageBlockAttrMap["type"]; ok {
147+
// storageBlock.Type = helper.String(v.(string))
148+
// }
149+
//
150+
// if v, ok := storageBlockAttrMap["min_size"]; ok {
151+
// storageBlock.MinSize = helper.IntInt64(v.(int))
152+
// }
153+
//
154+
// if v, ok := storageBlockAttrMap["max_size"]; ok {
155+
// storageBlock.MaxSize = helper.IntInt64(v.(int))
156+
// }
157+
//
158+
// externals.StorageBlockAttr = &storageBlock
159+
// }
160+
//
161+
// actionTimer.Externals = &externals
162+
//}
160163

161164
request.ActionTimer = &actionTimer
162165
}
@@ -219,36 +222,36 @@ func resourceTencentCloudCvmActionTimerRead(d *schema.ResourceData, meta interfa
219222
actionTimerMap["action_time"] = InstanceActionTimer.ActionTime
220223
}
221224

222-
actionTimerMap["externals"] = []interface{}{}
223-
if InstanceActionTimer.Externals != nil {
224-
externalsMap := map[string]interface{}{}
225-
if InstanceActionTimer.Externals.ReleaseAddress != nil {
226-
externalsMap["release_address"] = InstanceActionTimer.Externals.ReleaseAddress
227-
}
228-
229-
if InstanceActionTimer.Externals.UnsupportNetworks != nil {
230-
externalsMap["unsupport_networks"] = InstanceActionTimer.Externals.UnsupportNetworks
231-
}
232-
233-
if InstanceActionTimer.Externals.StorageBlockAttr != nil {
234-
storageBlockAttrMap := map[string]interface{}{}
235-
if InstanceActionTimer.Externals.StorageBlockAttr.Type != nil {
236-
storageBlockAttrMap["type"] = InstanceActionTimer.Externals.StorageBlockAttr.Type
237-
}
238-
239-
if InstanceActionTimer.Externals.StorageBlockAttr.MinSize != nil {
240-
storageBlockAttrMap["min_size"] = InstanceActionTimer.Externals.StorageBlockAttr.MinSize
241-
}
242-
243-
if InstanceActionTimer.Externals.StorageBlockAttr.MaxSize != nil {
244-
storageBlockAttrMap["max_size"] = InstanceActionTimer.Externals.StorageBlockAttr.MaxSize
245-
}
246-
247-
externalsMap["storage_block_attr"] = []interface{}{storageBlockAttrMap}
248-
}
249-
250-
actionTimerMap["externals"] = []interface{}{externalsMap}
251-
}
225+
//actionTimerMap["externals"] = []interface{}{}
226+
//if InstanceActionTimer.Externals != nil {
227+
// externalsMap := map[string]interface{}{}
228+
// if InstanceActionTimer.Externals.ReleaseAddress != nil {
229+
// externalsMap["release_address"] = InstanceActionTimer.Externals.ReleaseAddress
230+
// }
231+
//
232+
// if InstanceActionTimer.Externals.UnsupportNetworks != nil {
233+
// externalsMap["unsupport_networks"] = InstanceActionTimer.Externals.UnsupportNetworks
234+
// }
235+
//
236+
// if InstanceActionTimer.Externals.StorageBlockAttr != nil {
237+
// storageBlockAttrMap := map[string]interface{}{}
238+
// if InstanceActionTimer.Externals.StorageBlockAttr.Type != nil {
239+
// storageBlockAttrMap["type"] = InstanceActionTimer.Externals.StorageBlockAttr.Type
240+
// }
241+
//
242+
// if InstanceActionTimer.Externals.StorageBlockAttr.MinSize != nil {
243+
// storageBlockAttrMap["min_size"] = InstanceActionTimer.Externals.StorageBlockAttr.MinSize
244+
// }
245+
//
246+
// if InstanceActionTimer.Externals.StorageBlockAttr.MaxSize != nil {
247+
// storageBlockAttrMap["max_size"] = InstanceActionTimer.Externals.StorageBlockAttr.MaxSize
248+
// }
249+
//
250+
// externalsMap["storage_block_attr"] = []interface{}{storageBlockAttrMap}
251+
// }
252+
//
253+
// actionTimerMap["externals"] = []interface{}{externalsMap}
254+
//}
252255

253256
_ = d.Set("action_timer", []interface{}{actionTimerMap})
254257

website/docs/r/cvm_action_timer.html.markdown

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -82,21 +82,8 @@ The following arguments are supported:
8282

8383
The `action_timer` object supports the following:
8484

85-
* `action_time` - (Optional, String) Execution time, expressed according to ISO8601 standard and using UTC time. The format is YYYY-MM-DDThh:mm:ssZ. For example, 2018-05-29T11:26:40Z, the execution time must be 5 minutes longer than the current time.
86-
* `externals` - (Optional, List) Extended data.
87-
* `timer_action` - (Optional, String) Timer action, currently only supports destroying one value: TerminateInstances.
88-
89-
The `externals` object of `action_timer` supports the following:
90-
91-
* `release_address` - (Optional, Bool) Whether to release address of this instance.
92-
* `storage_block_attr` - (Optional, List) HDD local storage properties.
93-
* `unsupport_networks` - (Optional, Set) Unsupported network type, Value range: BASIC - Basic Network; VPC1.0 - Private Network VPC1.0.
94-
95-
The `storage_block_attr` object of `externals` supports the following:
96-
97-
* `max_size` - (Optional, Int) Maximum capacity of HDD local storage.
98-
* `min_size` - (Optional, Int) Minimum capacity for HDD local storage.
99-
* `type` - (Optional, String) HDD local storage type, Value is: LOCAL_PRO.
85+
* `action_time` - (Optional, String, ForceNew) Execution time, expressed according to ISO8601 standard and using UTC time. The format is YYYY-MM-DDThh:mm:ssZ. For example, 2018-05-29T11:26:40Z, the execution time must be 5 minutes longer than the current time.
86+
* `timer_action` - (Optional, String, ForceNew) Timer action, currently only supports destroying one value: TerminateInstances.
10087

10188
## Attributes Reference
10289

0 commit comments

Comments
 (0)