UNPKG

@pulumi/aws

Version:

A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.

125 lines 5.8 kB
"use strict"; // *** 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, Object.assign(Object.assign({}, 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 ? state.autoscalingGroupName : undefined; resourceInputs["defaultResult"] = state ? state.defaultResult : undefined; resourceInputs["heartbeatTimeout"] = state ? state.heartbeatTimeout : undefined; resourceInputs["lifecycleTransition"] = state ? state.lifecycleTransition : undefined; resourceInputs["name"] = state ? state.name : undefined; resourceInputs["notificationMetadata"] = state ? state.notificationMetadata : undefined; resourceInputs["notificationTargetArn"] = state ? state.notificationTargetArn : undefined; resourceInputs["region"] = state ? state.region : undefined; resourceInputs["roleArn"] = state ? state.roleArn : undefined; } else { const args = argsOrState; if ((!args || args.autoscalingGroupName === undefined) && !opts.urn) { throw new Error("Missing required property 'autoscalingGroupName'"); } if ((!args || args.lifecycleTransition === undefined) && !opts.urn) { throw new Error("Missing required property 'lifecycleTransition'"); } resourceInputs["autoscalingGroupName"] = args ? args.autoscalingGroupName : undefined; resourceInputs["defaultResult"] = args ? args.defaultResult : undefined; resourceInputs["heartbeatTimeout"] = args ? args.heartbeatTimeout : undefined; resourceInputs["lifecycleTransition"] = args ? args.lifecycleTransition : undefined; resourceInputs["name"] = args ? args.name : undefined; resourceInputs["notificationMetadata"] = args ? args.notificationMetadata : undefined; resourceInputs["notificationTargetArn"] = args ? args.notificationTargetArn : undefined; resourceInputs["region"] = args ? args.region : undefined; resourceInputs["roleArn"] = args ? args.roleArn : undefined; } 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