Class LifecycleHook


  • public class LifecycleHook
    extends com.pulumi.resources.CustomResource
    Provides an AutoScaling Lifecycle Hook resource. > **NOTE:** This provider has two types of ways you can add lifecycle hooks - via the `initialLifecycleHook` attribute from the `aws.autoscaling.Group` resource, or via this one. Hooks added via this resource will not be added until the Auto Scaling group has been created, and depending on your capacity settings, after the initial instances have been launched, creating unintended behavior. If you need hooks to run on all instances, add them with `initialLifecycleHook` in `aws.autoscaling.Group`, but take care to not duplicate those hooks with this resource. ## Example Usage
     
     package generated_program;
     
     import com.pulumi.Context;
     import com.pulumi.Pulumi;
     import com.pulumi.core.Output;
     import com.pulumi.aws.autoscaling.Group;
     import com.pulumi.aws.autoscaling.GroupArgs;
     import com.pulumi.aws.autoscaling.inputs.GroupTagArgs;
     import com.pulumi.aws.autoscaling.LifecycleHook;
     import com.pulumi.aws.autoscaling.LifecycleHookArgs;
     import static com.pulumi.codegen.internal.Serialization.*;
     import java.util.ArrayList;
     import java.util.Arrays;
     import java.util.Map;
     import java.io.File;
     import java.nio.file.Files;
     import java.nio.file.Paths;
     
     public class App {
         public static void main(String[] args) {
             Pulumi.run(App::stack);
         }
     
         public static void stack(Context ctx) {
             var foobar = new Group("foobar", GroupArgs.builder()
                 .tags(GroupTagArgs.builder()
                     .key("Foo")
                     .value("foo-bar")
                     .propagateAtLaunch(true)
                     .build())
                 .availabilityZones("us-west-2a")
                 .name("test-foobar5")
                 .healthCheckType("EC2")
                 .terminationPolicies("OldestInstance")
                 .build());
     
             var foobarLifecycleHook = new LifecycleHook("foobarLifecycleHook", LifecycleHookArgs.builder()
                 .name("foobar")
                 .autoscalingGroupName(foobar.name())
                 .defaultResult("CONTINUE")
                 .heartbeatTimeout(2000)
                 .lifecycleTransition("autoscaling:EC2_INSTANCE_LAUNCHING")
                 .notificationMetadata(serializeJson(
                     jsonObject(
                         jsonProperty("foo", "bar")
                     )))
                 .notificationTargetArn("arn:aws:sqs:us-east-1:444455556666:queue1*")
                 .roleArn("arn:aws:iam::123456789012:role/S3Access")
                 .build());
     
         }
     }
     
     
    ## Import ### Identity Schema #### Required * `autoscalingGroupName` (String) Name of the Auto Scaling group. * `name` (String) Name of the lifecycle hook. #### Optional * `accountId` (String) AWS Account where this resource is managed. * `region` (String) Region where this resource is managed. Using `pulumi import`, import AutoScaling Lifecycle Hooks using `autoscalingGroupName` and `name` separated by a forward slash (`/`). For example: ```sh $ pulumi import aws:autoscaling/lifecycleHook:LifecycleHook example example-asg/example-hook ```
    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.pulumi.resources.CustomResource

        com.pulumi.resources.CustomResource.CustomResourceInternal
      • Nested classes/interfaces inherited from class com.pulumi.resources.Resource

        com.pulumi.resources.Resource.LazyField<T extends java.lang.Object>, com.pulumi.resources.Resource.LazyFields, com.pulumi.resources.Resource.ResourceInternal
    • Field Summary

      • Fields inherited from class com.pulumi.resources.Resource

        childResources, remote
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.pulumi.core.Output<java.lang.String> autoscalingGroupName()  
      com.pulumi.core.Output<java.lang.String> defaultResult()  
      static LifecycleHook get​(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, LifecycleHookState state, com.pulumi.resources.CustomResourceOptions options)
      Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
      com.pulumi.core.Output<java.util.Optional<java.lang.Integer>> heartbeatTimeout()  
      com.pulumi.core.Output<java.lang.String> lifecycleTransition()  
      com.pulumi.core.Output<java.lang.String> name()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> notificationMetadata()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> notificationTargetArn()  
      com.pulumi.core.Output<java.lang.String> region()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> roleArn()  
      • Methods inherited from class com.pulumi.resources.CustomResource

        getId, id, idFuture
      • Methods inherited from class com.pulumi.resources.Resource

        getChildResources, getResourceName, getResourceType, getUrn, pulumiChildResources, pulumiResourceName, pulumiResourceType, urn
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LifecycleHook

        public LifecycleHook​(java.lang.String name)
        Parameters:
        name - The _unique_ name of the resulting resource.
      • LifecycleHook

        public LifecycleHook​(java.lang.String name,
                             LifecycleHookArgs args)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
      • LifecycleHook

        public LifecycleHook​(java.lang.String name,
                             LifecycleHookArgs args,
                             @Nullable
                             com.pulumi.resources.CustomResourceOptions options)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
        options - A bag of options that control this resource's behavior.
    • Method Detail

      • autoscalingGroupName

        public com.pulumi.core.Output<java.lang.String> autoscalingGroupName()
        Returns:
        Name of the Auto Scaling group to which you want to assign the lifecycle hook
      • defaultResult

        public com.pulumi.core.Output<java.lang.String> defaultResult()
        Returns:
        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.
      • heartbeatTimeout

        public com.pulumi.core.Output<java.util.Optional<java.lang.Integer>> heartbeatTimeout()
        Returns:
        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
      • lifecycleTransition

        public com.pulumi.core.Output<java.lang.String> lifecycleTransition()
        Returns:
        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)
      • name

        public com.pulumi.core.Output<java.lang.String> name()
        Returns:
        Name of the lifecycle hook.
      • notificationMetadata

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> notificationMetadata()
        Returns:
        Contains additional information that you want to include any time Auto Scaling sends a message to the notification target.
      • notificationTargetArn

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> notificationTargetArn()
        Returns:
        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, an SNS topic, or a Lambda function.
      • region

        public com.pulumi.core.Output<java.lang.String> region()
        Returns:
        Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration.
      • roleArn

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> roleArn()
        Returns:
        ARN of the IAM role that allows the Auto Scaling group to publish to the specified notification target.
      • get

        public static LifecycleHook get​(java.lang.String name,
                                        com.pulumi.core.Output<java.lang.String> id,
                                        @Nullable
                                        LifecycleHookState state,
                                        @Nullable
                                        com.pulumi.resources.CustomResourceOptions options)
        Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
        Parameters:
        name - The _unique_ name of the resulting resource.
        id - The _unique_ provider ID of the resource to lookup.
        state -
        options - Optional settings to control the behavior of the CustomResource.