Skip to content

Commit d3c9dce

Browse files
authored
feat(tke): [119722168] add lifecycle_transition_type (#2943)
* add lifecycle_transition_type * add lifecycle_transition_type * add lifecycle_transition_type
1 parent 7b449eb commit d3c9dce

6 files changed

+48
-21
lines changed

.changelog/2943.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
resource/tencentcloud_as_lifecycle_hook: add `lifecycle_transition_type`
3+
```

tencentcloud/services/as/resource_tc_as_lifecycle_hook.go

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ func ResourceTencentCloudAsLifecycleHook() *schema.Resource {
7777
Optional: true,
7878
Description: "For CMQ_TOPIC type, a name of topic must be set.",
7979
},
80+
"lifecycle_transition_type": {
81+
Type: schema.TypeString,
82+
Optional: true,
83+
Computed: true,
84+
Description: "The scenario where the lifecycle hook is applied. `EXTENSION`: the lifecycle hook will be triggered when AttachInstances, DetachInstances or RemoveInstaces is called. `NORMAL`: the lifecycle hook is not triggered by the above APIs.",
85+
},
8086
"lifecycle_command": {
8187
Type: schema.TypeList,
8288
MaxItems: 1,
@@ -122,6 +128,9 @@ func resourceTencentCloudAsLifecycleHookCreate(d *schema.ResourceData, meta inte
122128
if v, ok := d.GetOk("notification_metadata"); ok {
123129
request.NotificationMetadata = helper.String(v.(string))
124130
}
131+
if v, ok := d.GetOk("lifecycle_transition_type"); ok {
132+
request.LifecycleTransitionType = helper.String(v.(string))
133+
}
125134
if v, ok := d.GetOk("notification_target_type"); ok {
126135
request.NotificationTarget = &as.NotificationTarget{}
127136
request.NotificationTarget.TargetType = helper.String(v.(string))
@@ -200,6 +209,9 @@ func resourceTencentCloudAsLifecycleHookRead(d *schema.ResourceData, meta interf
200209
if lifecycleHook.NotificationMetadata != nil {
201210
_ = d.Set("notification_metadata", *lifecycleHook.NotificationMetadata)
202211
}
212+
if lifecycleHook.LifecycleTransitionType != nil {
213+
_ = d.Set("lifecycle_transition_type", *lifecycleHook.LifecycleTransitionType)
214+
}
203215
if lifecycleHook.NotificationTarget != nil {
204216
_ = d.Set("notification_target_type", *lifecycleHook.NotificationTarget.TargetType)
205217
if lifecycleHook.NotificationTarget.QueueName != nil {
@@ -247,6 +259,9 @@ func resourceTencentCloudAsLifecycleHookUpdate(d *schema.ResourceData, meta inte
247259
if v, ok := d.GetOk("notification_metadata"); ok {
248260
request.NotificationMetadata = helper.String(v.(string))
249261
}
262+
if v, ok := d.GetOk("lifecycle_transition_type"); ok {
263+
request.LifecycleTransitionType = helper.String(v.(string))
264+
}
250265
if v, ok := d.GetOk("notification_target_type"); ok {
251266
request.NotificationTarget = &as.NotificationTarget{}
252267
request.NotificationTarget.TargetType = helper.String(v.(string))
@@ -265,15 +280,17 @@ func resourceTencentCloudAsLifecycleHookUpdate(d *schema.ResourceData, meta inte
265280
}
266281
}
267282

268-
if dMap, ok := helper.InterfacesHeadMap(d, "lifecycle_command"); ok {
269-
lifecycleCommand := as.LifecycleCommand{}
270-
if v, ok := dMap["command_id"]; ok {
271-
lifecycleCommand.CommandId = helper.String(v.(string))
272-
}
273-
if v, ok := dMap["parameters"]; ok {
274-
lifecycleCommand.Parameters = helper.String(v.(string))
283+
if d.HasChange("lifecycle_command") {
284+
if dMap, ok := helper.InterfacesHeadMap(d, "lifecycle_command"); ok {
285+
lifecycleCommand := as.LifecycleCommand{}
286+
if v, ok := dMap["command_id"]; ok && v != "" {
287+
lifecycleCommand.CommandId = helper.String(v.(string))
288+
}
289+
if v, ok := dMap["parameters"]; ok && v != "" {
290+
lifecycleCommand.Parameters = helper.String(v.(string))
291+
}
292+
request.LifecycleCommand = &lifecycleCommand
275293
}
276-
request.LifecycleCommand = &lifecycleCommand
277294
}
278295

279296
response, err := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseAsClient().UpgradeLifecycleHook(request)

tencentcloud/services/as/resource_tc_as_lifecycle_hook.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,14 @@ resource "tencentcloud_as_scaling_group" "example" {
4545
}
4646
4747
resource "tencentcloud_as_lifecycle_hook" "example" {
48-
scaling_group_id = tencentcloud_as_scaling_group.example.id
49-
lifecycle_hook_name = "tf-as-lifecycle-hook"
50-
lifecycle_transition = "INSTANCE_LAUNCHING"
51-
default_result = "CONTINUE"
52-
heartbeat_timeout = 500
53-
notification_metadata = "tf test"
48+
scaling_group_id = tencentcloud_as_scaling_group.example.id
49+
lifecycle_hook_name = "tf-as-lifecycle-hook"
50+
lifecycle_transition = "INSTANCE_LAUNCHING"
51+
default_result = "CONTINUE"
52+
heartbeat_timeout = 500
53+
lifecycle_transition_type = "NORMAL"
54+
# lifecycle_transition_type = "EXTENSION"
55+
notification_metadata = "tf test"
5456
}
5557
```
5658

tencentcloud/services/as/resource_tc_as_start_instance_refresh.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ Example Usage
44

55
```hcl
66
resource "tencentcloud_as_start_instance_refresh" "example" {
7-
auto_scaling_group_id = "asg-9dn1a5y6"
7+
auto_scaling_group_id = "asg-8n7fdm28"
88
refresh_mode = "ROLLING_UPDATE_RESET"
99
refresh_settings {
1010
check_instance_target_health = false
1111
rolling_update_settings {
1212
batch_number = 1
1313
batch_pause = "AUTOMATIC"
14+
max_surge = 1
1415
}
1516
}
1617
}

website/docs/r/as_lifecycle_hook.html.markdown

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,13 @@ resource "tencentcloud_as_scaling_group" "example" {
5656
}
5757
5858
resource "tencentcloud_as_lifecycle_hook" "example" {
59-
scaling_group_id = tencentcloud_as_scaling_group.example.id
60-
lifecycle_hook_name = "tf-as-lifecycle-hook"
61-
lifecycle_transition = "INSTANCE_LAUNCHING"
62-
default_result = "CONTINUE"
63-
heartbeat_timeout = 500
59+
scaling_group_id = tencentcloud_as_scaling_group.example.id
60+
lifecycle_hook_name = "tf-as-lifecycle-hook"
61+
lifecycle_transition = "INSTANCE_LAUNCHING"
62+
default_result = "CONTINUE"
63+
heartbeat_timeout = 500
64+
lifecycle_transition_type = "NORMAL"
65+
# lifecycle_transition_type = "EXTENSION"
6466
notification_metadata = "tf test"
6567
}
6668
```
@@ -121,6 +123,7 @@ The following arguments are supported:
121123
* `default_result` - (Optional, String) Defines the action the AS group should take when the lifecycle hook timeout elapses or if an unexpected failure occurs. Valid values: `CONTINUE` and `ABANDON`. The default value is `CONTINUE`.
122124
* `heartbeat_timeout` - (Optional, Int) Defines the amount of time, in seconds, that can elapse before the lifecycle hook times out. Valid value ranges: (30~7200). and default value is `300`.
123125
* `lifecycle_command` - (Optional, List) Remote command execution object. `NotificationTarget` and `LifecycleCommand` cannot be specified at the same time.
126+
* `lifecycle_transition_type` - (Optional, String) The scenario where the lifecycle hook is applied. `EXTENSION`: the lifecycle hook will be triggered when AttachInstances, DetachInstances or RemoveInstaces is called. `NORMAL`: the lifecycle hook is not triggered by the above APIs.
124127
* `notification_metadata` - (Optional, String) Contains additional information that you want to include any time AS sends a message to the notification target.
125128
* `notification_queue_name` - (Optional, String) For CMQ_QUEUE type, a name of queue must be set.
126129
* `notification_target_type` - (Optional, String) Target type. Valid values: `CMQ_QUEUE`, `CMQ_TOPIC`, `TDMQ_CMQ_QUEUE`, `TDMQ_CMQ_TOPIC`.

website/docs/r/as_start_instance_refresh.html.markdown

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@ Provides a resource to create as instance refresh
1515

1616
```hcl
1717
resource "tencentcloud_as_start_instance_refresh" "example" {
18-
auto_scaling_group_id = "asg-9dn1a5y6"
18+
auto_scaling_group_id = "asg-8n7fdm28"
1919
refresh_mode = "ROLLING_UPDATE_RESET"
2020
refresh_settings {
2121
check_instance_target_health = false
2222
rolling_update_settings {
2323
batch_number = 1
2424
batch_pause = "AUTOMATIC"
25+
max_surge = 1
2526
}
2627
}
2728
}

0 commit comments

Comments
 (0)