Resource: aws_autoscaling_lifecycle_hook

Provides an AutoScaling Lifecycle Hook resource.

Example Usage

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"
}

Argument Reference

This resource supports the following arguments:

Attribute Reference

This resource exports no additional attributes.

Import

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