Provides an AutoScaling Lifecycle Hook resource.
resource "aws_autoscaling_group" "foobar" {
availability_zones = ["us-west-2a"]
name = "terraform-test-foobar5"
health_check_type = "EC2"
termination_policies = ["OldestInstance"]
tag {
key = "Foo"
value = "foo-bar"
propagate_at_launch = true
}
}
resource "aws_autoscaling_lifecycle_hook" "foobar" {
name = "foobar"
autoscaling_group_name = aws_autoscaling_group.foobar.name
default_result = "CONTINUE"
heartbeat_timeout = 2000
lifecycle_transition = "autoscaling:EC2_INSTANCE_LAUNCHING"
notification_metadata = jsonencode({
foo = "bar"
})
notification_target_arn = "arn:aws:sqs:us-east-1:444455556666:queue1*"
role_arn = "arn:aws:iam::123456789012:role/S3Access"
}
This resource supports the following arguments:
name
- (Required) Name of the lifecycle hook.autoscaling_group_name
- (Required) Name of the Auto Scaling group to which you want to assign the lifecycle hookdefault_result
- (Optional) Defines the action the Auto Scaling group should take when the lifecycle hook timeout elapses or if an unexpected failure occurs. The value for this parameter can be either CONTINUE or ABANDON. The default value for this parameter is ABANDON.heartbeat_timeout
- (Optional) Defines the amount of time, in seconds, that can elapse before the lifecycle hook times out. When the lifecycle hook times out, Auto Scaling performs the action defined in the DefaultResult parameterlifecycle_transition
- (Required) Instance state to which you want to attach the lifecycle hook. For a list of lifecycle hook types, see describe-lifecycle-hook-typesnotification_metadata
- (Optional) Contains additional information that you want to include any time Auto Scaling sends a message to the notification target.notification_target_arn
- (Optional) ARN of the notification target that Auto Scaling will use to notify you when an instance is in the transition state for the lifecycle hook. This ARN target can be either an SQS queue or an SNS topic.role_arn
- (Optional) ARN of the IAM role that allows the Auto Scaling group to publish to the specified notification target.This resource exports no additional attributes.
In Terraform v1.5.0 and later, use an import
block to import AutoScaling Lifecycle Hooks using the role autoscaling_group_name and name separated by /
. For example:
import {
to = aws_autoscaling_lifecycle_hook.test-lifecycle-hook
id = "asg-name/lifecycle-hook-name"
}
Using terraform import
, import AutoScaling Lifecycle Hooks using the role autoscaling_group_name and name separated by /
. For example:
% terraform import aws_autoscaling_lifecycle_hook.test-lifecycle-hook asg-name/lifecycle-hook-name