Lifecycle Hook Args
Provides an AutoScaling Lifecycle Hook resource.
NOTE: This provider has two types of ways you can add lifecycle hooks - via the
initial_lifecycle_hook
attribute from theaws.autoscaling.Group
resource, or via this one. Hooks added via this resource will not be added until the autoscaling 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 withinitial_lifecycle_hook
inaws.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.List;
import java.util.ArrayList;
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 foobarGroup = new Group("foobarGroup", GroupArgs.builder()
.availabilityZones("us-west-2a")
.healthCheckType("EC2")
.terminationPolicies("OldestInstance")
.tags(GroupTagArgs.builder()
.key("Foo")
.value("foo-bar")
.propagateAtLaunch(true)
.build())
.build());
var foobarLifecycleHook = new LifecycleHook("foobarLifecycleHook", LifecycleHookArgs.builder()
.autoscalingGroupName(foobarGroup.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
Using pulumi import
, import AutoScaling Lifecycle Hooks using the role autoscaling_group_name and name separated by /
. For example:
$ pulumi import aws:autoscaling/lifecycleHook:LifecycleHook test-lifecycle-hook asg-name/lifecycle-hook-name
Constructors
Functions
Properties
Instance state to which you want to attach the lifecycle hook. For a list of lifecycle hook types, see describe-lifecycle-hook-types