LifecycleHook
Provides an AutoScaling Lifecycle Hook resource.
NOTE: This provider has two types of ways you can add lifecycle hooks - via the
initial_lifecycle_hookattribute from theaws.autoscaling.Groupresource, or via this one. Hooks added via this resource will not be added until the autoscaling group has been created, and depending on yourcapacitysettings, after the initial instances have been launched, creating unintended behavior. If you need hooks to run on all instances, add them withinitial_lifecycle_hookinaws.autoscaling.Group, but take care to not duplicate those hooks with this resource.
Example Usage
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var foobarGroup = new Aws.AutoScaling.Group("foobarGroup", new Aws.AutoScaling.GroupArgs
{
AvailabilityZones =
{
"us-west-2a",
},
HealthCheckType = "EC2",
Tags =
{
new Aws.AutoScaling.Inputs.GroupTagArgs
{
Key = "Foo",
PropagateAtLaunch = true,
Value = "foo-bar",
},
},
TerminationPolicies =
{
"OldestInstance",
},
});
var foobarLifecycleHook = new Aws.AutoScaling.LifecycleHook("foobarLifecycleHook", new Aws.AutoScaling.LifecycleHookArgs
{
AutoscalingGroupName = foobarGroup.Name,
DefaultResult = "CONTINUE",
HeartbeatTimeout = 2000,
LifecycleTransition = "autoscaling:EC2_INSTANCE_LAUNCHING",
NotificationMetadata = @"{
""foo"": ""bar""
}
",
NotificationTargetArn = "arn:aws:sqs:us-east-1:444455556666:queue1*",
RoleArn = "arn:aws:iam::123456789012:role/S3Access",
});
}
}
package main
import (
"fmt"
"github.com/pulumi/pulumi-aws/sdk/v2/go/aws/autoscaling"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
foobarGroup, err := autoscaling.NewGroup(ctx, "foobarGroup", &autoscaling.GroupArgs{
AvailabilityZones: pulumi.StringArray{
pulumi.String("us-west-2a"),
},
HealthCheckType: pulumi.String("EC2"),
Tags: autoscaling.GroupTagArray{
&autoscaling.GroupTagArgs{
Key: pulumi.String("Foo"),
PropagateAtLaunch: pulumi.Bool(true),
Value: pulumi.String("foo-bar"),
},
},
TerminationPolicies: pulumi.StringArray{
pulumi.String("OldestInstance"),
},
})
if err != nil {
return err
}
_, err = autoscaling.NewLifecycleHook(ctx, "foobarLifecycleHook", &autoscaling.LifecycleHookArgs{
AutoscalingGroupName: foobarGroup.Name,
DefaultResult: pulumi.String("CONTINUE"),
HeartbeatTimeout: pulumi.Int(2000),
LifecycleTransition: pulumi.String("autoscaling:EC2_INSTANCE_LAUNCHING"),
NotificationMetadata: pulumi.String(fmt.Sprintf("%v%v%v%v", "{\n", " \"foo\": \"bar\"\n", "}\n", "\n")),
NotificationTargetArn: pulumi.String("arn:aws:sqs:us-east-1:444455556666:queue1*"),
RoleArn: pulumi.String("arn:aws:iam::123456789012:role/S3Access"),
})
if err != nil {
return err
}
return nil
})
}import pulumi
import pulumi_aws as aws
foobar_group = aws.autoscaling.Group("foobarGroup",
availability_zones=["us-west-2a"],
health_check_type="EC2",
tags=[{
"key": "Foo",
"propagateAtLaunch": True,
"value": "foo-bar",
}],
termination_policies=["OldestInstance"])
foobar_lifecycle_hook = aws.autoscaling.LifecycleHook("foobarLifecycleHook",
autoscaling_group_name=foobar_group.name,
default_result="CONTINUE",
heartbeat_timeout=2000,
lifecycle_transition="autoscaling:EC2_INSTANCE_LAUNCHING",
notification_metadata="""{
"foo": "bar"
}
""",
notification_target_arn="arn:aws:sqs:us-east-1:444455556666:queue1*",
role_arn="arn:aws:iam::123456789012:role/S3Access")import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const foobarGroup = new aws.autoscaling.Group("foobar", {
availabilityZones: ["us-west-2a"],
healthCheckType: "EC2",
tags: [{
key: "Foo",
propagateAtLaunch: true,
value: "foo-bar",
}],
terminationPolicies: ["OldestInstance"],
});
const foobarLifecycleHook = new aws.autoscaling.LifecycleHook("foobar", {
autoscalingGroupName: foobarGroup.name,
defaultResult: "CONTINUE",
heartbeatTimeout: 2000,
lifecycleTransition: "autoscaling:EC2_INSTANCE_LAUNCHING",
notificationMetadata: `{
"foo": "bar"
}
`,
notificationTargetArn: "arn:aws:sqs:us-east-1:444455556666:queue1*",
roleArn: "arn:aws:iam::123456789012:role/S3Access",
});Create a LifecycleHook Resource
new LifecycleHook(name: string, args: LifecycleHookArgs, opts?: CustomResourceOptions);def LifecycleHook(resource_name, opts=None, autoscaling_group_name=None, default_result=None, heartbeat_timeout=None, lifecycle_transition=None, name=None, notification_metadata=None, notification_target_arn=None, role_arn=None, __props__=None);func NewLifecycleHook(ctx *Context, name string, args LifecycleHookArgs, opts ...ResourceOption) (*LifecycleHook, error)public LifecycleHook(string name, LifecycleHookArgs args, CustomResourceOptions? opts = null)- name string
- The unique name of the resource.
- args LifecycleHookArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- opts ResourceOptions
- A bag of options that control this resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args LifecycleHookArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args LifecycleHookArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
LifecycleHook Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.
Inputs
The LifecycleHook resource accepts the following input properties:
- Autoscaling
Group stringName The name of the Auto Scaling group to which you want to assign the lifecycle hook
- Lifecycle
Transition string The instance state to which you want to attach the lifecycle hook. For a list of lifecycle hook types, see describe-lifecycle-hook-types
- Default
Result string 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 int 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
- Name string
The name of the lifecycle hook.
- Notification
Metadata string Contains additional information that you want to include any time Auto Scaling sends a message to the notification target.
- Notification
Target stringArn 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.
- Role
Arn string The ARN of the IAM role that allows the Auto Scaling group to publish to the specified notification target.
- Autoscaling
Group stringName The name of the Auto Scaling group to which you want to assign the lifecycle hook
- Lifecycle
Transition string The instance state to which you want to attach the lifecycle hook. For a list of lifecycle hook types, see describe-lifecycle-hook-types
- Default
Result string 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 int 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
- Name string
The name of the lifecycle hook.
- Notification
Metadata string Contains additional information that you want to include any time Auto Scaling sends a message to the notification target.
- Notification
Target stringArn 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.
- Role
Arn string The ARN of the IAM role that allows the Auto Scaling group to publish to the specified notification target.
- autoscaling
Group stringName The name of the Auto Scaling group to which you want to assign the lifecycle hook
- lifecycle
Transition string The instance state to which you want to attach the lifecycle hook. For a list of lifecycle hook types, see describe-lifecycle-hook-types
- default
Result string 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 number 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
- name string
The name of the lifecycle hook.
- notification
Metadata string Contains additional information that you want to include any time Auto Scaling sends a message to the notification target.
- notification
Target stringArn 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.
- role
Arn string The ARN of the IAM role that allows the Auto Scaling group to publish to the specified notification target.
- autoscaling_
group_ strname The name of the Auto Scaling group to which you want to assign the lifecycle hook
- lifecycle_
transition str The instance state to which you want to attach the lifecycle hook. For a list of lifecycle hook types, see describe-lifecycle-hook-types
- default_
result str 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 float 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
- name str
The name of the lifecycle hook.
- notification_
metadata str Contains additional information that you want to include any time Auto Scaling sends a message to the notification target.
- notification_
target_ strarn 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.
- role_
arn str The ARN of the IAM role that allows the Auto Scaling group to publish to the specified notification target.
Outputs
All input properties are implicitly available as output properties. Additionally, the LifecycleHook resource produces the following output properties:
Look up an Existing LifecycleHook Resource
Get an existing LifecycleHook resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: LifecycleHookState, opts?: CustomResourceOptions): LifecycleHookstatic get(resource_name, id, opts=None, autoscaling_group_name=None, default_result=None, heartbeat_timeout=None, lifecycle_transition=None, name=None, notification_metadata=None, notification_target_arn=None, role_arn=None, __props__=None);func GetLifecycleHook(ctx *Context, name string, id IDInput, state *LifecycleHookState, opts ...ResourceOption) (*LifecycleHook, error)public static LifecycleHook Get(string name, Input<string> id, LifecycleHookState? state, CustomResourceOptions? opts = null)- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
The following state arguments are supported:
- Autoscaling
Group stringName The name of the Auto Scaling group to which you want to assign the lifecycle hook
- Default
Result string 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 int 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
- Lifecycle
Transition string The instance state to which you want to attach the lifecycle hook. For a list of lifecycle hook types, see describe-lifecycle-hook-types
- Name string
The name of the lifecycle hook.
- Notification
Metadata string Contains additional information that you want to include any time Auto Scaling sends a message to the notification target.
- Notification
Target stringArn 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.
- Role
Arn string The ARN of the IAM role that allows the Auto Scaling group to publish to the specified notification target.
- Autoscaling
Group stringName The name of the Auto Scaling group to which you want to assign the lifecycle hook
- Default
Result string 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 int 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
- Lifecycle
Transition string The instance state to which you want to attach the lifecycle hook. For a list of lifecycle hook types, see describe-lifecycle-hook-types
- Name string
The name of the lifecycle hook.
- Notification
Metadata string Contains additional information that you want to include any time Auto Scaling sends a message to the notification target.
- Notification
Target stringArn 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.
- Role
Arn string The ARN of the IAM role that allows the Auto Scaling group to publish to the specified notification target.
- autoscaling
Group stringName The name of the Auto Scaling group to which you want to assign the lifecycle hook
- default
Result string 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 number 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
- lifecycle
Transition string The instance state to which you want to attach the lifecycle hook. For a list of lifecycle hook types, see describe-lifecycle-hook-types
- name string
The name of the lifecycle hook.
- notification
Metadata string Contains additional information that you want to include any time Auto Scaling sends a message to the notification target.
- notification
Target stringArn 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.
- role
Arn string The ARN of the IAM role that allows the Auto Scaling group to publish to the specified notification target.
- autoscaling_
group_ strname The name of the Auto Scaling group to which you want to assign the lifecycle hook
- default_
result str 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 float 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
- lifecycle_
transition str The instance state to which you want to attach the lifecycle hook. For a list of lifecycle hook types, see describe-lifecycle-hook-types
- name str
The name of the lifecycle hook.
- notification_
metadata str Contains additional information that you want to include any time Auto Scaling sends a message to the notification target.
- notification_
target_ strarn 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.
- role_
arn str The ARN of the IAM role that allows the Auto Scaling group to publish to the specified notification target.
Package Details
- Repository
- https://github.com/pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
awsTerraform Provider.