@pulumi/aws
Version:
A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.
125 lines • 5.42 kB
JavaScript
;
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.LifecycleHook = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* 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 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 with
* `initialLifecycleHook` in
* `aws.autoscaling.Group`,
* but take care to not duplicate those hooks with this resource.
*
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const foobar = new aws.autoscaling.Group("foobar", {
* availabilityZones: ["us-west-2a"],
* name: "test-foobar5",
* healthCheckType: "EC2",
* terminationPolicies: ["OldestInstance"],
* tags: [{
* key: "Foo",
* value: "foo-bar",
* propagateAtLaunch: true,
* }],
* });
* const foobarLifecycleHook = new aws.autoscaling.LifecycleHook("foobar", {
* name: "foobar",
* autoscalingGroupName: foobar.name,
* defaultResult: "CONTINUE",
* heartbeatTimeout: 2000,
* lifecycleTransition: "autoscaling:EC2_INSTANCE_LAUNCHING",
* notificationMetadata: JSON.stringify({
* foo: "bar",
* }),
* notificationTargetArn: "arn:aws:sqs:us-east-1:444455556666:queue1*",
* roleArn: "arn:aws:iam::123456789012:role/S3Access",
* });
* ```
*
* ## Import
*
* Using `pulumi import`, import AutoScaling Lifecycle Hooks using the role autoscaling_group_name and name separated by `/`. For example:
*
* ```sh
* $ pulumi import aws:autoscaling/lifecycleHook:LifecycleHook test-lifecycle-hook asg-name/lifecycle-hook-name
* ```
*/
class LifecycleHook extends pulumi.CustomResource {
/**
* Get an existing LifecycleHook resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state Any extra arguments used during the lookup.
* @param opts Optional settings to control the behavior of the CustomResource.
*/
static get(name, id, state, opts) {
return new LifecycleHook(name, state, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of LifecycleHook. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
static isInstance(obj) {
if (obj === undefined || obj === null) {
return false;
}
return obj['__pulumiType'] === LifecycleHook.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["autoscalingGroupName"] = state?.autoscalingGroupName;
resourceInputs["defaultResult"] = state?.defaultResult;
resourceInputs["heartbeatTimeout"] = state?.heartbeatTimeout;
resourceInputs["lifecycleTransition"] = state?.lifecycleTransition;
resourceInputs["name"] = state?.name;
resourceInputs["notificationMetadata"] = state?.notificationMetadata;
resourceInputs["notificationTargetArn"] = state?.notificationTargetArn;
resourceInputs["region"] = state?.region;
resourceInputs["roleArn"] = state?.roleArn;
}
else {
const args = argsOrState;
if (args?.autoscalingGroupName === undefined && !opts.urn) {
throw new Error("Missing required property 'autoscalingGroupName'");
}
if (args?.lifecycleTransition === undefined && !opts.urn) {
throw new Error("Missing required property 'lifecycleTransition'");
}
resourceInputs["autoscalingGroupName"] = args?.autoscalingGroupName;
resourceInputs["defaultResult"] = args?.defaultResult;
resourceInputs["heartbeatTimeout"] = args?.heartbeatTimeout;
resourceInputs["lifecycleTransition"] = args?.lifecycleTransition;
resourceInputs["name"] = args?.name;
resourceInputs["notificationMetadata"] = args?.notificationMetadata;
resourceInputs["notificationTargetArn"] = args?.notificationTargetArn;
resourceInputs["region"] = args?.region;
resourceInputs["roleArn"] = args?.roleArn;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(LifecycleHook.__pulumiType, name, resourceInputs, opts);
}
}
exports.LifecycleHook = LifecycleHook;
/** @internal */
LifecycleHook.__pulumiType = 'aws:autoscaling/lifecycleHook:LifecycleHook';
//# sourceMappingURL=lifecycleHook.js.map