LifecycleHook
- Implements: ILifecycleHook
This class encapsulates and extends the ROS resource type ALIYUN::ESS::LifecycleHook, which is used to create a lifecycle hook for a scaling group.
Initializers
import com.aliyun.ros.cdk.ess.LifecycleHook;
LifecycleHook.Builder.create(Construct scope, java.lang.String id, java.lang.Boolean enableResourcePropertyConstraint)
.lifecycleTransition(java.lang.String)
.lifecycleTransition(IResolvable)
.scalingGroupId(java.lang.String)
.scalingGroupId(IResolvable)
// .defaultResult(java.lang.String)
// .defaultResult(IResolvable)
// .heartbeatTimeout(java.lang.Number)
// .heartbeatTimeout(IResolvable)
// .lifecycleHookName(java.lang.String)
// .lifecycleHookName(IResolvable)
// .notificationArn(java.lang.String)
// .notificationArn(IResolvable)
// .notificationMetadata(java.lang.String)
// .notificationMetadata(IResolvable)
.build();
| Name | Type | Description |
|---|---|---|
scope | com.aliyun.ros.cdk.core.Construct | No description. |
id | java.lang.String | No description. |
enableResourcePropertyConstraint | java.lang.Boolean | No description. |
lifecycleTransition | java.lang.String OR com.aliyun.ros.cdk.core.IResolvable | Property lifecycleTransition: The scaling activities to which lifecycle hooks apply Value range: SCALE_OUT: scale-out event SCALE_IN: scale-in event. |
scalingGroupId | java.lang.String OR com.aliyun.ros.cdk.core.IResolvable | Property scalingGroupId: The ID of the scaling group. |
defaultResult | java.lang.String OR com.aliyun.ros.cdk.core.IResolvable | Property defaultResult: The action that Auto Scaling performs after the lifecycle hook times out. |
heartbeatTimeout | java.lang.Number OR com.aliyun.ros.cdk.core.IResolvable | Property heartbeatTimeout: The period of time before the lifecycle hook times out. |
lifecycleHookName | java.lang.String OR com.aliyun.ros.cdk.core.IResolvable | Property lifecycleHookName: The name of the lifecycle hook. |
notificationArn | java.lang.String OR com.aliyun.ros.cdk.core.IResolvable | Property notificationArn: The Alibaba Cloud Resource Name (ARN) of the notification recipient. |
notificationMetadata | java.lang.String OR com.aliyun.ros.cdk.core.IResolvable | Property notificationMetadata: The fixed string that is included in a notification that Auto Scaling sends when the lifecycle hook takes effect. |
scopeRequired
- Type: com.aliyun.ros.cdk.core.Construct
idRequired
- Type: java.lang.String
enableResourcePropertyConstraintOptional
- Type: java.lang.Boolean
lifecycleTransitionRequired
- Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable
Property lifecycleTransition: The scaling activities to which lifecycle hooks apply Value range: SCALE_OUT: scale-out event SCALE_IN: scale-in event.
scalingGroupIdRequired
- Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable
Property scalingGroupId: The ID of the scaling group.
defaultResultOptional
- Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable
Property defaultResult: The action that Auto Scaling performs after the lifecycle hook times out.
Valid values:
- CONTINUE: Auto Scaling continues to respond to a scale-in or scale-out request.
- ABANDON: Auto Scaling releases ECS instances that are created during scale-out activities or removes ECS instances from the scaling group during scale-in activities.
- ROLLBACK: For scale-in activities, Auto Scaling rejects the requests to release ECS instances but rolls back ECS instances. For scale-out activities, the ROLLBACK setting has the same effect as the
ABANDONsetting. If a scaling group has multiple lifecycle hooks in effect and you set theDefaultResultparameter for one of the lifecycle hooks toABANDONorROLLBACK, the following rule applies to scale-in activities: When the lifecycle hook whose DefaultResult parameter is set to ABANDON or ROLLBACK times out, other lifecycle hooks time out ahead of schedule. In other cases, Auto Scaling performs the action only after all lifecycle hooks time out. The action that Auto Scaling performs is specified by the DefaultResult parameter of the last lifecycle hook that times out. Default value: CONTINUE.
heartbeatTimeoutOptional
- Type: java.lang.Number OR com.aliyun.ros.cdk.core.IResolvable
Property heartbeatTimeout: The period of time before the lifecycle hook times out.
When the lifecycle hook times out, Auto Scaling performs the action that is specified by the DefaultResult parameter. Valid values: 30 to 21600. Unit: seconds. You can call the RecordLifecycleActionHeartbeat operation to extend the period of time before a lifecycle hook times out. You can also call the CompleteLifecycleAction operation to end a lifecycle hook ahead of schedule. Default value: 600.
lifecycleHookNameOptional
- Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable
Property lifecycleHookName: The name of the lifecycle hook.
Each name must be unique within a scaling group. The name must be 2 to 64 characters in length and can contain letters, numbers, Chinese characters, and special characters including underscores (_), hyphens (-) and periods (.). Default value: Lifecycle Hook ID
notificationArnOptional
- Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable
Property notificationArn: The Alibaba Cloud Resource Name (ARN) of the notification recipient.
If you do not specify this parameter, no notification is sent when the lifecycle hook takes effect. If you specify this parameter, the value must be in one of the following formats:
- If you specify a Simple Message Queue (SMQ, formerly MNS) as the notification recipient, specify the value in the acs:mns:{region-id}:{account-id}:queue/{queuename} format.
- If you specify an SMQ topic as the notification recipient, specify the value in the acs:mns:{region-id}:{account-id}:topic/{topicname} format.
- If you specify a CloudOps Orchestration Service (OOS) template as the notification recipient, specify the value in the acs:oos:{region-id}:{account-id}:template/{templatename} format.
- If you specify an event bus as the notification recipient, specify the value in the acs:eventbridge:{region-id}:{account-id}:eventbus/default format.
The variables in the preceding value formats have the following meanings:
- region-id: the region ID of your scaling group.
- account-id: the ID of the Alibaba Cloud account. IDs of Resource Access Management (RAM) users are not supported.
- queuename: the name of the SMQ queue.
- topicname: the name of the SMQ topic.
- templatename: the name of the OOS template.
notificationMetadataOptional
- Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable
Property notificationMetadata: The fixed string that is included in a notification that Auto Scaling sends when the lifecycle hook takes effect.
Auto Scaling sends the value of the NotificationMetadata parameter together with the notification. This helps you categorize your notifications. If you specify this parameter, you must also specify the NotificationArn parameter. The value of this parameter cannot exceed 4,096 characters in length. If you use the NotificationArn parameter to specify a public or custom OOS template, the value of the NotificationMetadata parameter must be a JSON string that contains the OOS template parameters. For example, your OOS template includes the following parameters: {"dbInstanceId": "dds-bp17661e0135****", "modifyMode": "Append"}, dbInstanceId, and modifyMode. Specific parameters that are defined in your OOS template have default values. When you specify the NotificationMetadata parameter, specify parameters that do not have default values. If you specify parameters that have default values, the default values are overwritten. The default values of the following parameters must be retained to obtain information about scaling activities that are in progress:
- regionId: the region ID of the scaling activity that is in progress. Default value: ${regionId}.
- instanceIds: the IDs of ECS instances that are scaled in the scaling activity. Default value: ${instanceIds}.
- lifecycleHookId: the ID of the lifecycle hook. Default value: ${lifecycleHookId}.
- lifecycleActionToken: the token of the lifecycle hook. You can use the token to end the timeout period of the lifecycle hook ahead of schedule. Default value: ${lifecycleActionToken}
- scalingGroupId: the ID of the scaling group in which the scaling activity is executed. Default value: ${scalingGroupId}.
- lifecycleActionResult: the action that Auto Scaling performs after the lifecycle hook times out. If the OOS template fails to be executed, the lifecycle hook times out ahead of schedule. If you set the
DefalutResultparameter toROLLBACK, the default value of this parameter isROLLBACK. If you set theDefaultResultparameter to other values, the default value of this parameter is ABANDON. Note** - You can specify a value for the
lifecycleActionResultparameter to overwrite the default value. Valid values: ABANDON, CONTINUE, ROLLBACK, and ${lifecycleActionResult}. A value of${lifecycleActionResult}specifies that the value of the lifecycleActionResult parameter is the same as the value of the DefaultResult parameter. - You can view the details of the OOS template that you specify in the OOS console.
Methods
| Name | Description |
|---|---|
toString | Returns a string representation of this construct. |
synthesize | Allows this construct to emit artifacts into the cloud assembly during synthesis. |
addCondition | No description. |
addCount | No description. |
addDependency | No description. |
addResourceDesc | No description. |
applyRemovalPolicy | No description. |
fetchCondition | No description. |
fetchDependency | No description. |
fetchResourceDesc | No description. |
getAtt | No description. |
setMetadata | No description. |
toString
public java.lang.String toString()
Returns a string representation of this construct.
synthesize
public void synthesize(ISynthesisSession session)
Allows this construct to emit artifacts into the cloud assembly during synthesis.
This method is usually implemented by framework-level constructs such as Stack and Asset as they participate in synthesizing the cloud assembly.
- Type: com.aliyun.ros.cdk.core.ISynthesisSession
The synthesis session.
addCondition
public void addCondition(RosCondition condition)
- Type: com.aliyun.ros.cdk.core.RosCondition
addCount
public void addCount(java.lang.Number OR IResolvable count)
- Type: java.lang.Number OR com.aliyun.ros.cdk.core.IResolvable
addDependency
public void addDependency(Resource resource)
- Type: com.aliyun.ros.cdk.core.Resource
addResourceDesc
public void addResourceDesc(java.lang.String desc)
- Type: java.lang.String
applyRemovalPolicy
public void applyRemovalPolicy(RemovalPolicy policy)
- Type: com.aliyun.ros.cdk.core.RemovalPolicy
fetchCondition
public RosCondition fetchCondition()
fetchDependency
public java.util.List<java.lang.String> fetchDependency()
fetchResourceDesc
public java.lang.String fetchResourceDesc()
getAtt
public IResolvable getAtt(java.lang.String name)
- Type: java.lang.String
setMetadata
public void setMetadata(java.lang.String key, java.lang.Object value)
- Type: java.lang.String
- Type: java.lang.Object
Static Functions
| Name | Description |
|---|---|
isConstruct | Return whether the given object is a Construct. |
isConstruct
import com.aliyun.ros.cdk.ess.LifecycleHook;
LifecycleHook.isConstruct(java.lang.Object x)
Return whether the given object is a Construct.
- Type: java.lang.Object
Properties
| Name | Type | Description |
|---|---|---|
node | com.aliyun.ros.cdk.core.ConstructNode | The construct tree node associated with this construct. |
env | com.aliyun.ros.cdk.core.IResourceEnvironment | The environment this resource belongs to. |
ref | java.lang.String | No description. |
stack | com.aliyun.ros.cdk.core.Stack | The stack in which this resource is defined. |
resource | com.aliyun.ros.cdk.core.RosResource | No description. |
attrLifecycleHookId | java.lang.String OR com.aliyun.ros.cdk.core.IResolvable | Attribute LifecycleHookId: The lifecycle hook ID. |
attrScalingGroupId | java.lang.String OR com.aliyun.ros.cdk.core.IResolvable | Attribute ScalingGroupId: The id of the scaling group to which the lifecycle hook belongs. |
props | LifecycleHookProps | No description. |
nodeRequired
public ConstructNode getNode();
- Type: com.aliyun.ros.cdk.core.ConstructNode
The construct tree node associated with this construct.
envRequired
public IResourceEnvironment getEnv();
- Type: com.aliyun.ros.cdk.core.IResourceEnvironment
The environment this resource belongs to.
For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.
refRequired
public java.lang.String getRef();
- Type: java.lang.String
stackRequired
public Stack getStack();
- Type: com.aliyun.ros.cdk.core.Stack
The stack in which this resource is defined.
resourceOptional
public RosResource getResource();
- Type: com.aliyun.ros.cdk.core.RosResource
attrLifecycleHookIdRequired
public java.lang.Object getAttrLifecycleHookId();
- Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable
Attribute LifecycleHookId: The lifecycle hook ID.
attrScalingGroupIdRequired
public java.lang.Object getAttrScalingGroupId();
- Type: java.lang.String OR com.aliyun.ros.cdk.core.IResolvable
Attribute ScalingGroupId: The id of the scaling group to which the lifecycle hook belongs.
propsRequired
public LifecycleHookProps getProps();
- Type: LifecycleHookProps