github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/autoscaling/lifecycleHook.go (about) 1 // Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT. 2 // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! *** 3 4 package autoscaling 5 6 import ( 7 "context" 8 "reflect" 9 10 "errors" 11 "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal" 12 "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 13 ) 14 15 // Provides an AutoScaling Lifecycle Hook resource. 16 // 17 // > **NOTE:** This provider has two types of ways you can add lifecycle hooks - via 18 // the `initialLifecycleHook` attribute from the 19 // `autoscaling.Group` 20 // resource, or via this one. Hooks added via this resource will not be added 21 // until the autoscaling group has been created, and depending on your 22 // capacity 23 // settings, after the initial instances have been launched, creating unintended 24 // behavior. If you need hooks to run on all instances, add them with 25 // `initialLifecycleHook` in 26 // `autoscaling.Group`, 27 // but take care to not duplicate those hooks with this resource. 28 // 29 // ## Example Usage 30 // 31 // <!--Start PulumiCodeChooser --> 32 // ```go 33 // package main 34 // 35 // import ( 36 // 37 // "encoding/json" 38 // 39 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/autoscaling" 40 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 41 // 42 // ) 43 // 44 // func main() { 45 // pulumi.Run(func(ctx *pulumi.Context) error { 46 // foobar, err := autoscaling.NewGroup(ctx, "foobar", &autoscaling.GroupArgs{ 47 // AvailabilityZones: pulumi.StringArray{ 48 // pulumi.String("us-west-2a"), 49 // }, 50 // Name: pulumi.String("test-foobar5"), 51 // HealthCheckType: pulumi.String("EC2"), 52 // TerminationPolicies: pulumi.StringArray{ 53 // pulumi.String("OldestInstance"), 54 // }, 55 // Tags: autoscaling.GroupTagArray{ 56 // &autoscaling.GroupTagArgs{ 57 // Key: pulumi.String("Foo"), 58 // Value: pulumi.String("foo-bar"), 59 // PropagateAtLaunch: pulumi.Bool(true), 60 // }, 61 // }, 62 // }) 63 // if err != nil { 64 // return err 65 // } 66 // tmpJSON0, err := json.Marshal(map[string]interface{}{ 67 // "foo": "bar", 68 // }) 69 // if err != nil { 70 // return err 71 // } 72 // json0 := string(tmpJSON0) 73 // _, err = autoscaling.NewLifecycleHook(ctx, "foobar", &autoscaling.LifecycleHookArgs{ 74 // Name: pulumi.String("foobar"), 75 // AutoscalingGroupName: foobar.Name, 76 // DefaultResult: pulumi.String("CONTINUE"), 77 // HeartbeatTimeout: pulumi.Int(2000), 78 // LifecycleTransition: pulumi.String("autoscaling:EC2_INSTANCE_LAUNCHING"), 79 // NotificationMetadata: pulumi.String(json0), 80 // NotificationTargetArn: pulumi.String("arn:aws:sqs:us-east-1:444455556666:queue1*"), 81 // RoleArn: pulumi.String("arn:aws:iam::123456789012:role/S3Access"), 82 // }) 83 // if err != nil { 84 // return err 85 // } 86 // return nil 87 // }) 88 // } 89 // 90 // ``` 91 // <!--End PulumiCodeChooser --> 92 // 93 // ## Import 94 // 95 // Using `pulumi import`, import AutoScaling Lifecycle Hooks using the role autoscaling_group_name and name separated by `/`. For example: 96 // 97 // ```sh 98 // $ pulumi import aws:autoscaling/lifecycleHook:LifecycleHook test-lifecycle-hook asg-name/lifecycle-hook-name 99 // ``` 100 type LifecycleHook struct { 101 pulumi.CustomResourceState 102 103 // Name of the Auto Scaling group to which you want to assign the lifecycle hook 104 AutoscalingGroupName pulumi.StringOutput `pulumi:"autoscalingGroupName"` 105 // 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. 106 DefaultResult pulumi.StringOutput `pulumi:"defaultResult"` 107 // 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 108 HeartbeatTimeout pulumi.IntPtrOutput `pulumi:"heartbeatTimeout"` 109 // 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) 110 LifecycleTransition pulumi.StringOutput `pulumi:"lifecycleTransition"` 111 // Name of the lifecycle hook. 112 Name pulumi.StringOutput `pulumi:"name"` 113 // Contains additional information that you want to include any time Auto Scaling sends a message to the notification target. 114 NotificationMetadata pulumi.StringPtrOutput `pulumi:"notificationMetadata"` 115 // 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. 116 NotificationTargetArn pulumi.StringPtrOutput `pulumi:"notificationTargetArn"` 117 // ARN of the IAM role that allows the Auto Scaling group to publish to the specified notification target. 118 RoleArn pulumi.StringPtrOutput `pulumi:"roleArn"` 119 } 120 121 // NewLifecycleHook registers a new resource with the given unique name, arguments, and options. 122 func NewLifecycleHook(ctx *pulumi.Context, 123 name string, args *LifecycleHookArgs, opts ...pulumi.ResourceOption) (*LifecycleHook, error) { 124 if args == nil { 125 return nil, errors.New("missing one or more required arguments") 126 } 127 128 if args.AutoscalingGroupName == nil { 129 return nil, errors.New("invalid value for required argument 'AutoscalingGroupName'") 130 } 131 if args.LifecycleTransition == nil { 132 return nil, errors.New("invalid value for required argument 'LifecycleTransition'") 133 } 134 opts = internal.PkgResourceDefaultOpts(opts) 135 var resource LifecycleHook 136 err := ctx.RegisterResource("aws:autoscaling/lifecycleHook:LifecycleHook", name, args, &resource, opts...) 137 if err != nil { 138 return nil, err 139 } 140 return &resource, nil 141 } 142 143 // GetLifecycleHook gets an existing LifecycleHook resource's state with the given name, ID, and optional 144 // state properties that are used to uniquely qualify the lookup (nil if not required). 145 func GetLifecycleHook(ctx *pulumi.Context, 146 name string, id pulumi.IDInput, state *LifecycleHookState, opts ...pulumi.ResourceOption) (*LifecycleHook, error) { 147 var resource LifecycleHook 148 err := ctx.ReadResource("aws:autoscaling/lifecycleHook:LifecycleHook", name, id, state, &resource, opts...) 149 if err != nil { 150 return nil, err 151 } 152 return &resource, nil 153 } 154 155 // Input properties used for looking up and filtering LifecycleHook resources. 156 type lifecycleHookState struct { 157 // Name of the Auto Scaling group to which you want to assign the lifecycle hook 158 AutoscalingGroupName *string `pulumi:"autoscalingGroupName"` 159 // 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. 160 DefaultResult *string `pulumi:"defaultResult"` 161 // 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 162 HeartbeatTimeout *int `pulumi:"heartbeatTimeout"` 163 // 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) 164 LifecycleTransition *string `pulumi:"lifecycleTransition"` 165 // Name of the lifecycle hook. 166 Name *string `pulumi:"name"` 167 // Contains additional information that you want to include any time Auto Scaling sends a message to the notification target. 168 NotificationMetadata *string `pulumi:"notificationMetadata"` 169 // 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. 170 NotificationTargetArn *string `pulumi:"notificationTargetArn"` 171 // ARN of the IAM role that allows the Auto Scaling group to publish to the specified notification target. 172 RoleArn *string `pulumi:"roleArn"` 173 } 174 175 type LifecycleHookState struct { 176 // Name of the Auto Scaling group to which you want to assign the lifecycle hook 177 AutoscalingGroupName pulumi.StringPtrInput 178 // 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. 179 DefaultResult pulumi.StringPtrInput 180 // 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 181 HeartbeatTimeout pulumi.IntPtrInput 182 // 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) 183 LifecycleTransition pulumi.StringPtrInput 184 // Name of the lifecycle hook. 185 Name pulumi.StringPtrInput 186 // Contains additional information that you want to include any time Auto Scaling sends a message to the notification target. 187 NotificationMetadata pulumi.StringPtrInput 188 // 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. 189 NotificationTargetArn pulumi.StringPtrInput 190 // ARN of the IAM role that allows the Auto Scaling group to publish to the specified notification target. 191 RoleArn pulumi.StringPtrInput 192 } 193 194 func (LifecycleHookState) ElementType() reflect.Type { 195 return reflect.TypeOf((*lifecycleHookState)(nil)).Elem() 196 } 197 198 type lifecycleHookArgs struct { 199 // Name of the Auto Scaling group to which you want to assign the lifecycle hook 200 AutoscalingGroupName string `pulumi:"autoscalingGroupName"` 201 // 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. 202 DefaultResult *string `pulumi:"defaultResult"` 203 // 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 204 HeartbeatTimeout *int `pulumi:"heartbeatTimeout"` 205 // 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) 206 LifecycleTransition string `pulumi:"lifecycleTransition"` 207 // Name of the lifecycle hook. 208 Name *string `pulumi:"name"` 209 // Contains additional information that you want to include any time Auto Scaling sends a message to the notification target. 210 NotificationMetadata *string `pulumi:"notificationMetadata"` 211 // 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. 212 NotificationTargetArn *string `pulumi:"notificationTargetArn"` 213 // ARN of the IAM role that allows the Auto Scaling group to publish to the specified notification target. 214 RoleArn *string `pulumi:"roleArn"` 215 } 216 217 // The set of arguments for constructing a LifecycleHook resource. 218 type LifecycleHookArgs struct { 219 // Name of the Auto Scaling group to which you want to assign the lifecycle hook 220 AutoscalingGroupName pulumi.StringInput 221 // 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. 222 DefaultResult pulumi.StringPtrInput 223 // 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 224 HeartbeatTimeout pulumi.IntPtrInput 225 // 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) 226 LifecycleTransition pulumi.StringInput 227 // Name of the lifecycle hook. 228 Name pulumi.StringPtrInput 229 // Contains additional information that you want to include any time Auto Scaling sends a message to the notification target. 230 NotificationMetadata pulumi.StringPtrInput 231 // 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. 232 NotificationTargetArn pulumi.StringPtrInput 233 // ARN of the IAM role that allows the Auto Scaling group to publish to the specified notification target. 234 RoleArn pulumi.StringPtrInput 235 } 236 237 func (LifecycleHookArgs) ElementType() reflect.Type { 238 return reflect.TypeOf((*lifecycleHookArgs)(nil)).Elem() 239 } 240 241 type LifecycleHookInput interface { 242 pulumi.Input 243 244 ToLifecycleHookOutput() LifecycleHookOutput 245 ToLifecycleHookOutputWithContext(ctx context.Context) LifecycleHookOutput 246 } 247 248 func (*LifecycleHook) ElementType() reflect.Type { 249 return reflect.TypeOf((**LifecycleHook)(nil)).Elem() 250 } 251 252 func (i *LifecycleHook) ToLifecycleHookOutput() LifecycleHookOutput { 253 return i.ToLifecycleHookOutputWithContext(context.Background()) 254 } 255 256 func (i *LifecycleHook) ToLifecycleHookOutputWithContext(ctx context.Context) LifecycleHookOutput { 257 return pulumi.ToOutputWithContext(ctx, i).(LifecycleHookOutput) 258 } 259 260 // LifecycleHookArrayInput is an input type that accepts LifecycleHookArray and LifecycleHookArrayOutput values. 261 // You can construct a concrete instance of `LifecycleHookArrayInput` via: 262 // 263 // LifecycleHookArray{ LifecycleHookArgs{...} } 264 type LifecycleHookArrayInput interface { 265 pulumi.Input 266 267 ToLifecycleHookArrayOutput() LifecycleHookArrayOutput 268 ToLifecycleHookArrayOutputWithContext(context.Context) LifecycleHookArrayOutput 269 } 270 271 type LifecycleHookArray []LifecycleHookInput 272 273 func (LifecycleHookArray) ElementType() reflect.Type { 274 return reflect.TypeOf((*[]*LifecycleHook)(nil)).Elem() 275 } 276 277 func (i LifecycleHookArray) ToLifecycleHookArrayOutput() LifecycleHookArrayOutput { 278 return i.ToLifecycleHookArrayOutputWithContext(context.Background()) 279 } 280 281 func (i LifecycleHookArray) ToLifecycleHookArrayOutputWithContext(ctx context.Context) LifecycleHookArrayOutput { 282 return pulumi.ToOutputWithContext(ctx, i).(LifecycleHookArrayOutput) 283 } 284 285 // LifecycleHookMapInput is an input type that accepts LifecycleHookMap and LifecycleHookMapOutput values. 286 // You can construct a concrete instance of `LifecycleHookMapInput` via: 287 // 288 // LifecycleHookMap{ "key": LifecycleHookArgs{...} } 289 type LifecycleHookMapInput interface { 290 pulumi.Input 291 292 ToLifecycleHookMapOutput() LifecycleHookMapOutput 293 ToLifecycleHookMapOutputWithContext(context.Context) LifecycleHookMapOutput 294 } 295 296 type LifecycleHookMap map[string]LifecycleHookInput 297 298 func (LifecycleHookMap) ElementType() reflect.Type { 299 return reflect.TypeOf((*map[string]*LifecycleHook)(nil)).Elem() 300 } 301 302 func (i LifecycleHookMap) ToLifecycleHookMapOutput() LifecycleHookMapOutput { 303 return i.ToLifecycleHookMapOutputWithContext(context.Background()) 304 } 305 306 func (i LifecycleHookMap) ToLifecycleHookMapOutputWithContext(ctx context.Context) LifecycleHookMapOutput { 307 return pulumi.ToOutputWithContext(ctx, i).(LifecycleHookMapOutput) 308 } 309 310 type LifecycleHookOutput struct{ *pulumi.OutputState } 311 312 func (LifecycleHookOutput) ElementType() reflect.Type { 313 return reflect.TypeOf((**LifecycleHook)(nil)).Elem() 314 } 315 316 func (o LifecycleHookOutput) ToLifecycleHookOutput() LifecycleHookOutput { 317 return o 318 } 319 320 func (o LifecycleHookOutput) ToLifecycleHookOutputWithContext(ctx context.Context) LifecycleHookOutput { 321 return o 322 } 323 324 // Name of the Auto Scaling group to which you want to assign the lifecycle hook 325 func (o LifecycleHookOutput) AutoscalingGroupName() pulumi.StringOutput { 326 return o.ApplyT(func(v *LifecycleHook) pulumi.StringOutput { return v.AutoscalingGroupName }).(pulumi.StringOutput) 327 } 328 329 // 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. 330 func (o LifecycleHookOutput) DefaultResult() pulumi.StringOutput { 331 return o.ApplyT(func(v *LifecycleHook) pulumi.StringOutput { return v.DefaultResult }).(pulumi.StringOutput) 332 } 333 334 // 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 335 func (o LifecycleHookOutput) HeartbeatTimeout() pulumi.IntPtrOutput { 336 return o.ApplyT(func(v *LifecycleHook) pulumi.IntPtrOutput { return v.HeartbeatTimeout }).(pulumi.IntPtrOutput) 337 } 338 339 // 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) 340 func (o LifecycleHookOutput) LifecycleTransition() pulumi.StringOutput { 341 return o.ApplyT(func(v *LifecycleHook) pulumi.StringOutput { return v.LifecycleTransition }).(pulumi.StringOutput) 342 } 343 344 // Name of the lifecycle hook. 345 func (o LifecycleHookOutput) Name() pulumi.StringOutput { 346 return o.ApplyT(func(v *LifecycleHook) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput) 347 } 348 349 // Contains additional information that you want to include any time Auto Scaling sends a message to the notification target. 350 func (o LifecycleHookOutput) NotificationMetadata() pulumi.StringPtrOutput { 351 return o.ApplyT(func(v *LifecycleHook) pulumi.StringPtrOutput { return v.NotificationMetadata }).(pulumi.StringPtrOutput) 352 } 353 354 // 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. 355 func (o LifecycleHookOutput) NotificationTargetArn() pulumi.StringPtrOutput { 356 return o.ApplyT(func(v *LifecycleHook) pulumi.StringPtrOutput { return v.NotificationTargetArn }).(pulumi.StringPtrOutput) 357 } 358 359 // ARN of the IAM role that allows the Auto Scaling group to publish to the specified notification target. 360 func (o LifecycleHookOutput) RoleArn() pulumi.StringPtrOutput { 361 return o.ApplyT(func(v *LifecycleHook) pulumi.StringPtrOutput { return v.RoleArn }).(pulumi.StringPtrOutput) 362 } 363 364 type LifecycleHookArrayOutput struct{ *pulumi.OutputState } 365 366 func (LifecycleHookArrayOutput) ElementType() reflect.Type { 367 return reflect.TypeOf((*[]*LifecycleHook)(nil)).Elem() 368 } 369 370 func (o LifecycleHookArrayOutput) ToLifecycleHookArrayOutput() LifecycleHookArrayOutput { 371 return o 372 } 373 374 func (o LifecycleHookArrayOutput) ToLifecycleHookArrayOutputWithContext(ctx context.Context) LifecycleHookArrayOutput { 375 return o 376 } 377 378 func (o LifecycleHookArrayOutput) Index(i pulumi.IntInput) LifecycleHookOutput { 379 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *LifecycleHook { 380 return vs[0].([]*LifecycleHook)[vs[1].(int)] 381 }).(LifecycleHookOutput) 382 } 383 384 type LifecycleHookMapOutput struct{ *pulumi.OutputState } 385 386 func (LifecycleHookMapOutput) ElementType() reflect.Type { 387 return reflect.TypeOf((*map[string]*LifecycleHook)(nil)).Elem() 388 } 389 390 func (o LifecycleHookMapOutput) ToLifecycleHookMapOutput() LifecycleHookMapOutput { 391 return o 392 } 393 394 func (o LifecycleHookMapOutput) ToLifecycleHookMapOutputWithContext(ctx context.Context) LifecycleHookMapOutput { 395 return o 396 } 397 398 func (o LifecycleHookMapOutput) MapIndex(k pulumi.StringInput) LifecycleHookOutput { 399 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *LifecycleHook { 400 return vs[0].(map[string]*LifecycleHook)[vs[1].(string)] 401 }).(LifecycleHookOutput) 402 } 403 404 func init() { 405 pulumi.RegisterInputType(reflect.TypeOf((*LifecycleHookInput)(nil)).Elem(), &LifecycleHook{}) 406 pulumi.RegisterInputType(reflect.TypeOf((*LifecycleHookArrayInput)(nil)).Elem(), LifecycleHookArray{}) 407 pulumi.RegisterInputType(reflect.TypeOf((*LifecycleHookMapInput)(nil)).Elem(), LifecycleHookMap{}) 408 pulumi.RegisterOutputType(LifecycleHookOutput{}) 409 pulumi.RegisterOutputType(LifecycleHookArrayOutput{}) 410 pulumi.RegisterOutputType(LifecycleHookMapOutput{}) 411 }