-
Notifications
You must be signed in to change notification settings - Fork 51
/
policySetDefinition.go
415 lines (360 loc) · 19.2 KB
/
policySetDefinition.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
// 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 policy
import (
"context"
"reflect"
"errors"
"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Manages a policy set definition.
//
// > **NOTE:** Policy set definitions (also known as policy initiatives) do not take effect until they are assigned to a scope using a Policy Set Assignment.
//
// ## Example Usage
//
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-azure/sdk/v5/go/azure/policy"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := policy.NewPolicySetDefinition(ctx, "example", &policy.PolicySetDefinitionArgs{
// DisplayName: pulumi.String("Test Policy Set"),
// Parameters: pulumi.String(` {
// "allowedLocations": {
// "type": "Array",
// "metadata": {
// "description": "The list of allowed locations for resources.",
// "displayName": "Allowed locations",
// "strongType": "location"
// }
// }
// }
//
// `),
//
// PolicyDefinitionReferences: policy.PolicySetDefinitionPolicyDefinitionReferenceArray{
// &policy.PolicySetDefinitionPolicyDefinitionReferenceArgs{
// ParameterValues: pulumi.String(" {\n \"listOfAllowedLocations\": {\"value\": \"[parameters('allowedLocations')]\"}\n }\n \n"),
// PolicyDefinitionId: pulumi.String("/providers/Microsoft.Authorization/policyDefinitions/e765b5de-1225-4ba3-bd56-1ac6695af988"),
// },
// },
// PolicyType: pulumi.String("Custom"),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
//
// ## Import
//
// Policy Set Definitions can be imported using the `resource id`, e.g.
//
// ```sh
//
// $ pulumi import azure:policy/policySetDefinition:PolicySetDefinition example /subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/policySetDefinitions/testPolicySet
//
// ```
//
// or
//
// ```sh
//
// $ pulumi import azure:policy/policySetDefinition:PolicySetDefinition example /providers/Microsoft.Management/managementGroups/my-mgmt-group-id/providers/Microsoft.Authorization/policySetDefinitions/testPolicySet
//
// ```
type PolicySetDefinition struct {
pulumi.CustomResourceState
// The description of the policy set definition.
Description pulumi.StringPtrOutput `pulumi:"description"`
// The display name of the policy set definition.
DisplayName pulumi.StringOutput `pulumi:"displayName"`
// The id of the Management Group where this policy set definition should be defined. Changing this forces a new resource to be created.
ManagementGroupId pulumi.StringPtrOutput `pulumi:"managementGroupId"`
// The metadata for the policy set definition. This is a JSON object representing additional metadata that should be stored with the policy definition.
Metadata pulumi.StringOutput `pulumi:"metadata"`
// The name of the policy set definition. Changing this forces a new resource to be created.
Name pulumi.StringOutput `pulumi:"name"`
// Parameters for the policy set definition. This field is a JSON object that allows you to parameterize your policy definition.
Parameters pulumi.StringPtrOutput `pulumi:"parameters"`
// One or more `policyDefinitionGroup` blocks as defined below.
PolicyDefinitionGroups PolicySetDefinitionPolicyDefinitionGroupArrayOutput `pulumi:"policyDefinitionGroups"`
// One or more `policyDefinitionReference` blocks as defined below.
PolicyDefinitionReferences PolicySetDefinitionPolicyDefinitionReferenceArrayOutput `pulumi:"policyDefinitionReferences"`
// The policy set type. Possible values are `BuiltIn`, `Custom`, `NotSpecified` and `Static`. Changing this forces a new resource to be created.
PolicyType pulumi.StringOutput `pulumi:"policyType"`
}
// NewPolicySetDefinition registers a new resource with the given unique name, arguments, and options.
func NewPolicySetDefinition(ctx *pulumi.Context,
name string, args *PolicySetDefinitionArgs, opts ...pulumi.ResourceOption) (*PolicySetDefinition, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.DisplayName == nil {
return nil, errors.New("invalid value for required argument 'DisplayName'")
}
if args.PolicyDefinitionReferences == nil {
return nil, errors.New("invalid value for required argument 'PolicyDefinitionReferences'")
}
if args.PolicyType == nil {
return nil, errors.New("invalid value for required argument 'PolicyType'")
}
opts = internal.PkgResourceDefaultOpts(opts)
var resource PolicySetDefinition
err := ctx.RegisterResource("azure:policy/policySetDefinition:PolicySetDefinition", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetPolicySetDefinition gets an existing PolicySetDefinition 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 GetPolicySetDefinition(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *PolicySetDefinitionState, opts ...pulumi.ResourceOption) (*PolicySetDefinition, error) {
var resource PolicySetDefinition
err := ctx.ReadResource("azure:policy/policySetDefinition:PolicySetDefinition", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering PolicySetDefinition resources.
type policySetDefinitionState struct {
// The description of the policy set definition.
Description *string `pulumi:"description"`
// The display name of the policy set definition.
DisplayName *string `pulumi:"displayName"`
// The id of the Management Group where this policy set definition should be defined. Changing this forces a new resource to be created.
ManagementGroupId *string `pulumi:"managementGroupId"`
// The metadata for the policy set definition. This is a JSON object representing additional metadata that should be stored with the policy definition.
Metadata *string `pulumi:"metadata"`
// The name of the policy set definition. Changing this forces a new resource to be created.
Name *string `pulumi:"name"`
// Parameters for the policy set definition. This field is a JSON object that allows you to parameterize your policy definition.
Parameters *string `pulumi:"parameters"`
// One or more `policyDefinitionGroup` blocks as defined below.
PolicyDefinitionGroups []PolicySetDefinitionPolicyDefinitionGroup `pulumi:"policyDefinitionGroups"`
// One or more `policyDefinitionReference` blocks as defined below.
PolicyDefinitionReferences []PolicySetDefinitionPolicyDefinitionReference `pulumi:"policyDefinitionReferences"`
// The policy set type. Possible values are `BuiltIn`, `Custom`, `NotSpecified` and `Static`. Changing this forces a new resource to be created.
PolicyType *string `pulumi:"policyType"`
}
type PolicySetDefinitionState struct {
// The description of the policy set definition.
Description pulumi.StringPtrInput
// The display name of the policy set definition.
DisplayName pulumi.StringPtrInput
// The id of the Management Group where this policy set definition should be defined. Changing this forces a new resource to be created.
ManagementGroupId pulumi.StringPtrInput
// The metadata for the policy set definition. This is a JSON object representing additional metadata that should be stored with the policy definition.
Metadata pulumi.StringPtrInput
// The name of the policy set definition. Changing this forces a new resource to be created.
Name pulumi.StringPtrInput
// Parameters for the policy set definition. This field is a JSON object that allows you to parameterize your policy definition.
Parameters pulumi.StringPtrInput
// One or more `policyDefinitionGroup` blocks as defined below.
PolicyDefinitionGroups PolicySetDefinitionPolicyDefinitionGroupArrayInput
// One or more `policyDefinitionReference` blocks as defined below.
PolicyDefinitionReferences PolicySetDefinitionPolicyDefinitionReferenceArrayInput
// The policy set type. Possible values are `BuiltIn`, `Custom`, `NotSpecified` and `Static`. Changing this forces a new resource to be created.
PolicyType pulumi.StringPtrInput
}
func (PolicySetDefinitionState) ElementType() reflect.Type {
return reflect.TypeOf((*policySetDefinitionState)(nil)).Elem()
}
type policySetDefinitionArgs struct {
// The description of the policy set definition.
Description *string `pulumi:"description"`
// The display name of the policy set definition.
DisplayName string `pulumi:"displayName"`
// The id of the Management Group where this policy set definition should be defined. Changing this forces a new resource to be created.
ManagementGroupId *string `pulumi:"managementGroupId"`
// The metadata for the policy set definition. This is a JSON object representing additional metadata that should be stored with the policy definition.
Metadata *string `pulumi:"metadata"`
// The name of the policy set definition. Changing this forces a new resource to be created.
Name *string `pulumi:"name"`
// Parameters for the policy set definition. This field is a JSON object that allows you to parameterize your policy definition.
Parameters *string `pulumi:"parameters"`
// One or more `policyDefinitionGroup` blocks as defined below.
PolicyDefinitionGroups []PolicySetDefinitionPolicyDefinitionGroup `pulumi:"policyDefinitionGroups"`
// One or more `policyDefinitionReference` blocks as defined below.
PolicyDefinitionReferences []PolicySetDefinitionPolicyDefinitionReference `pulumi:"policyDefinitionReferences"`
// The policy set type. Possible values are `BuiltIn`, `Custom`, `NotSpecified` and `Static`. Changing this forces a new resource to be created.
PolicyType string `pulumi:"policyType"`
}
// The set of arguments for constructing a PolicySetDefinition resource.
type PolicySetDefinitionArgs struct {
// The description of the policy set definition.
Description pulumi.StringPtrInput
// The display name of the policy set definition.
DisplayName pulumi.StringInput
// The id of the Management Group where this policy set definition should be defined. Changing this forces a new resource to be created.
ManagementGroupId pulumi.StringPtrInput
// The metadata for the policy set definition. This is a JSON object representing additional metadata that should be stored with the policy definition.
Metadata pulumi.StringPtrInput
// The name of the policy set definition. Changing this forces a new resource to be created.
Name pulumi.StringPtrInput
// Parameters for the policy set definition. This field is a JSON object that allows you to parameterize your policy definition.
Parameters pulumi.StringPtrInput
// One or more `policyDefinitionGroup` blocks as defined below.
PolicyDefinitionGroups PolicySetDefinitionPolicyDefinitionGroupArrayInput
// One or more `policyDefinitionReference` blocks as defined below.
PolicyDefinitionReferences PolicySetDefinitionPolicyDefinitionReferenceArrayInput
// The policy set type. Possible values are `BuiltIn`, `Custom`, `NotSpecified` and `Static`. Changing this forces a new resource to be created.
PolicyType pulumi.StringInput
}
func (PolicySetDefinitionArgs) ElementType() reflect.Type {
return reflect.TypeOf((*policySetDefinitionArgs)(nil)).Elem()
}
type PolicySetDefinitionInput interface {
pulumi.Input
ToPolicySetDefinitionOutput() PolicySetDefinitionOutput
ToPolicySetDefinitionOutputWithContext(ctx context.Context) PolicySetDefinitionOutput
}
func (*PolicySetDefinition) ElementType() reflect.Type {
return reflect.TypeOf((**PolicySetDefinition)(nil)).Elem()
}
func (i *PolicySetDefinition) ToPolicySetDefinitionOutput() PolicySetDefinitionOutput {
return i.ToPolicySetDefinitionOutputWithContext(context.Background())
}
func (i *PolicySetDefinition) ToPolicySetDefinitionOutputWithContext(ctx context.Context) PolicySetDefinitionOutput {
return pulumi.ToOutputWithContext(ctx, i).(PolicySetDefinitionOutput)
}
// PolicySetDefinitionArrayInput is an input type that accepts PolicySetDefinitionArray and PolicySetDefinitionArrayOutput values.
// You can construct a concrete instance of `PolicySetDefinitionArrayInput` via:
//
// PolicySetDefinitionArray{ PolicySetDefinitionArgs{...} }
type PolicySetDefinitionArrayInput interface {
pulumi.Input
ToPolicySetDefinitionArrayOutput() PolicySetDefinitionArrayOutput
ToPolicySetDefinitionArrayOutputWithContext(context.Context) PolicySetDefinitionArrayOutput
}
type PolicySetDefinitionArray []PolicySetDefinitionInput
func (PolicySetDefinitionArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*PolicySetDefinition)(nil)).Elem()
}
func (i PolicySetDefinitionArray) ToPolicySetDefinitionArrayOutput() PolicySetDefinitionArrayOutput {
return i.ToPolicySetDefinitionArrayOutputWithContext(context.Background())
}
func (i PolicySetDefinitionArray) ToPolicySetDefinitionArrayOutputWithContext(ctx context.Context) PolicySetDefinitionArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(PolicySetDefinitionArrayOutput)
}
// PolicySetDefinitionMapInput is an input type that accepts PolicySetDefinitionMap and PolicySetDefinitionMapOutput values.
// You can construct a concrete instance of `PolicySetDefinitionMapInput` via:
//
// PolicySetDefinitionMap{ "key": PolicySetDefinitionArgs{...} }
type PolicySetDefinitionMapInput interface {
pulumi.Input
ToPolicySetDefinitionMapOutput() PolicySetDefinitionMapOutput
ToPolicySetDefinitionMapOutputWithContext(context.Context) PolicySetDefinitionMapOutput
}
type PolicySetDefinitionMap map[string]PolicySetDefinitionInput
func (PolicySetDefinitionMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*PolicySetDefinition)(nil)).Elem()
}
func (i PolicySetDefinitionMap) ToPolicySetDefinitionMapOutput() PolicySetDefinitionMapOutput {
return i.ToPolicySetDefinitionMapOutputWithContext(context.Background())
}
func (i PolicySetDefinitionMap) ToPolicySetDefinitionMapOutputWithContext(ctx context.Context) PolicySetDefinitionMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(PolicySetDefinitionMapOutput)
}
type PolicySetDefinitionOutput struct{ *pulumi.OutputState }
func (PolicySetDefinitionOutput) ElementType() reflect.Type {
return reflect.TypeOf((**PolicySetDefinition)(nil)).Elem()
}
func (o PolicySetDefinitionOutput) ToPolicySetDefinitionOutput() PolicySetDefinitionOutput {
return o
}
func (o PolicySetDefinitionOutput) ToPolicySetDefinitionOutputWithContext(ctx context.Context) PolicySetDefinitionOutput {
return o
}
// The description of the policy set definition.
func (o PolicySetDefinitionOutput) Description() pulumi.StringPtrOutput {
return o.ApplyT(func(v *PolicySetDefinition) pulumi.StringPtrOutput { return v.Description }).(pulumi.StringPtrOutput)
}
// The display name of the policy set definition.
func (o PolicySetDefinitionOutput) DisplayName() pulumi.StringOutput {
return o.ApplyT(func(v *PolicySetDefinition) pulumi.StringOutput { return v.DisplayName }).(pulumi.StringOutput)
}
// The id of the Management Group where this policy set definition should be defined. Changing this forces a new resource to be created.
func (o PolicySetDefinitionOutput) ManagementGroupId() pulumi.StringPtrOutput {
return o.ApplyT(func(v *PolicySetDefinition) pulumi.StringPtrOutput { return v.ManagementGroupId }).(pulumi.StringPtrOutput)
}
// The metadata for the policy set definition. This is a JSON object representing additional metadata that should be stored with the policy definition.
func (o PolicySetDefinitionOutput) Metadata() pulumi.StringOutput {
return o.ApplyT(func(v *PolicySetDefinition) pulumi.StringOutput { return v.Metadata }).(pulumi.StringOutput)
}
// The name of the policy set definition. Changing this forces a new resource to be created.
func (o PolicySetDefinitionOutput) Name() pulumi.StringOutput {
return o.ApplyT(func(v *PolicySetDefinition) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
}
// Parameters for the policy set definition. This field is a JSON object that allows you to parameterize your policy definition.
func (o PolicySetDefinitionOutput) Parameters() pulumi.StringPtrOutput {
return o.ApplyT(func(v *PolicySetDefinition) pulumi.StringPtrOutput { return v.Parameters }).(pulumi.StringPtrOutput)
}
// One or more `policyDefinitionGroup` blocks as defined below.
func (o PolicySetDefinitionOutput) PolicyDefinitionGroups() PolicySetDefinitionPolicyDefinitionGroupArrayOutput {
return o.ApplyT(func(v *PolicySetDefinition) PolicySetDefinitionPolicyDefinitionGroupArrayOutput {
return v.PolicyDefinitionGroups
}).(PolicySetDefinitionPolicyDefinitionGroupArrayOutput)
}
// One or more `policyDefinitionReference` blocks as defined below.
func (o PolicySetDefinitionOutput) PolicyDefinitionReferences() PolicySetDefinitionPolicyDefinitionReferenceArrayOutput {
return o.ApplyT(func(v *PolicySetDefinition) PolicySetDefinitionPolicyDefinitionReferenceArrayOutput {
return v.PolicyDefinitionReferences
}).(PolicySetDefinitionPolicyDefinitionReferenceArrayOutput)
}
// The policy set type. Possible values are `BuiltIn`, `Custom`, `NotSpecified` and `Static`. Changing this forces a new resource to be created.
func (o PolicySetDefinitionOutput) PolicyType() pulumi.StringOutput {
return o.ApplyT(func(v *PolicySetDefinition) pulumi.StringOutput { return v.PolicyType }).(pulumi.StringOutput)
}
type PolicySetDefinitionArrayOutput struct{ *pulumi.OutputState }
func (PolicySetDefinitionArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*PolicySetDefinition)(nil)).Elem()
}
func (o PolicySetDefinitionArrayOutput) ToPolicySetDefinitionArrayOutput() PolicySetDefinitionArrayOutput {
return o
}
func (o PolicySetDefinitionArrayOutput) ToPolicySetDefinitionArrayOutputWithContext(ctx context.Context) PolicySetDefinitionArrayOutput {
return o
}
func (o PolicySetDefinitionArrayOutput) Index(i pulumi.IntInput) PolicySetDefinitionOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *PolicySetDefinition {
return vs[0].([]*PolicySetDefinition)[vs[1].(int)]
}).(PolicySetDefinitionOutput)
}
type PolicySetDefinitionMapOutput struct{ *pulumi.OutputState }
func (PolicySetDefinitionMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*PolicySetDefinition)(nil)).Elem()
}
func (o PolicySetDefinitionMapOutput) ToPolicySetDefinitionMapOutput() PolicySetDefinitionMapOutput {
return o
}
func (o PolicySetDefinitionMapOutput) ToPolicySetDefinitionMapOutputWithContext(ctx context.Context) PolicySetDefinitionMapOutput {
return o
}
func (o PolicySetDefinitionMapOutput) MapIndex(k pulumi.StringInput) PolicySetDefinitionOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *PolicySetDefinition {
return vs[0].(map[string]*PolicySetDefinition)[vs[1].(string)]
}).(PolicySetDefinitionOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*PolicySetDefinitionInput)(nil)).Elem(), &PolicySetDefinition{})
pulumi.RegisterInputType(reflect.TypeOf((*PolicySetDefinitionArrayInput)(nil)).Elem(), PolicySetDefinitionArray{})
pulumi.RegisterInputType(reflect.TypeOf((*PolicySetDefinitionMapInput)(nil)).Elem(), PolicySetDefinitionMap{})
pulumi.RegisterOutputType(PolicySetDefinitionOutput{})
pulumi.RegisterOutputType(PolicySetDefinitionArrayOutput{})
pulumi.RegisterOutputType(PolicySetDefinitionMapOutput{})
}