/
budgetManagementGroup.go
429 lines (375 loc) · 19 KB
/
budgetManagementGroup.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
// 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 consumption
import (
"context"
"reflect"
"errors"
"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Manages a Consumption Budget for a Management Group.
//
// ## Example Usage
//
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-azure/sdk/v5/go/azure/consumption"
// "github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
// "github.com/pulumi/pulumi-azure/sdk/v5/go/azure/management"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// example, err := management.NewGroup(ctx, "example", &management.GroupArgs{
// DisplayName: pulumi.String("example"),
// })
// if err != nil {
// return err
// }
// exampleResourceGroup, err := core.NewResourceGroup(ctx, "example", &core.ResourceGroupArgs{
// Name: pulumi.String("example"),
// Location: pulumi.String("eastus"),
// })
// if err != nil {
// return err
// }
// _, err = consumption.NewBudgetManagementGroup(ctx, "example", &consumption.BudgetManagementGroupArgs{
// Name: pulumi.String("example"),
// ManagementGroupId: example.ID(),
// Amount: pulumi.Float64(1000),
// TimeGrain: pulumi.String("Monthly"),
// TimePeriod: &consumption.BudgetManagementGroupTimePeriodArgs{
// StartDate: pulumi.String("2022-06-01T00:00:00Z"),
// EndDate: pulumi.String("2022-07-01T00:00:00Z"),
// },
// Filter: &consumption.BudgetManagementGroupFilterArgs{
// Dimensions: consumption.BudgetManagementGroupFilterDimensionArray{
// &consumption.BudgetManagementGroupFilterDimensionArgs{
// Name: pulumi.String("ResourceGroupName"),
// Values: pulumi.StringArray{
// exampleResourceGroup.Name,
// },
// },
// },
// Tags: consumption.BudgetManagementGroupFilterTagArray{
// &consumption.BudgetManagementGroupFilterTagArgs{
// Name: pulumi.String("foo"),
// Values: pulumi.StringArray{
// pulumi.String("bar"),
// pulumi.String("baz"),
// },
// },
// },
// },
// Notifications: consumption.BudgetManagementGroupNotificationArray{
// &consumption.BudgetManagementGroupNotificationArgs{
// Enabled: pulumi.Bool(true),
// Threshold: pulumi.Int(90),
// Operator: pulumi.String("EqualTo"),
// ContactEmails: pulumi.StringArray{
// pulumi.String("foo@example.com"),
// pulumi.String("bar@example.com"),
// },
// },
// &consumption.BudgetManagementGroupNotificationArgs{
// Enabled: pulumi.Bool(false),
// Threshold: pulumi.Int(100),
// Operator: pulumi.String("GreaterThan"),
// ThresholdType: pulumi.String("Forecasted"),
// ContactEmails: pulumi.StringArray{
// pulumi.String("foo@example.com"),
// pulumi.String("bar@example.com"),
// },
// },
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
//
// ## Import
//
// Management Group Consumption Budgets can be imported using the `resource id`, e.g.
//
// ```sh
// $ pulumi import azure:consumption/budgetManagementGroup:BudgetManagementGroup example /providers/Microsoft.Management/managementGroups/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/budgets/budget1
// ```
type BudgetManagementGroup struct {
pulumi.CustomResourceState
// The total amount of cost to track with the budget.
Amount pulumi.Float64Output `pulumi:"amount"`
// (Optional) The ETag of the Management Group Consumption Budget.
Etag pulumi.StringOutput `pulumi:"etag"`
// A `filter` block as defined below.
Filter BudgetManagementGroupFilterPtrOutput `pulumi:"filter"`
// The ID of the Management Group. Changing this forces a new resource to be created.
ManagementGroupId pulumi.StringOutput `pulumi:"managementGroupId"`
// The name which should be used for this Management Group Consumption Budget. Changing this forces a new resource to be created.
Name pulumi.StringOutput `pulumi:"name"`
// One or more `notification` blocks as defined below.
Notifications BudgetManagementGroupNotificationArrayOutput `pulumi:"notifications"`
// The time covered by a budget. Tracking of the amount will be reset based on the time grain. Must be one of `BillingAnnual`, `BillingMonth`, `BillingQuarter`, `Annually`, `Monthly` and `Quarterly`. Defaults to `Monthly`. Changing this forces a new resource to be created.
TimeGrain pulumi.StringPtrOutput `pulumi:"timeGrain"`
// A `timePeriod` block as defined below.
TimePeriod BudgetManagementGroupTimePeriodOutput `pulumi:"timePeriod"`
}
// NewBudgetManagementGroup registers a new resource with the given unique name, arguments, and options.
func NewBudgetManagementGroup(ctx *pulumi.Context,
name string, args *BudgetManagementGroupArgs, opts ...pulumi.ResourceOption) (*BudgetManagementGroup, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.Amount == nil {
return nil, errors.New("invalid value for required argument 'Amount'")
}
if args.ManagementGroupId == nil {
return nil, errors.New("invalid value for required argument 'ManagementGroupId'")
}
if args.Notifications == nil {
return nil, errors.New("invalid value for required argument 'Notifications'")
}
if args.TimePeriod == nil {
return nil, errors.New("invalid value for required argument 'TimePeriod'")
}
opts = internal.PkgResourceDefaultOpts(opts)
var resource BudgetManagementGroup
err := ctx.RegisterResource("azure:consumption/budgetManagementGroup:BudgetManagementGroup", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetBudgetManagementGroup gets an existing BudgetManagementGroup 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 GetBudgetManagementGroup(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *BudgetManagementGroupState, opts ...pulumi.ResourceOption) (*BudgetManagementGroup, error) {
var resource BudgetManagementGroup
err := ctx.ReadResource("azure:consumption/budgetManagementGroup:BudgetManagementGroup", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering BudgetManagementGroup resources.
type budgetManagementGroupState struct {
// The total amount of cost to track with the budget.
Amount *float64 `pulumi:"amount"`
// (Optional) The ETag of the Management Group Consumption Budget.
Etag *string `pulumi:"etag"`
// A `filter` block as defined below.
Filter *BudgetManagementGroupFilter `pulumi:"filter"`
// The ID of the Management Group. Changing this forces a new resource to be created.
ManagementGroupId *string `pulumi:"managementGroupId"`
// The name which should be used for this Management Group Consumption Budget. Changing this forces a new resource to be created.
Name *string `pulumi:"name"`
// One or more `notification` blocks as defined below.
Notifications []BudgetManagementGroupNotification `pulumi:"notifications"`
// The time covered by a budget. Tracking of the amount will be reset based on the time grain. Must be one of `BillingAnnual`, `BillingMonth`, `BillingQuarter`, `Annually`, `Monthly` and `Quarterly`. Defaults to `Monthly`. Changing this forces a new resource to be created.
TimeGrain *string `pulumi:"timeGrain"`
// A `timePeriod` block as defined below.
TimePeriod *BudgetManagementGroupTimePeriod `pulumi:"timePeriod"`
}
type BudgetManagementGroupState struct {
// The total amount of cost to track with the budget.
Amount pulumi.Float64PtrInput
// (Optional) The ETag of the Management Group Consumption Budget.
Etag pulumi.StringPtrInput
// A `filter` block as defined below.
Filter BudgetManagementGroupFilterPtrInput
// The ID of the Management Group. Changing this forces a new resource to be created.
ManagementGroupId pulumi.StringPtrInput
// The name which should be used for this Management Group Consumption Budget. Changing this forces a new resource to be created.
Name pulumi.StringPtrInput
// One or more `notification` blocks as defined below.
Notifications BudgetManagementGroupNotificationArrayInput
// The time covered by a budget. Tracking of the amount will be reset based on the time grain. Must be one of `BillingAnnual`, `BillingMonth`, `BillingQuarter`, `Annually`, `Monthly` and `Quarterly`. Defaults to `Monthly`. Changing this forces a new resource to be created.
TimeGrain pulumi.StringPtrInput
// A `timePeriod` block as defined below.
TimePeriod BudgetManagementGroupTimePeriodPtrInput
}
func (BudgetManagementGroupState) ElementType() reflect.Type {
return reflect.TypeOf((*budgetManagementGroupState)(nil)).Elem()
}
type budgetManagementGroupArgs struct {
// The total amount of cost to track with the budget.
Amount float64 `pulumi:"amount"`
// (Optional) The ETag of the Management Group Consumption Budget.
Etag *string `pulumi:"etag"`
// A `filter` block as defined below.
Filter *BudgetManagementGroupFilter `pulumi:"filter"`
// The ID of the Management Group. Changing this forces a new resource to be created.
ManagementGroupId string `pulumi:"managementGroupId"`
// The name which should be used for this Management Group Consumption Budget. Changing this forces a new resource to be created.
Name *string `pulumi:"name"`
// One or more `notification` blocks as defined below.
Notifications []BudgetManagementGroupNotification `pulumi:"notifications"`
// The time covered by a budget. Tracking of the amount will be reset based on the time grain. Must be one of `BillingAnnual`, `BillingMonth`, `BillingQuarter`, `Annually`, `Monthly` and `Quarterly`. Defaults to `Monthly`. Changing this forces a new resource to be created.
TimeGrain *string `pulumi:"timeGrain"`
// A `timePeriod` block as defined below.
TimePeriod BudgetManagementGroupTimePeriod `pulumi:"timePeriod"`
}
// The set of arguments for constructing a BudgetManagementGroup resource.
type BudgetManagementGroupArgs struct {
// The total amount of cost to track with the budget.
Amount pulumi.Float64Input
// (Optional) The ETag of the Management Group Consumption Budget.
Etag pulumi.StringPtrInput
// A `filter` block as defined below.
Filter BudgetManagementGroupFilterPtrInput
// The ID of the Management Group. Changing this forces a new resource to be created.
ManagementGroupId pulumi.StringInput
// The name which should be used for this Management Group Consumption Budget. Changing this forces a new resource to be created.
Name pulumi.StringPtrInput
// One or more `notification` blocks as defined below.
Notifications BudgetManagementGroupNotificationArrayInput
// The time covered by a budget. Tracking of the amount will be reset based on the time grain. Must be one of `BillingAnnual`, `BillingMonth`, `BillingQuarter`, `Annually`, `Monthly` and `Quarterly`. Defaults to `Monthly`. Changing this forces a new resource to be created.
TimeGrain pulumi.StringPtrInput
// A `timePeriod` block as defined below.
TimePeriod BudgetManagementGroupTimePeriodInput
}
func (BudgetManagementGroupArgs) ElementType() reflect.Type {
return reflect.TypeOf((*budgetManagementGroupArgs)(nil)).Elem()
}
type BudgetManagementGroupInput interface {
pulumi.Input
ToBudgetManagementGroupOutput() BudgetManagementGroupOutput
ToBudgetManagementGroupOutputWithContext(ctx context.Context) BudgetManagementGroupOutput
}
func (*BudgetManagementGroup) ElementType() reflect.Type {
return reflect.TypeOf((**BudgetManagementGroup)(nil)).Elem()
}
func (i *BudgetManagementGroup) ToBudgetManagementGroupOutput() BudgetManagementGroupOutput {
return i.ToBudgetManagementGroupOutputWithContext(context.Background())
}
func (i *BudgetManagementGroup) ToBudgetManagementGroupOutputWithContext(ctx context.Context) BudgetManagementGroupOutput {
return pulumi.ToOutputWithContext(ctx, i).(BudgetManagementGroupOutput)
}
// BudgetManagementGroupArrayInput is an input type that accepts BudgetManagementGroupArray and BudgetManagementGroupArrayOutput values.
// You can construct a concrete instance of `BudgetManagementGroupArrayInput` via:
//
// BudgetManagementGroupArray{ BudgetManagementGroupArgs{...} }
type BudgetManagementGroupArrayInput interface {
pulumi.Input
ToBudgetManagementGroupArrayOutput() BudgetManagementGroupArrayOutput
ToBudgetManagementGroupArrayOutputWithContext(context.Context) BudgetManagementGroupArrayOutput
}
type BudgetManagementGroupArray []BudgetManagementGroupInput
func (BudgetManagementGroupArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*BudgetManagementGroup)(nil)).Elem()
}
func (i BudgetManagementGroupArray) ToBudgetManagementGroupArrayOutput() BudgetManagementGroupArrayOutput {
return i.ToBudgetManagementGroupArrayOutputWithContext(context.Background())
}
func (i BudgetManagementGroupArray) ToBudgetManagementGroupArrayOutputWithContext(ctx context.Context) BudgetManagementGroupArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(BudgetManagementGroupArrayOutput)
}
// BudgetManagementGroupMapInput is an input type that accepts BudgetManagementGroupMap and BudgetManagementGroupMapOutput values.
// You can construct a concrete instance of `BudgetManagementGroupMapInput` via:
//
// BudgetManagementGroupMap{ "key": BudgetManagementGroupArgs{...} }
type BudgetManagementGroupMapInput interface {
pulumi.Input
ToBudgetManagementGroupMapOutput() BudgetManagementGroupMapOutput
ToBudgetManagementGroupMapOutputWithContext(context.Context) BudgetManagementGroupMapOutput
}
type BudgetManagementGroupMap map[string]BudgetManagementGroupInput
func (BudgetManagementGroupMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*BudgetManagementGroup)(nil)).Elem()
}
func (i BudgetManagementGroupMap) ToBudgetManagementGroupMapOutput() BudgetManagementGroupMapOutput {
return i.ToBudgetManagementGroupMapOutputWithContext(context.Background())
}
func (i BudgetManagementGroupMap) ToBudgetManagementGroupMapOutputWithContext(ctx context.Context) BudgetManagementGroupMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(BudgetManagementGroupMapOutput)
}
type BudgetManagementGroupOutput struct{ *pulumi.OutputState }
func (BudgetManagementGroupOutput) ElementType() reflect.Type {
return reflect.TypeOf((**BudgetManagementGroup)(nil)).Elem()
}
func (o BudgetManagementGroupOutput) ToBudgetManagementGroupOutput() BudgetManagementGroupOutput {
return o
}
func (o BudgetManagementGroupOutput) ToBudgetManagementGroupOutputWithContext(ctx context.Context) BudgetManagementGroupOutput {
return o
}
// The total amount of cost to track with the budget.
func (o BudgetManagementGroupOutput) Amount() pulumi.Float64Output {
return o.ApplyT(func(v *BudgetManagementGroup) pulumi.Float64Output { return v.Amount }).(pulumi.Float64Output)
}
// (Optional) The ETag of the Management Group Consumption Budget.
func (o BudgetManagementGroupOutput) Etag() pulumi.StringOutput {
return o.ApplyT(func(v *BudgetManagementGroup) pulumi.StringOutput { return v.Etag }).(pulumi.StringOutput)
}
// A `filter` block as defined below.
func (o BudgetManagementGroupOutput) Filter() BudgetManagementGroupFilterPtrOutput {
return o.ApplyT(func(v *BudgetManagementGroup) BudgetManagementGroupFilterPtrOutput { return v.Filter }).(BudgetManagementGroupFilterPtrOutput)
}
// The ID of the Management Group. Changing this forces a new resource to be created.
func (o BudgetManagementGroupOutput) ManagementGroupId() pulumi.StringOutput {
return o.ApplyT(func(v *BudgetManagementGroup) pulumi.StringOutput { return v.ManagementGroupId }).(pulumi.StringOutput)
}
// The name which should be used for this Management Group Consumption Budget. Changing this forces a new resource to be created.
func (o BudgetManagementGroupOutput) Name() pulumi.StringOutput {
return o.ApplyT(func(v *BudgetManagementGroup) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
}
// One or more `notification` blocks as defined below.
func (o BudgetManagementGroupOutput) Notifications() BudgetManagementGroupNotificationArrayOutput {
return o.ApplyT(func(v *BudgetManagementGroup) BudgetManagementGroupNotificationArrayOutput { return v.Notifications }).(BudgetManagementGroupNotificationArrayOutput)
}
// The time covered by a budget. Tracking of the amount will be reset based on the time grain. Must be one of `BillingAnnual`, `BillingMonth`, `BillingQuarter`, `Annually`, `Monthly` and `Quarterly`. Defaults to `Monthly`. Changing this forces a new resource to be created.
func (o BudgetManagementGroupOutput) TimeGrain() pulumi.StringPtrOutput {
return o.ApplyT(func(v *BudgetManagementGroup) pulumi.StringPtrOutput { return v.TimeGrain }).(pulumi.StringPtrOutput)
}
// A `timePeriod` block as defined below.
func (o BudgetManagementGroupOutput) TimePeriod() BudgetManagementGroupTimePeriodOutput {
return o.ApplyT(func(v *BudgetManagementGroup) BudgetManagementGroupTimePeriodOutput { return v.TimePeriod }).(BudgetManagementGroupTimePeriodOutput)
}
type BudgetManagementGroupArrayOutput struct{ *pulumi.OutputState }
func (BudgetManagementGroupArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*BudgetManagementGroup)(nil)).Elem()
}
func (o BudgetManagementGroupArrayOutput) ToBudgetManagementGroupArrayOutput() BudgetManagementGroupArrayOutput {
return o
}
func (o BudgetManagementGroupArrayOutput) ToBudgetManagementGroupArrayOutputWithContext(ctx context.Context) BudgetManagementGroupArrayOutput {
return o
}
func (o BudgetManagementGroupArrayOutput) Index(i pulumi.IntInput) BudgetManagementGroupOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *BudgetManagementGroup {
return vs[0].([]*BudgetManagementGroup)[vs[1].(int)]
}).(BudgetManagementGroupOutput)
}
type BudgetManagementGroupMapOutput struct{ *pulumi.OutputState }
func (BudgetManagementGroupMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*BudgetManagementGroup)(nil)).Elem()
}
func (o BudgetManagementGroupMapOutput) ToBudgetManagementGroupMapOutput() BudgetManagementGroupMapOutput {
return o
}
func (o BudgetManagementGroupMapOutput) ToBudgetManagementGroupMapOutputWithContext(ctx context.Context) BudgetManagementGroupMapOutput {
return o
}
func (o BudgetManagementGroupMapOutput) MapIndex(k pulumi.StringInput) BudgetManagementGroupOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *BudgetManagementGroup {
return vs[0].(map[string]*BudgetManagementGroup)[vs[1].(string)]
}).(BudgetManagementGroupOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*BudgetManagementGroupInput)(nil)).Elem(), &BudgetManagementGroup{})
pulumi.RegisterInputType(reflect.TypeOf((*BudgetManagementGroupArrayInput)(nil)).Elem(), BudgetManagementGroupArray{})
pulumi.RegisterInputType(reflect.TypeOf((*BudgetManagementGroupMapInput)(nil)).Elem(), BudgetManagementGroupMap{})
pulumi.RegisterOutputType(BudgetManagementGroupOutput{})
pulumi.RegisterOutputType(BudgetManagementGroupArrayOutput{})
pulumi.RegisterOutputType(BudgetManagementGroupMapOutput{})
}