Skip to content

LifecycleHook

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 ros_cdk_ess
ros_cdk_ess.LifecycleHook(
  scope: Construct,
  id: str,
  lifecycle_transition: typing.Union[str, IResolvable],
  scaling_group_id: typing.Union[str, IResolvable],
  default_result: typing.Union[str, IResolvable] = None,
  heartbeat_timeout: typing.Union[typing.Union[int, float], IResolvable] = None,
  lifecycle_hook_name: typing.Union[str, IResolvable] = None,
  notification_arn: typing.Union[str, IResolvable] = None,
  notification_metadata: typing.Union[str, IResolvable] = None,
  enable_resource_property_constraint: bool = None
)
Name Type Description
scope ros_cdk_core.Construct No description.
id str No description.
lifecycle_transition typing.Union[str, 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.
scaling_group_id typing.Union[str, ros_cdk_core.IResolvable] Property scalingGroupId: The ID of the scaling group.
default_result typing.Union[str, ros_cdk_core.IResolvable] Property defaultResult: The action that Auto Scaling performs after the lifecycle hook times out.
heartbeat_timeout typing.Union[typing.Union[int, float], ros_cdk_core.IResolvable] Property heartbeatTimeout: The period of time before the lifecycle hook times out.
lifecycle_hook_name typing.Union[str, ros_cdk_core.IResolvable] Property lifecycleHookName: The name of the lifecycle hook.
notification_arn typing.Union[str, ros_cdk_core.IResolvable] Property notificationArn: The Alibaba Cloud Resource Name (ARN) of the notification recipient.
notification_metadata typing.Union[str, 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.
enable_resource_property_constraint bool No description.

scopeRequired

  • Type: ros_cdk_core.Construct

idRequired

  • Type: str

lifecycle_transitionRequired

  • Type: typing.Union[str, 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.


scaling_group_idRequired

  • Type: typing.Union[str, ros_cdk_core.IResolvable]

Property scalingGroupId: The ID of the scaling group.


default_resultOptional

  • Type: typing.Union[str, 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 ABANDON setting. If a scaling group has multiple lifecycle hooks in effect and you set the DefaultResult parameter for one of the lifecycle hooks to ABANDON or ROLLBACK, 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.

heartbeat_timeoutOptional

  • Type: typing.Union[typing.Union[int, float], 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.


lifecycle_hook_nameOptional

  • Type: typing.Union[str, 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


notification_arnOptional

  • Type: typing.Union[str, 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.

notification_metadataOptional

  • Type: typing.Union[str, 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 DefalutResult parameter to ROLLBACK, the default value of this parameter is ROLLBACK. If you set the DefaultResult parameter to other values, the default value of this parameter is ABANDON. Note**
  • You can specify a value for the lifecycleActionResult parameter 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.

enable_resource_property_constraintOptional

  • Type: bool

Methods

Name Description
to_string Returns a string representation of this construct.
synthesize Allows this construct to emit artifacts into the cloud assembly during synthesis.
add_condition No description.
add_count No description.
add_dependency No description.
add_resource_desc No description.
apply_removal_policy No description.
fetch_condition No description.
fetch_dependency No description.
fetch_resource_desc No description.
get_att No description.
set_metadata No description.

to_string

def to_string() -> str

Returns a string representation of this construct.

synthesize

def synthesize(
  session: ISynthesisSession
) -> None

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.

sessionRequired

  • Type: ros_cdk_core.ISynthesisSession

The synthesis session.


add_condition

def add_condition(
  condition: RosCondition
) -> None

conditionRequired

  • Type: ros_cdk_core.RosCondition

add_count

def add_count(
  count: typing.Union[typing.Union[int, float], IResolvable]
) -> None

countRequired

  • Type: typing.Union[typing.Union[int, float], ros_cdk_core.IResolvable]

add_dependency

def add_dependency(
  resource: Resource
) -> None

resourceRequired

  • Type: ros_cdk_core.Resource

add_resource_desc

def add_resource_desc(
  desc: str
) -> None

descRequired

  • Type: str

apply_removal_policy

def apply_removal_policy(
  policy: RemovalPolicy
) -> None

policyRequired

  • Type: ros_cdk_core.RemovalPolicy

fetch_condition

def fetch_condition() -> RosCondition

fetch_dependency

def fetch_dependency() -> typing.List[str]

fetch_resource_desc

def fetch_resource_desc() -> str

get_att

def get_att(
  name: str
) -> IResolvable

nameRequired

  • Type: str

set_metadata

def set_metadata(
  key: str,
  value: typing.Any
) -> None

keyRequired

  • Type: str

valueRequired

  • Type: typing.Any

Static Functions

Name Description
is_construct Return whether the given object is a Construct.

is_construct

import ros_cdk_ess
ros_cdk_ess.LifecycleHook.is_construct(
  x: typing.Any
)

Return whether the given object is a Construct.

xRequired

  • Type: typing.Any

Properties

Name Type Description
node ros_cdk_core.ConstructNode The construct tree node associated with this construct.
env ros_cdk_core.IResourceEnvironment The environment this resource belongs to.
ref str No description.
stack ros_cdk_core.Stack The stack in which this resource is defined.
resource ros_cdk_core.RosResource No description.
attr_lifecycle_hook_id typing.Union[str, ros_cdk_core.IResolvable] Attribute LifecycleHookId: The lifecycle hook ID.
attr_scaling_group_id typing.Union[str, ros_cdk_core.IResolvable] Attribute ScalingGroupId: The id of the scaling group to which the lifecycle hook belongs.
props LifecycleHookProps No description.

nodeRequired

node: ConstructNode
  • Type: ros_cdk_core.ConstructNode

The construct tree node associated with this construct.


envRequired

env: IResourceEnvironment
  • Type: 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

ref: str
  • Type: str

stackRequired

stack: Stack
  • Type: ros_cdk_core.Stack

The stack in which this resource is defined.


resourceOptional

resource: RosResource
  • Type: ros_cdk_core.RosResource

attr_lifecycle_hook_idRequired

attr_lifecycle_hook_id: typing.Union[str, IResolvable]
  • Type: typing.Union[str, ros_cdk_core.IResolvable]

Attribute LifecycleHookId: The lifecycle hook ID.


attr_scaling_group_idRequired

attr_scaling_group_id: typing.Union[str, IResolvable]
  • Type: typing.Union[str, ros_cdk_core.IResolvable]

Attribute ScalingGroupId: The id of the scaling group to which the lifecycle hook belongs.


propsRequired

props: LifecycleHookProps