Skip to content

aws.autoscaling-lifecycle-hook resource

Description

LifecycleHook is an EC2 Auto Scaling lifecycle hook: a pause point in an instance's launch or termination that lets a custom action run before the transition completes. The whole resource is one PutLifecycleHook upsert, used for both create and update, with no eventual-consistency waiter. The hook is keyed by the group name plus the hook name, both fixed at create time; a change to either makes a new hook.

The one resilience wrapper is on the upsert: a notification target created moments earlier -- an SNS topic, an SQS queue, the IAM role that publishes to it -- may not have propagated, so AWS cannot yet publish its test message. The call retries through that ValidationError for five minutes. Lifecycle hooks are not taggable, so the resource has no tag fields.

Source: internal/service/autoscaling/lifecycle_hook_rsrc.go:30

Example usage:

imports: {
  aws: 'github.com/cloudboss/unobin-library-aws'
}

resources: {
  example: aws.autoscaling-lifecycle-hook {
    # Set input fields here.
  }
}

Inputs

autoscaling-group-name

string

required

name

string

required

lifecycle-transition

string

required

default-result

optional(string)

heartbeat-timeout

optional(integer)

notification-metadata

optional(string)

notification-target-arn

optional(string)

role-arn

optional(string)

Input Constraints

Lifecycle transition rules

lifecycle-transition must be autoscaling:EC2_INSTANCE_LAUNCHING or autoscaling:EC2_INSTANCE_TERMINATING.

Rule logic
Require
input.lifecycle-transition == 'autoscaling:EC2_INSTANCE_LAUNCHING'
|| input.lifecycle-transition == 'autoscaling:EC2_INSTANCE_TERMINATING'

Default result rules

default-result must be CONTINUE or ABANDON.

Rule logic
When
input.default-result != null
Require
input.default-result == 'CONTINUE'
|| input.default-result == 'ABANDON'

Heartbeat timeout rules

heartbeat-timeout must be from 30 to 7200 seconds.

Rule logic
When
input.heartbeat-timeout != null
Require
(input.heartbeat-timeout == null || input.heartbeat-timeout >= 30)
&& (input.heartbeat-timeout == null || input.heartbeat-timeout <= 7200)

Outputs

autoscaling-group-name

string

name

string

default-result

string