/
activityLogAlert.go
430 lines (375 loc) · 18.2 KB
/
activityLogAlert.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
// Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT.
// *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
package monitoring
import (
"context"
"reflect"
"errors"
"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Manages an Activity Log Alert within Azure Monitor.
//
// ## Example Usage
//
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
// "github.com/pulumi/pulumi-azure/sdk/v5/go/azure/monitoring"
// "github.com/pulumi/pulumi-azure/sdk/v5/go/azure/storage"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// example, err := core.NewResourceGroup(ctx, "example", &core.ResourceGroupArgs{
// Name: pulumi.String("example-resources"),
// Location: pulumi.String("West Europe"),
// })
// if err != nil {
// return err
// }
// main, err := monitoring.NewActionGroup(ctx, "main", &monitoring.ActionGroupArgs{
// Name: pulumi.String("example-actiongroup"),
// ResourceGroupName: example.Name,
// ShortName: pulumi.String("p0action"),
// WebhookReceivers: monitoring.ActionGroupWebhookReceiverArray{
// &monitoring.ActionGroupWebhookReceiverArgs{
// Name: pulumi.String("callmyapi"),
// ServiceUri: pulumi.String("http://example.com/alert"),
// },
// },
// })
// if err != nil {
// return err
// }
// toMonitor, err := storage.NewAccount(ctx, "to_monitor", &storage.AccountArgs{
// Name: pulumi.String("examplesa"),
// ResourceGroupName: example.Name,
// Location: example.Location,
// AccountTier: pulumi.String("Standard"),
// AccountReplicationType: pulumi.String("GRS"),
// })
// if err != nil {
// return err
// }
// _, err = monitoring.NewActivityLogAlert(ctx, "main", &monitoring.ActivityLogAlertArgs{
// Name: pulumi.String("example-activitylogalert"),
// ResourceGroupName: example.Name,
// Scopes: pulumi.StringArray{
// example.ID(),
// },
// Description: pulumi.String("This alert will monitor a specific storage account updates."),
// Criteria: &monitoring.ActivityLogAlertCriteriaArgs{
// ResourceId: toMonitor.ID(),
// OperationName: pulumi.String("Microsoft.Storage/storageAccounts/write"),
// Category: pulumi.String("Recommendation"),
// },
// Actions: monitoring.ActivityLogAlertActionArray{
// &monitoring.ActivityLogAlertActionArgs{
// ActionGroupId: main.ID(),
// WebhookProperties: pulumi.StringMap{
// "from": pulumi.String("source"),
// },
// },
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
//
// ## Import
//
// Activity log alerts can be imported using the `resource id`, e.g.
//
// ```sh
// $ pulumi import azure:monitoring/activityLogAlert:ActivityLogAlert example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Insights/activityLogAlerts/myalertname
// ```
type ActivityLogAlert struct {
pulumi.CustomResourceState
// One or more `action` blocks as defined below.
Actions ActivityLogAlertActionArrayOutput `pulumi:"actions"`
// A `criteria` block as defined below.
Criteria ActivityLogAlertCriteriaOutput `pulumi:"criteria"`
// The description of this activity log alert.
Description pulumi.StringPtrOutput `pulumi:"description"`
// Should this Activity Log Alert be enabled? Defaults to `true`.
Enabled pulumi.BoolPtrOutput `pulumi:"enabled"`
// The Azure Region where the activity log alert rule should exist. Changing this forces a new resource to be created. Defaults to `global`.
Location pulumi.StringOutput `pulumi:"location"`
// The name of the activity log alert. Changing this forces a new resource to be created.
Name pulumi.StringOutput `pulumi:"name"`
// The name of the resource group in which to create the activity log alert instance. Changing this forces a new resource to be created.
ResourceGroupName pulumi.StringOutput `pulumi:"resourceGroupName"`
// The Scope at which the Activity Log should be applied. A list of strings which could be a resource group , or a subscription, or a resource ID (such as a Storage Account).
Scopes pulumi.StringArrayOutput `pulumi:"scopes"`
// A mapping of tags to assign to the resource.
Tags pulumi.StringMapOutput `pulumi:"tags"`
}
// NewActivityLogAlert registers a new resource with the given unique name, arguments, and options.
func NewActivityLogAlert(ctx *pulumi.Context,
name string, args *ActivityLogAlertArgs, opts ...pulumi.ResourceOption) (*ActivityLogAlert, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.Criteria == nil {
return nil, errors.New("invalid value for required argument 'Criteria'")
}
if args.ResourceGroupName == nil {
return nil, errors.New("invalid value for required argument 'ResourceGroupName'")
}
if args.Scopes == nil {
return nil, errors.New("invalid value for required argument 'Scopes'")
}
opts = internal.PkgResourceDefaultOpts(opts)
var resource ActivityLogAlert
err := ctx.RegisterResource("azure:monitoring/activityLogAlert:ActivityLogAlert", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetActivityLogAlert gets an existing ActivityLogAlert resource's state with the given name, ID, and optional
// state properties that are used to uniquely qualify the lookup (nil if not required).
func GetActivityLogAlert(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *ActivityLogAlertState, opts ...pulumi.ResourceOption) (*ActivityLogAlert, error) {
var resource ActivityLogAlert
err := ctx.ReadResource("azure:monitoring/activityLogAlert:ActivityLogAlert", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering ActivityLogAlert resources.
type activityLogAlertState struct {
// One or more `action` blocks as defined below.
Actions []ActivityLogAlertAction `pulumi:"actions"`
// A `criteria` block as defined below.
Criteria *ActivityLogAlertCriteria `pulumi:"criteria"`
// The description of this activity log alert.
Description *string `pulumi:"description"`
// Should this Activity Log Alert be enabled? Defaults to `true`.
Enabled *bool `pulumi:"enabled"`
// The Azure Region where the activity log alert rule should exist. Changing this forces a new resource to be created. Defaults to `global`.
Location *string `pulumi:"location"`
// The name of the activity log alert. Changing this forces a new resource to be created.
Name *string `pulumi:"name"`
// The name of the resource group in which to create the activity log alert instance. Changing this forces a new resource to be created.
ResourceGroupName *string `pulumi:"resourceGroupName"`
// The Scope at which the Activity Log should be applied. A list of strings which could be a resource group , or a subscription, or a resource ID (such as a Storage Account).
Scopes []string `pulumi:"scopes"`
// A mapping of tags to assign to the resource.
Tags map[string]string `pulumi:"tags"`
}
type ActivityLogAlertState struct {
// One or more `action` blocks as defined below.
Actions ActivityLogAlertActionArrayInput
// A `criteria` block as defined below.
Criteria ActivityLogAlertCriteriaPtrInput
// The description of this activity log alert.
Description pulumi.StringPtrInput
// Should this Activity Log Alert be enabled? Defaults to `true`.
Enabled pulumi.BoolPtrInput
// The Azure Region where the activity log alert rule should exist. Changing this forces a new resource to be created. Defaults to `global`.
Location pulumi.StringPtrInput
// The name of the activity log alert. Changing this forces a new resource to be created.
Name pulumi.StringPtrInput
// The name of the resource group in which to create the activity log alert instance. Changing this forces a new resource to be created.
ResourceGroupName pulumi.StringPtrInput
// The Scope at which the Activity Log should be applied. A list of strings which could be a resource group , or a subscription, or a resource ID (such as a Storage Account).
Scopes pulumi.StringArrayInput
// A mapping of tags to assign to the resource.
Tags pulumi.StringMapInput
}
func (ActivityLogAlertState) ElementType() reflect.Type {
return reflect.TypeOf((*activityLogAlertState)(nil)).Elem()
}
type activityLogAlertArgs struct {
// One or more `action` blocks as defined below.
Actions []ActivityLogAlertAction `pulumi:"actions"`
// A `criteria` block as defined below.
Criteria ActivityLogAlertCriteria `pulumi:"criteria"`
// The description of this activity log alert.
Description *string `pulumi:"description"`
// Should this Activity Log Alert be enabled? Defaults to `true`.
Enabled *bool `pulumi:"enabled"`
// The Azure Region where the activity log alert rule should exist. Changing this forces a new resource to be created. Defaults to `global`.
Location *string `pulumi:"location"`
// The name of the activity log alert. Changing this forces a new resource to be created.
Name *string `pulumi:"name"`
// The name of the resource group in which to create the activity log alert instance. Changing this forces a new resource to be created.
ResourceGroupName string `pulumi:"resourceGroupName"`
// The Scope at which the Activity Log should be applied. A list of strings which could be a resource group , or a subscription, or a resource ID (such as a Storage Account).
Scopes []string `pulumi:"scopes"`
// A mapping of tags to assign to the resource.
Tags map[string]string `pulumi:"tags"`
}
// The set of arguments for constructing a ActivityLogAlert resource.
type ActivityLogAlertArgs struct {
// One or more `action` blocks as defined below.
Actions ActivityLogAlertActionArrayInput
// A `criteria` block as defined below.
Criteria ActivityLogAlertCriteriaInput
// The description of this activity log alert.
Description pulumi.StringPtrInput
// Should this Activity Log Alert be enabled? Defaults to `true`.
Enabled pulumi.BoolPtrInput
// The Azure Region where the activity log alert rule should exist. Changing this forces a new resource to be created. Defaults to `global`.
Location pulumi.StringPtrInput
// The name of the activity log alert. Changing this forces a new resource to be created.
Name pulumi.StringPtrInput
// The name of the resource group in which to create the activity log alert instance. Changing this forces a new resource to be created.
ResourceGroupName pulumi.StringInput
// The Scope at which the Activity Log should be applied. A list of strings which could be a resource group , or a subscription, or a resource ID (such as a Storage Account).
Scopes pulumi.StringArrayInput
// A mapping of tags to assign to the resource.
Tags pulumi.StringMapInput
}
func (ActivityLogAlertArgs) ElementType() reflect.Type {
return reflect.TypeOf((*activityLogAlertArgs)(nil)).Elem()
}
type ActivityLogAlertInput interface {
pulumi.Input
ToActivityLogAlertOutput() ActivityLogAlertOutput
ToActivityLogAlertOutputWithContext(ctx context.Context) ActivityLogAlertOutput
}
func (*ActivityLogAlert) ElementType() reflect.Type {
return reflect.TypeOf((**ActivityLogAlert)(nil)).Elem()
}
func (i *ActivityLogAlert) ToActivityLogAlertOutput() ActivityLogAlertOutput {
return i.ToActivityLogAlertOutputWithContext(context.Background())
}
func (i *ActivityLogAlert) ToActivityLogAlertOutputWithContext(ctx context.Context) ActivityLogAlertOutput {
return pulumi.ToOutputWithContext(ctx, i).(ActivityLogAlertOutput)
}
// ActivityLogAlertArrayInput is an input type that accepts ActivityLogAlertArray and ActivityLogAlertArrayOutput values.
// You can construct a concrete instance of `ActivityLogAlertArrayInput` via:
//
// ActivityLogAlertArray{ ActivityLogAlertArgs{...} }
type ActivityLogAlertArrayInput interface {
pulumi.Input
ToActivityLogAlertArrayOutput() ActivityLogAlertArrayOutput
ToActivityLogAlertArrayOutputWithContext(context.Context) ActivityLogAlertArrayOutput
}
type ActivityLogAlertArray []ActivityLogAlertInput
func (ActivityLogAlertArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*ActivityLogAlert)(nil)).Elem()
}
func (i ActivityLogAlertArray) ToActivityLogAlertArrayOutput() ActivityLogAlertArrayOutput {
return i.ToActivityLogAlertArrayOutputWithContext(context.Background())
}
func (i ActivityLogAlertArray) ToActivityLogAlertArrayOutputWithContext(ctx context.Context) ActivityLogAlertArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(ActivityLogAlertArrayOutput)
}
// ActivityLogAlertMapInput is an input type that accepts ActivityLogAlertMap and ActivityLogAlertMapOutput values.
// You can construct a concrete instance of `ActivityLogAlertMapInput` via:
//
// ActivityLogAlertMap{ "key": ActivityLogAlertArgs{...} }
type ActivityLogAlertMapInput interface {
pulumi.Input
ToActivityLogAlertMapOutput() ActivityLogAlertMapOutput
ToActivityLogAlertMapOutputWithContext(context.Context) ActivityLogAlertMapOutput
}
type ActivityLogAlertMap map[string]ActivityLogAlertInput
func (ActivityLogAlertMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*ActivityLogAlert)(nil)).Elem()
}
func (i ActivityLogAlertMap) ToActivityLogAlertMapOutput() ActivityLogAlertMapOutput {
return i.ToActivityLogAlertMapOutputWithContext(context.Background())
}
func (i ActivityLogAlertMap) ToActivityLogAlertMapOutputWithContext(ctx context.Context) ActivityLogAlertMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(ActivityLogAlertMapOutput)
}
type ActivityLogAlertOutput struct{ *pulumi.OutputState }
func (ActivityLogAlertOutput) ElementType() reflect.Type {
return reflect.TypeOf((**ActivityLogAlert)(nil)).Elem()
}
func (o ActivityLogAlertOutput) ToActivityLogAlertOutput() ActivityLogAlertOutput {
return o
}
func (o ActivityLogAlertOutput) ToActivityLogAlertOutputWithContext(ctx context.Context) ActivityLogAlertOutput {
return o
}
// One or more `action` blocks as defined below.
func (o ActivityLogAlertOutput) Actions() ActivityLogAlertActionArrayOutput {
return o.ApplyT(func(v *ActivityLogAlert) ActivityLogAlertActionArrayOutput { return v.Actions }).(ActivityLogAlertActionArrayOutput)
}
// A `criteria` block as defined below.
func (o ActivityLogAlertOutput) Criteria() ActivityLogAlertCriteriaOutput {
return o.ApplyT(func(v *ActivityLogAlert) ActivityLogAlertCriteriaOutput { return v.Criteria }).(ActivityLogAlertCriteriaOutput)
}
// The description of this activity log alert.
func (o ActivityLogAlertOutput) Description() pulumi.StringPtrOutput {
return o.ApplyT(func(v *ActivityLogAlert) pulumi.StringPtrOutput { return v.Description }).(pulumi.StringPtrOutput)
}
// Should this Activity Log Alert be enabled? Defaults to `true`.
func (o ActivityLogAlertOutput) Enabled() pulumi.BoolPtrOutput {
return o.ApplyT(func(v *ActivityLogAlert) pulumi.BoolPtrOutput { return v.Enabled }).(pulumi.BoolPtrOutput)
}
// The Azure Region where the activity log alert rule should exist. Changing this forces a new resource to be created. Defaults to `global`.
func (o ActivityLogAlertOutput) Location() pulumi.StringOutput {
return o.ApplyT(func(v *ActivityLogAlert) pulumi.StringOutput { return v.Location }).(pulumi.StringOutput)
}
// The name of the activity log alert. Changing this forces a new resource to be created.
func (o ActivityLogAlertOutput) Name() pulumi.StringOutput {
return o.ApplyT(func(v *ActivityLogAlert) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
}
// The name of the resource group in which to create the activity log alert instance. Changing this forces a new resource to be created.
func (o ActivityLogAlertOutput) ResourceGroupName() pulumi.StringOutput {
return o.ApplyT(func(v *ActivityLogAlert) pulumi.StringOutput { return v.ResourceGroupName }).(pulumi.StringOutput)
}
// The Scope at which the Activity Log should be applied. A list of strings which could be a resource group , or a subscription, or a resource ID (such as a Storage Account).
func (o ActivityLogAlertOutput) Scopes() pulumi.StringArrayOutput {
return o.ApplyT(func(v *ActivityLogAlert) pulumi.StringArrayOutput { return v.Scopes }).(pulumi.StringArrayOutput)
}
// A mapping of tags to assign to the resource.
func (o ActivityLogAlertOutput) Tags() pulumi.StringMapOutput {
return o.ApplyT(func(v *ActivityLogAlert) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)
}
type ActivityLogAlertArrayOutput struct{ *pulumi.OutputState }
func (ActivityLogAlertArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*ActivityLogAlert)(nil)).Elem()
}
func (o ActivityLogAlertArrayOutput) ToActivityLogAlertArrayOutput() ActivityLogAlertArrayOutput {
return o
}
func (o ActivityLogAlertArrayOutput) ToActivityLogAlertArrayOutputWithContext(ctx context.Context) ActivityLogAlertArrayOutput {
return o
}
func (o ActivityLogAlertArrayOutput) Index(i pulumi.IntInput) ActivityLogAlertOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *ActivityLogAlert {
return vs[0].([]*ActivityLogAlert)[vs[1].(int)]
}).(ActivityLogAlertOutput)
}
type ActivityLogAlertMapOutput struct{ *pulumi.OutputState }
func (ActivityLogAlertMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*ActivityLogAlert)(nil)).Elem()
}
func (o ActivityLogAlertMapOutput) ToActivityLogAlertMapOutput() ActivityLogAlertMapOutput {
return o
}
func (o ActivityLogAlertMapOutput) ToActivityLogAlertMapOutputWithContext(ctx context.Context) ActivityLogAlertMapOutput {
return o
}
func (o ActivityLogAlertMapOutput) MapIndex(k pulumi.StringInput) ActivityLogAlertOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *ActivityLogAlert {
return vs[0].(map[string]*ActivityLogAlert)[vs[1].(string)]
}).(ActivityLogAlertOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*ActivityLogAlertInput)(nil)).Elem(), &ActivityLogAlert{})
pulumi.RegisterInputType(reflect.TypeOf((*ActivityLogAlertArrayInput)(nil)).Elem(), ActivityLogAlertArray{})
pulumi.RegisterInputType(reflect.TypeOf((*ActivityLogAlertMapInput)(nil)).Elem(), ActivityLogAlertMap{})
pulumi.RegisterOutputType(ActivityLogAlertOutput{})
pulumi.RegisterOutputType(ActivityLogAlertArrayOutput{})
pulumi.RegisterOutputType(ActivityLogAlertMapOutput{})
}