github.com/nathanielks/terraform@v0.6.1-0.20170509030759-13e1a62319dc/website/source/docs/providers/aws/r/autoscaling_lifecycle_hooks.html.markdown (about)

     1  ---
     2  layout: "aws"
     3  page_title: "AWS: aws_autoscaling_lifecycle_hook"
     4  sidebar_current: "docs-aws-resource-autoscaling-lifecycle-hook"
     5  description: |-
     6    Provides an AutoScaling Lifecycle Hooks resource.
     7  ---
     8  
     9  # aws\_autoscaling\_lifecycle\_hook
    10  
    11  Provides an AutoScaling Lifecycle Hook resource.
    12  
    13  ~> **NOTE:** Terraform has two types of ways you can add lifecycle hooks - via
    14  the `initial_lifecycle_hook` attribute from the
    15  [`aws_autoscaling_group`](/docs/providers/aws/r/autoscaling_group.html)
    16  resource, or via this one. Hooks added via this resource will not be added
    17  until the autoscaling group has been created, and depending on your
    18  [capacity](/docs/providers/aws/r/autoscaling_group.html#waiting-for-capacity)
    19  settings, after the initial instances have been launched, creating unintended
    20  behavior. If you need hooks to run on all instances, add them with
    21  `initial_lifecycle_hook` in
    22  [`aws_autoscaling_group`](/docs/providers/aws/r/autoscaling_group.html),
    23  but take care to not duplicate those hooks with this resource.
    24  
    25  ## Example Usage
    26  
    27  ```hcl
    28  resource "aws_autoscaling_group" "foobar" {
    29    availability_zones   = ["us-west-2a"]
    30    name                 = "terraform-test-foobar5"
    31    health_check_type    = "EC2"
    32    termination_policies = ["OldestInstance"]
    33  
    34    tag {
    35      key                 = "Foo"
    36      value               = "foo-bar"
    37      propagate_at_launch = true
    38    }
    39  }
    40  
    41  resource "aws_autoscaling_lifecycle_hook" "foobar" {
    42    name                   = "foobar"
    43    autoscaling_group_name = "${aws_autoscaling_group.foobar.name}"
    44    default_result         = "CONTINUE"
    45    heartbeat_timeout      = 2000
    46    lifecycle_transition   = "autoscaling:EC2_INSTANCE_LAUNCHING"
    47  
    48    notification_metadata = <<EOF
    49  {
    50    "foo": "bar"
    51  }
    52  EOF
    53  
    54    notification_target_arn = "arn:aws:sqs:us-east-1:444455556666:queue1*"
    55    role_arn                = "arn:aws:iam::123456789012:role/S3Access"
    56  }
    57  ```
    58  
    59  ## Argument Reference
    60  
    61  The following arguments are supported:
    62  
    63  * `name` - (Required) The name of the lifecycle hook.
    64  * `autoscaling_group_name` - (Required) The name of the Auto Scaling group to which you want to assign the lifecycle hook
    65  * `default_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.
    66  * `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 parameter
    67  * `lifecycle_transition` - (Optional) The instance state to which you want to attach the lifecycle hook. For a list of lifecycle hook types, see [describe-lifecycle-hook-types](https://docs.aws.amazon.com/cli/latest/reference/autoscaling/describe-lifecycle-hook-types.html#examples)
    68  * `notification_metadata` - (Optional) Contains additional information that you want to include any time Auto Scaling sends a message to the notification target.
    69  * `notification_target_arn` - (Optional) The 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.
    70  * `role_arn` - (Optional) The ARN of the IAM role that allows the Auto Scaling group to publish to the specified notification target.