github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/autoscaling/notification.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 Group with Notification support, via SNS Topics. Each of 16 // the `notifications` map to a [Notification Configuration](https://docs.aws.amazon.com/AutoScaling/latest/APIReference/API_DescribeNotificationConfigurations.html) inside Amazon Web 17 // Services, and are applied to each AutoScaling Group you supply. 18 // 19 // ## Example Usage 20 // 21 // Basic usage: 22 // 23 // <!--Start PulumiCodeChooser --> 24 // ```go 25 // package main 26 // 27 // import ( 28 // 29 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/autoscaling" 30 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/sns" 31 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 32 // 33 // ) 34 // 35 // func main() { 36 // pulumi.Run(func(ctx *pulumi.Context) error { 37 // example, err := sns.NewTopic(ctx, "example", &sns.TopicArgs{ 38 // Name: pulumi.String("example-topic"), 39 // }) 40 // if err != nil { 41 // return err 42 // } 43 // bar, err := autoscaling.NewGroup(ctx, "bar", &autoscaling.GroupArgs{ 44 // Name: pulumi.String("foobar1-test"), 45 // }) 46 // if err != nil { 47 // return err 48 // } 49 // foo, err := autoscaling.NewGroup(ctx, "foo", &autoscaling.GroupArgs{ 50 // Name: pulumi.String("barfoo-test"), 51 // }) 52 // if err != nil { 53 // return err 54 // } 55 // _, err = autoscaling.NewNotification(ctx, "example_notifications", &autoscaling.NotificationArgs{ 56 // GroupNames: pulumi.StringArray{ 57 // bar.Name, 58 // foo.Name, 59 // }, 60 // Notifications: pulumi.StringArray{ 61 // pulumi.String("autoscaling:EC2_INSTANCE_LAUNCH"), 62 // pulumi.String("autoscaling:EC2_INSTANCE_TERMINATE"), 63 // pulumi.String("autoscaling:EC2_INSTANCE_LAUNCH_ERROR"), 64 // pulumi.String("autoscaling:EC2_INSTANCE_TERMINATE_ERROR"), 65 // }, 66 // TopicArn: example.Arn, 67 // }) 68 // if err != nil { 69 // return err 70 // } 71 // return nil 72 // }) 73 // } 74 // 75 // ``` 76 // <!--End PulumiCodeChooser --> 77 type Notification struct { 78 pulumi.CustomResourceState 79 80 // List of AutoScaling Group Names 81 GroupNames pulumi.StringArrayOutput `pulumi:"groupNames"` 82 // List of Notification Types that trigger 83 // notifications. Acceptable values are documented [in the AWS documentation here](https://docs.aws.amazon.com/AutoScaling/latest/APIReference/API_NotificationConfiguration.html) 84 Notifications pulumi.StringArrayOutput `pulumi:"notifications"` 85 // Topic ARN for notifications to be sent through 86 TopicArn pulumi.StringOutput `pulumi:"topicArn"` 87 } 88 89 // NewNotification registers a new resource with the given unique name, arguments, and options. 90 func NewNotification(ctx *pulumi.Context, 91 name string, args *NotificationArgs, opts ...pulumi.ResourceOption) (*Notification, error) { 92 if args == nil { 93 return nil, errors.New("missing one or more required arguments") 94 } 95 96 if args.GroupNames == nil { 97 return nil, errors.New("invalid value for required argument 'GroupNames'") 98 } 99 if args.Notifications == nil { 100 return nil, errors.New("invalid value for required argument 'Notifications'") 101 } 102 if args.TopicArn == nil { 103 return nil, errors.New("invalid value for required argument 'TopicArn'") 104 } 105 opts = internal.PkgResourceDefaultOpts(opts) 106 var resource Notification 107 err := ctx.RegisterResource("aws:autoscaling/notification:Notification", name, args, &resource, opts...) 108 if err != nil { 109 return nil, err 110 } 111 return &resource, nil 112 } 113 114 // GetNotification gets an existing Notification resource's state with the given name, ID, and optional 115 // state properties that are used to uniquely qualify the lookup (nil if not required). 116 func GetNotification(ctx *pulumi.Context, 117 name string, id pulumi.IDInput, state *NotificationState, opts ...pulumi.ResourceOption) (*Notification, error) { 118 var resource Notification 119 err := ctx.ReadResource("aws:autoscaling/notification:Notification", name, id, state, &resource, opts...) 120 if err != nil { 121 return nil, err 122 } 123 return &resource, nil 124 } 125 126 // Input properties used for looking up and filtering Notification resources. 127 type notificationState struct { 128 // List of AutoScaling Group Names 129 GroupNames []string `pulumi:"groupNames"` 130 // List of Notification Types that trigger 131 // notifications. Acceptable values are documented [in the AWS documentation here](https://docs.aws.amazon.com/AutoScaling/latest/APIReference/API_NotificationConfiguration.html) 132 Notifications []string `pulumi:"notifications"` 133 // Topic ARN for notifications to be sent through 134 TopicArn *string `pulumi:"topicArn"` 135 } 136 137 type NotificationState struct { 138 // List of AutoScaling Group Names 139 GroupNames pulumi.StringArrayInput 140 // List of Notification Types that trigger 141 // notifications. Acceptable values are documented [in the AWS documentation here](https://docs.aws.amazon.com/AutoScaling/latest/APIReference/API_NotificationConfiguration.html) 142 Notifications pulumi.StringArrayInput 143 // Topic ARN for notifications to be sent through 144 TopicArn pulumi.StringPtrInput 145 } 146 147 func (NotificationState) ElementType() reflect.Type { 148 return reflect.TypeOf((*notificationState)(nil)).Elem() 149 } 150 151 type notificationArgs struct { 152 // List of AutoScaling Group Names 153 GroupNames []string `pulumi:"groupNames"` 154 // List of Notification Types that trigger 155 // notifications. Acceptable values are documented [in the AWS documentation here](https://docs.aws.amazon.com/AutoScaling/latest/APIReference/API_NotificationConfiguration.html) 156 Notifications []string `pulumi:"notifications"` 157 // Topic ARN for notifications to be sent through 158 TopicArn string `pulumi:"topicArn"` 159 } 160 161 // The set of arguments for constructing a Notification resource. 162 type NotificationArgs struct { 163 // List of AutoScaling Group Names 164 GroupNames pulumi.StringArrayInput 165 // List of Notification Types that trigger 166 // notifications. Acceptable values are documented [in the AWS documentation here](https://docs.aws.amazon.com/AutoScaling/latest/APIReference/API_NotificationConfiguration.html) 167 Notifications pulumi.StringArrayInput 168 // Topic ARN for notifications to be sent through 169 TopicArn pulumi.StringInput 170 } 171 172 func (NotificationArgs) ElementType() reflect.Type { 173 return reflect.TypeOf((*notificationArgs)(nil)).Elem() 174 } 175 176 type NotificationInput interface { 177 pulumi.Input 178 179 ToNotificationOutput() NotificationOutput 180 ToNotificationOutputWithContext(ctx context.Context) NotificationOutput 181 } 182 183 func (*Notification) ElementType() reflect.Type { 184 return reflect.TypeOf((**Notification)(nil)).Elem() 185 } 186 187 func (i *Notification) ToNotificationOutput() NotificationOutput { 188 return i.ToNotificationOutputWithContext(context.Background()) 189 } 190 191 func (i *Notification) ToNotificationOutputWithContext(ctx context.Context) NotificationOutput { 192 return pulumi.ToOutputWithContext(ctx, i).(NotificationOutput) 193 } 194 195 // NotificationArrayInput is an input type that accepts NotificationArray and NotificationArrayOutput values. 196 // You can construct a concrete instance of `NotificationArrayInput` via: 197 // 198 // NotificationArray{ NotificationArgs{...} } 199 type NotificationArrayInput interface { 200 pulumi.Input 201 202 ToNotificationArrayOutput() NotificationArrayOutput 203 ToNotificationArrayOutputWithContext(context.Context) NotificationArrayOutput 204 } 205 206 type NotificationArray []NotificationInput 207 208 func (NotificationArray) ElementType() reflect.Type { 209 return reflect.TypeOf((*[]*Notification)(nil)).Elem() 210 } 211 212 func (i NotificationArray) ToNotificationArrayOutput() NotificationArrayOutput { 213 return i.ToNotificationArrayOutputWithContext(context.Background()) 214 } 215 216 func (i NotificationArray) ToNotificationArrayOutputWithContext(ctx context.Context) NotificationArrayOutput { 217 return pulumi.ToOutputWithContext(ctx, i).(NotificationArrayOutput) 218 } 219 220 // NotificationMapInput is an input type that accepts NotificationMap and NotificationMapOutput values. 221 // You can construct a concrete instance of `NotificationMapInput` via: 222 // 223 // NotificationMap{ "key": NotificationArgs{...} } 224 type NotificationMapInput interface { 225 pulumi.Input 226 227 ToNotificationMapOutput() NotificationMapOutput 228 ToNotificationMapOutputWithContext(context.Context) NotificationMapOutput 229 } 230 231 type NotificationMap map[string]NotificationInput 232 233 func (NotificationMap) ElementType() reflect.Type { 234 return reflect.TypeOf((*map[string]*Notification)(nil)).Elem() 235 } 236 237 func (i NotificationMap) ToNotificationMapOutput() NotificationMapOutput { 238 return i.ToNotificationMapOutputWithContext(context.Background()) 239 } 240 241 func (i NotificationMap) ToNotificationMapOutputWithContext(ctx context.Context) NotificationMapOutput { 242 return pulumi.ToOutputWithContext(ctx, i).(NotificationMapOutput) 243 } 244 245 type NotificationOutput struct{ *pulumi.OutputState } 246 247 func (NotificationOutput) ElementType() reflect.Type { 248 return reflect.TypeOf((**Notification)(nil)).Elem() 249 } 250 251 func (o NotificationOutput) ToNotificationOutput() NotificationOutput { 252 return o 253 } 254 255 func (o NotificationOutput) ToNotificationOutputWithContext(ctx context.Context) NotificationOutput { 256 return o 257 } 258 259 // List of AutoScaling Group Names 260 func (o NotificationOutput) GroupNames() pulumi.StringArrayOutput { 261 return o.ApplyT(func(v *Notification) pulumi.StringArrayOutput { return v.GroupNames }).(pulumi.StringArrayOutput) 262 } 263 264 // List of Notification Types that trigger 265 // notifications. Acceptable values are documented [in the AWS documentation here](https://docs.aws.amazon.com/AutoScaling/latest/APIReference/API_NotificationConfiguration.html) 266 func (o NotificationOutput) Notifications() pulumi.StringArrayOutput { 267 return o.ApplyT(func(v *Notification) pulumi.StringArrayOutput { return v.Notifications }).(pulumi.StringArrayOutput) 268 } 269 270 // Topic ARN for notifications to be sent through 271 func (o NotificationOutput) TopicArn() pulumi.StringOutput { 272 return o.ApplyT(func(v *Notification) pulumi.StringOutput { return v.TopicArn }).(pulumi.StringOutput) 273 } 274 275 type NotificationArrayOutput struct{ *pulumi.OutputState } 276 277 func (NotificationArrayOutput) ElementType() reflect.Type { 278 return reflect.TypeOf((*[]*Notification)(nil)).Elem() 279 } 280 281 func (o NotificationArrayOutput) ToNotificationArrayOutput() NotificationArrayOutput { 282 return o 283 } 284 285 func (o NotificationArrayOutput) ToNotificationArrayOutputWithContext(ctx context.Context) NotificationArrayOutput { 286 return o 287 } 288 289 func (o NotificationArrayOutput) Index(i pulumi.IntInput) NotificationOutput { 290 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Notification { 291 return vs[0].([]*Notification)[vs[1].(int)] 292 }).(NotificationOutput) 293 } 294 295 type NotificationMapOutput struct{ *pulumi.OutputState } 296 297 func (NotificationMapOutput) ElementType() reflect.Type { 298 return reflect.TypeOf((*map[string]*Notification)(nil)).Elem() 299 } 300 301 func (o NotificationMapOutput) ToNotificationMapOutput() NotificationMapOutput { 302 return o 303 } 304 305 func (o NotificationMapOutput) ToNotificationMapOutputWithContext(ctx context.Context) NotificationMapOutput { 306 return o 307 } 308 309 func (o NotificationMapOutput) MapIndex(k pulumi.StringInput) NotificationOutput { 310 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Notification { 311 return vs[0].(map[string]*Notification)[vs[1].(string)] 312 }).(NotificationOutput) 313 } 314 315 func init() { 316 pulumi.RegisterInputType(reflect.TypeOf((*NotificationInput)(nil)).Elem(), &Notification{}) 317 pulumi.RegisterInputType(reflect.TypeOf((*NotificationArrayInput)(nil)).Elem(), NotificationArray{}) 318 pulumi.RegisterInputType(reflect.TypeOf((*NotificationMapInput)(nil)).Elem(), NotificationMap{}) 319 pulumi.RegisterOutputType(NotificationOutput{}) 320 pulumi.RegisterOutputType(NotificationArrayOutput{}) 321 pulumi.RegisterOutputType(NotificationMapOutput{}) 322 }