com.pulumi.aws.autoscaling.kotlin.LifecycleHookArgs.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pulumi-aws-kotlin Show documentation
Show all versions of pulumi-aws-kotlin Show documentation
Build cloud applications and infrastructure by combining the safety and reliability of infrastructure as code with the power of the Kotlin programming language.
@file:Suppress("NAME_SHADOWING", "DEPRECATION")
package com.pulumi.aws.autoscaling.kotlin
import com.pulumi.aws.autoscaling.LifecycleHookArgs.builder
import com.pulumi.core.Output
import com.pulumi.core.Output.of
import com.pulumi.kotlin.ConvertibleToJava
import com.pulumi.kotlin.PulumiTagMarker
import kotlin.Int
import kotlin.String
import kotlin.Suppress
import kotlin.jvm.JvmName
/**
* 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 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
* `initial_lifecycle_hook` 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",
* });
* ```
* ```python
* import pulumi
* import json
* import pulumi_aws as aws
* foobar = aws.autoscaling.Group("foobar",
* availability_zones=["us-west-2a"],
* name="test-foobar5",
* health_check_type="EC2",
* termination_policies=["OldestInstance"],
* tags=[{
* "key": "Foo",
* "value": "foo-bar",
* "propagate_at_launch": True,
* }])
* foobar_lifecycle_hook = aws.autoscaling.LifecycleHook("foobar",
* name="foobar",
* autoscaling_group_name=foobar.name,
* default_result="CONTINUE",
* heartbeat_timeout=2000,
* lifecycle_transition="autoscaling:EC2_INSTANCE_LAUNCHING",
* notification_metadata=json.dumps({
* "foo": "bar",
* }),
* notification_target_arn="arn:aws:sqs:us-east-1:444455556666:queue1*",
* role_arn="arn:aws:iam::123456789012:role/S3Access")
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using System.Text.Json;
* using Pulumi;
* using Aws = Pulumi.Aws;
* return await Deployment.RunAsync(() =>
* {
* var foobar = new Aws.AutoScaling.Group("foobar", new()
* {
* AvailabilityZones = new[]
* {
* "us-west-2a",
* },
* Name = "test-foobar5",
* HealthCheckType = "EC2",
* TerminationPolicies = new[]
* {
* "OldestInstance",
* },
* Tags = new[]
* {
* new Aws.AutoScaling.Inputs.GroupTagArgs
* {
* Key = "Foo",
* Value = "foo-bar",
* PropagateAtLaunch = true,
* },
* },
* });
* var foobarLifecycleHook = new Aws.AutoScaling.LifecycleHook("foobar", new()
* {
* Name = "foobar",
* AutoscalingGroupName = foobar.Name,
* DefaultResult = "CONTINUE",
* HeartbeatTimeout = 2000,
* LifecycleTransition = "autoscaling:EC2_INSTANCE_LAUNCHING",
* NotificationMetadata = JsonSerializer.Serialize(new Dictionary
* {
* ["foo"] = "bar",
* }),
* NotificationTargetArn = "arn:aws:sqs:us-east-1:444455556666:queue1*",
* RoleArn = "arn:aws:iam::123456789012:role/S3Access",
* });
* });
* ```
* ```go
* package main
* import (
* "encoding/json"
* "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/autoscaling"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* foobar, err := autoscaling.NewGroup(ctx, "foobar", &autoscaling.GroupArgs{
* AvailabilityZones: pulumi.StringArray{
* pulumi.String("us-west-2a"),
* },
* Name: pulumi.String("test-foobar5"),
* HealthCheckType: pulumi.String("EC2"),
* TerminationPolicies: pulumi.StringArray{
* pulumi.String("OldestInstance"),
* },
* Tags: autoscaling.GroupTagArray{
* &autoscaling.GroupTagArgs{
* Key: pulumi.String("Foo"),
* Value: pulumi.String("foo-bar"),
* PropagateAtLaunch: pulumi.Bool(true),
* },
* },
* })
* if err != nil {
* return err
* }
* tmpJSON0, err := json.Marshal(map[string]interface{}{
* "foo": "bar",
* })
* if err != nil {
* return err
* }
* json0 := string(tmpJSON0)
* _, err = autoscaling.NewLifecycleHook(ctx, "foobar", &autoscaling.LifecycleHookArgs{
* Name: pulumi.String("foobar"),
* AutoscalingGroupName: foobar.Name,
* DefaultResult: pulumi.String("CONTINUE"),
* HeartbeatTimeout: pulumi.Int(2000),
* LifecycleTransition: pulumi.String("autoscaling:EC2_INSTANCE_LAUNCHING"),
* NotificationMetadata: pulumi.String(json0),
* 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
* })
* }
* ```
* ```java
* 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 foobar = new Group("foobar", GroupArgs.builder()
* .availabilityZones("us-west-2a")
* .name("test-foobar5")
* .healthCheckType("EC2")
* .terminationPolicies("OldestInstance")
* .tags(GroupTagArgs.builder()
* .key("Foo")
* .value("foo-bar")
* .propagateAtLaunch(true)
* .build())
* .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());
* }
* }
* ```
* ```yaml
* resources:
* foobar:
* type: aws:autoscaling:Group
* properties:
* availabilityZones:
* - us-west-2a
* name: test-foobar5
* healthCheckType: EC2
* terminationPolicies:
* - OldestInstance
* tags:
* - key: Foo
* value: foo-bar
* propagateAtLaunch: true
* foobarLifecycleHook:
* type: aws:autoscaling:LifecycleHook
* name: foobar
* properties:
* name: foobar
* autoscalingGroupName: ${foobar.name}
* defaultResult: CONTINUE
* heartbeatTimeout: 2000
* lifecycleTransition: autoscaling:EC2_INSTANCE_LAUNCHING
* notificationMetadata:
* fn::toJSON:
* 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
* ```
* @property autoscalingGroupName Name of the Auto Scaling group to which you want to assign the lifecycle hook
* @property defaultResult 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.
* @property heartbeatTimeout 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
* @property lifecycleTransition 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)
* @property name Name of the lifecycle hook.
* @property notificationMetadata Contains additional information that you want to include any time Auto Scaling sends a message to the notification target.
* @property notificationTargetArn 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.
* @property roleArn ARN of the IAM role that allows the Auto Scaling group to publish to the specified notification target.
*/
public data class LifecycleHookArgs(
public val autoscalingGroupName: Output? = null,
public val defaultResult: Output? = null,
public val heartbeatTimeout: Output? = null,
public val lifecycleTransition: Output? = null,
public val name: Output? = null,
public val notificationMetadata: Output? = null,
public val notificationTargetArn: Output? = null,
public val roleArn: Output? = null,
) : ConvertibleToJava {
override fun toJava(): com.pulumi.aws.autoscaling.LifecycleHookArgs =
com.pulumi.aws.autoscaling.LifecycleHookArgs.builder()
.autoscalingGroupName(autoscalingGroupName?.applyValue({ args0 -> args0 }))
.defaultResult(defaultResult?.applyValue({ args0 -> args0 }))
.heartbeatTimeout(heartbeatTimeout?.applyValue({ args0 -> args0 }))
.lifecycleTransition(lifecycleTransition?.applyValue({ args0 -> args0 }))
.name(name?.applyValue({ args0 -> args0 }))
.notificationMetadata(notificationMetadata?.applyValue({ args0 -> args0 }))
.notificationTargetArn(notificationTargetArn?.applyValue({ args0 -> args0 }))
.roleArn(roleArn?.applyValue({ args0 -> args0 })).build()
}
/**
* Builder for [LifecycleHookArgs].
*/
@PulumiTagMarker
public class LifecycleHookArgsBuilder internal constructor() {
private var autoscalingGroupName: Output? = null
private var defaultResult: Output? = null
private var heartbeatTimeout: Output? = null
private var lifecycleTransition: Output? = null
private var name: Output? = null
private var notificationMetadata: Output? = null
private var notificationTargetArn: Output? = null
private var roleArn: Output? = null
/**
* @param value Name of the Auto Scaling group to which you want to assign the lifecycle hook
*/
@JvmName("pbtlkdwstqfakham")
public suspend fun autoscalingGroupName(`value`: Output) {
this.autoscalingGroupName = value
}
/**
* @param value 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.
*/
@JvmName("mffjdmpnxydqdvnj")
public suspend fun defaultResult(`value`: Output) {
this.defaultResult = value
}
/**
* @param value 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
*/
@JvmName("rddsrkckljdwjilg")
public suspend fun heartbeatTimeout(`value`: Output) {
this.heartbeatTimeout = value
}
/**
* @param value 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)
*/
@JvmName("vaoqffvsabqkymbr")
public suspend fun lifecycleTransition(`value`: Output) {
this.lifecycleTransition = value
}
/**
* @param value Name of the lifecycle hook.
*/
@JvmName("tmcspnhagibbduse")
public suspend fun name(`value`: Output) {
this.name = value
}
/**
* @param value Contains additional information that you want to include any time Auto Scaling sends a message to the notification target.
*/
@JvmName("jvbrrovdapllytev")
public suspend fun notificationMetadata(`value`: Output) {
this.notificationMetadata = value
}
/**
* @param value 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.
*/
@JvmName("mocneinwiedyynkt")
public suspend fun notificationTargetArn(`value`: Output) {
this.notificationTargetArn = value
}
/**
* @param value ARN of the IAM role that allows the Auto Scaling group to publish to the specified notification target.
*/
@JvmName("jkehpmjxrakuihtu")
public suspend fun roleArn(`value`: Output) {
this.roleArn = value
}
/**
* @param value Name of the Auto Scaling group to which you want to assign the lifecycle hook
*/
@JvmName("iimmgxanvaxdlqib")
public suspend fun autoscalingGroupName(`value`: String?) {
val toBeMapped = value
val mapped = toBeMapped?.let({ args0 -> of(args0) })
this.autoscalingGroupName = mapped
}
/**
* @param value 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.
*/
@JvmName("xmuuohmirihsdunj")
public suspend fun defaultResult(`value`: String?) {
val toBeMapped = value
val mapped = toBeMapped?.let({ args0 -> of(args0) })
this.defaultResult = mapped
}
/**
* @param value 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
*/
@JvmName("myxboovgocihcyhm")
public suspend fun heartbeatTimeout(`value`: Int?) {
val toBeMapped = value
val mapped = toBeMapped?.let({ args0 -> of(args0) })
this.heartbeatTimeout = mapped
}
/**
* @param value 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)
*/
@JvmName("fyujyjnsitvskkeg")
public suspend fun lifecycleTransition(`value`: String?) {
val toBeMapped = value
val mapped = toBeMapped?.let({ args0 -> of(args0) })
this.lifecycleTransition = mapped
}
/**
* @param value Name of the lifecycle hook.
*/
@JvmName("agojawyfdeulrobg")
public suspend fun name(`value`: String?) {
val toBeMapped = value
val mapped = toBeMapped?.let({ args0 -> of(args0) })
this.name = mapped
}
/**
* @param value Contains additional information that you want to include any time Auto Scaling sends a message to the notification target.
*/
@JvmName("ljkilyxdfwnopeyk")
public suspend fun notificationMetadata(`value`: String?) {
val toBeMapped = value
val mapped = toBeMapped?.let({ args0 -> of(args0) })
this.notificationMetadata = mapped
}
/**
* @param value 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.
*/
@JvmName("nvgipltqnpenxoli")
public suspend fun notificationTargetArn(`value`: String?) {
val toBeMapped = value
val mapped = toBeMapped?.let({ args0 -> of(args0) })
this.notificationTargetArn = mapped
}
/**
* @param value ARN of the IAM role that allows the Auto Scaling group to publish to the specified notification target.
*/
@JvmName("wnopckjldsbpkobc")
public suspend fun roleArn(`value`: String?) {
val toBeMapped = value
val mapped = toBeMapped?.let({ args0 -> of(args0) })
this.roleArn = mapped
}
internal fun build(): LifecycleHookArgs = LifecycleHookArgs(
autoscalingGroupName = autoscalingGroupName,
defaultResult = defaultResult,
heartbeatTimeout = heartbeatTimeout,
lifecycleTransition = lifecycleTransition,
name = name,
notificationMetadata = notificationMetadata,
notificationTargetArn = notificationTargetArn,
roleArn = roleArn,
)
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy