lifecycle_hooks
Creates, updates, deletes or gets a lifecycle_hook resource or lists lifecycle_hooks in a region
Overview
| Name | lifecycle_hooks |
| Type | Resource |
| Description | Resource Type definition for AWS::AutoScaling::LifecycleHook |
| Id | awscc.autoscaling.lifecycle_hooks |
Fields
- get (all properties)
- list (identifiers only)
| Name | Datatype | Description |
|---|---|---|
auto_scaling_group_name | string | The name of the Auto Scaling group for the lifecycle hook. |
default_result | string | The action the Auto Scaling group takes when the lifecycle hook timeout elapses or if an unexpected failure occurs. The valid values are CONTINUE and ABANDON (default). |
heartbeat_timeout | integer | The maximum time, in seconds, that can elapse before the lifecycle hook times out. The range is from 30 to 7200 seconds. The default value is 3600 seconds (1 hour). If the lifecycle hook times out, Amazon EC2 Auto Scaling performs the action that you specified in the DefaultResult property. |
lifecycle_hook_name | string | The name of the lifecycle hook. |
lifecycle_transition | string | The instance state to which you want to attach the lifecycle hook. |
notification_metadata | string | Additional information that is included any time Amazon EC2 Auto Scaling sends a message to the notification target. |
notification_target_arn | string | The Amazon Resource Name (ARN) of the notification target that Amazon EC2 Auto Scaling uses to notify you when an instance is in the transition state for the lifecycle hook. You can specify an Amazon SQS queue or an Amazon SNS topic. The notification message includes the following information: lifecycle action token, user account ID, Auto Scaling group name, lifecycle hook name, instance ID, lifecycle transition, and notification metadata. |
role_arn | string | The ARN of the IAM role that allows the Auto Scaling group to publish to the specified notification target, for example, an Amazon SNS topic or an Amazon SQS queue. |
region | string | AWS region. |
| Name | Datatype | Description |
|---|---|---|
auto_scaling_group_name | string | The name of the Auto Scaling group for the lifecycle hook. |
lifecycle_hook_name | string | The name of the lifecycle hook. |
region | string | AWS region. |
For more information, see AWS::AutoScaling::LifecycleHook.
Methods
| Name | Resource | Accessible by | Required Params |
|---|---|---|---|
create_resource | lifecycle_hooks | INSERT | LifecycleTransition, AutoScalingGroupName, region |
delete_resource | lifecycle_hooks | DELETE | Identifier, region |
update_resource | lifecycle_hooks | UPDATE | Identifier, PatchDocument, region |
list_resources | lifecycle_hooks_list_only | SELECT | region |
get_resource | lifecycle_hooks | SELECT | Identifier, region |
SELECT examples
- get (all properties)
- list (identifiers only)
Gets all properties from an individual lifecycle_hook.
SELECT
region,
auto_scaling_group_name,
default_result,
heartbeat_timeout,
lifecycle_hook_name,
lifecycle_transition,
notification_metadata,
notification_target_arn,
role_arn
FROM awscc.autoscaling.lifecycle_hooks
WHERE
region = 'us-east-1' AND
Identifier = '{{ auto_scaling_group_name }}|{{ lifecycle_hook_name }}';
Lists all lifecycle_hooks in a region.
SELECT
region,
auto_scaling_group_name,
lifecycle_hook_name
FROM awscc.autoscaling.lifecycle_hooks_list_only
WHERE
region = 'us-east-1';
INSERT example
Use the following StackQL query and manifest file to create a new lifecycle_hook resource, using stack-deploy.
- Required Properties
- All Properties
- Manifest
/*+ create */
INSERT INTO awscc.autoscaling.lifecycle_hooks (
AutoScalingGroupName,
LifecycleTransition,
region
)
SELECT
'{{ auto_scaling_group_name }}',
'{{ lifecycle_transition }}',
'{{ region }}';
/*+ create */
INSERT INTO awscc.autoscaling.lifecycle_hooks (
AutoScalingGroupName,
DefaultResult,
HeartbeatTimeout,
LifecycleHookName,
LifecycleTransition,
NotificationMetadata,
NotificationTargetARN,
RoleARN,
region
)
SELECT
'{{ auto_scaling_group_name }}',
'{{ default_result }}',
'{{ heartbeat_timeout }}',
'{{ lifecycle_hook_name }}',
'{{ lifecycle_transition }}',
'{{ notification_metadata }}',
'{{ notification_target_arn }}',
'{{ role_arn }}',
'{{ region }}';
version: 1
name: stack name
description: stack description
providers:
- aws
globals:
- name: region
value: '{{ vars.AWS_REGION }}'
resources:
- name: lifecycle_hook
props:
- name: auto_scaling_group_name
value: '{{ auto_scaling_group_name }}'
- name: default_result
value: '{{ default_result }}'
- name: heartbeat_timeout
value: '{{ heartbeat_timeout }}'
- name: lifecycle_hook_name
value: '{{ lifecycle_hook_name }}'
- name: lifecycle_transition
value: '{{ lifecycle_transition }}'
- name: notification_metadata
value: '{{ notification_metadata }}'
- name: notification_target_arn
value: '{{ notification_target_arn }}'
- name: role_arn
value: '{{ role_arn }}'
UPDATE example
Use the following StackQL query and manifest file to update a lifecycle_hook resource, using stack-deploy.
/*+ update */
UPDATE awscc.autoscaling.lifecycle_hooks
SET PatchDocument = string('{{ {
"DefaultResult": default_result,
"HeartbeatTimeout": heartbeat_timeout,
"LifecycleTransition": lifecycle_transition,
"NotificationMetadata": notification_metadata,
"NotificationTargetARN": notification_target_arn,
"RoleARN": role_arn
} | generate_patch_document }}')
WHERE
region = '{{ region }}' AND
Identifier = '{{ auto_scaling_group_name }}|{{ lifecycle_hook_name }}';
DELETE example
/*+ delete */
DELETE FROM awscc.autoscaling.lifecycle_hooks
WHERE
Identifier = '{{ auto_scaling_group_name }}|{{ lifecycle_hook_name }}' AND
region = 'us-east-1';
Permissions
To operate on the lifecycle_hooks resource, the following permissions are required:
- Create
- Read
- Update
- Delete
- List
autoscaling:PutLifecycleHook,
autoscaling:DescribeLifecycleHooks,
iam:PassRole
autoscaling:DescribeLifecycleHooks
autoscaling:PutLifecycleHook,
autoscaling:DescribeLifecycleHooks,
iam:PassRole
autoscaling:DeleteLifecycleHook,
autoscaling:DescribeLifecycleHooks
autoscaling:DescribeLifecycleHooks