-
Notifications
You must be signed in to change notification settings - Fork 51
/
getPolicyAssignment.go
194 lines (167 loc) · 7.72 KB
/
getPolicyAssignment.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
// 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"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Use this data source to access information about an existing Policy 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 {
// example, err := policy.GetPolicyAssignment(ctx, &policy.GetPolicyAssignmentArgs{
// Name: "existing",
// ScopeId: data.Azurerm_resource_group.Example.Id,
// }, nil)
// if err != nil {
// return err
// }
// ctx.Export("id", example.Id)
// return nil
// })
// }
//
// ```
func GetPolicyAssignment(ctx *pulumi.Context, args *GetPolicyAssignmentArgs, opts ...pulumi.InvokeOption) (*GetPolicyAssignmentResult, error) {
var rv GetPolicyAssignmentResult
err := ctx.Invoke("azure:policy/getPolicyAssignment:getPolicyAssignment", args, &rv, opts...)
if err != nil {
return nil, err
}
return &rv, nil
}
// A collection of arguments for invoking getPolicyAssignment.
type GetPolicyAssignmentArgs struct {
// The name of this Policy Assignment. Changing this forces a new Policy Assignment to be created.
Name string `pulumi:"name"`
// The ID of the scope this Policy Assignment is assigned to. The `scopeId` can be a subscription id, a resource group id, a management group id, or an ID of any resource that is assigned with a policy. Changing this forces a new Policy Assignment to be created.
ScopeId string `pulumi:"scopeId"`
}
// A collection of values returned by getPolicyAssignment.
type GetPolicyAssignmentResult struct {
// The description of this Policy Assignment.
Description string `pulumi:"description"`
// The display name of this Policy Assignment.
DisplayName string `pulumi:"displayName"`
// Whether this Policy is enforced or not?
Enforce bool `pulumi:"enforce"`
// The provider-assigned unique ID for this managed resource.
Id string `pulumi:"id"`
// A `identity` block as defined below.
Identities []GetPolicyAssignmentIdentity `pulumi:"identities"`
// The Azure Region where the Policy Assignment exists.
Location string `pulumi:"location"`
// A JSON mapping of any Metadata for this Policy.
Metadata string `pulumi:"metadata"`
Name string `pulumi:"name"`
// A `nonComplianceMessage` block as defined below.
NonComplianceMessages []GetPolicyAssignmentNonComplianceMessage `pulumi:"nonComplianceMessages"`
// A `notScopes` block as defined below.
NotScopes []string `pulumi:"notScopes"`
// A JSON mapping of any Parameters for this Policy.
Parameters string `pulumi:"parameters"`
// The ID of the assigned Policy Definition.
PolicyDefinitionId string `pulumi:"policyDefinitionId"`
ScopeId string `pulumi:"scopeId"`
}
func GetPolicyAssignmentOutput(ctx *pulumi.Context, args GetPolicyAssignmentOutputArgs, opts ...pulumi.InvokeOption) GetPolicyAssignmentResultOutput {
return pulumi.ToOutputWithContext(context.Background(), args).
ApplyT(func(v interface{}) (GetPolicyAssignmentResult, error) {
args := v.(GetPolicyAssignmentArgs)
r, err := GetPolicyAssignment(ctx, &args, opts...)
var s GetPolicyAssignmentResult
if r != nil {
s = *r
}
return s, err
}).(GetPolicyAssignmentResultOutput)
}
// A collection of arguments for invoking getPolicyAssignment.
type GetPolicyAssignmentOutputArgs struct {
// The name of this Policy Assignment. Changing this forces a new Policy Assignment to be created.
Name pulumi.StringInput `pulumi:"name"`
// The ID of the scope this Policy Assignment is assigned to. The `scopeId` can be a subscription id, a resource group id, a management group id, or an ID of any resource that is assigned with a policy. Changing this forces a new Policy Assignment to be created.
ScopeId pulumi.StringInput `pulumi:"scopeId"`
}
func (GetPolicyAssignmentOutputArgs) ElementType() reflect.Type {
return reflect.TypeOf((*GetPolicyAssignmentArgs)(nil)).Elem()
}
// A collection of values returned by getPolicyAssignment.
type GetPolicyAssignmentResultOutput struct{ *pulumi.OutputState }
func (GetPolicyAssignmentResultOutput) ElementType() reflect.Type {
return reflect.TypeOf((*GetPolicyAssignmentResult)(nil)).Elem()
}
func (o GetPolicyAssignmentResultOutput) ToGetPolicyAssignmentResultOutput() GetPolicyAssignmentResultOutput {
return o
}
func (o GetPolicyAssignmentResultOutput) ToGetPolicyAssignmentResultOutputWithContext(ctx context.Context) GetPolicyAssignmentResultOutput {
return o
}
// The description of this Policy Assignment.
func (o GetPolicyAssignmentResultOutput) Description() pulumi.StringOutput {
return o.ApplyT(func(v GetPolicyAssignmentResult) string { return v.Description }).(pulumi.StringOutput)
}
// The display name of this Policy Assignment.
func (o GetPolicyAssignmentResultOutput) DisplayName() pulumi.StringOutput {
return o.ApplyT(func(v GetPolicyAssignmentResult) string { return v.DisplayName }).(pulumi.StringOutput)
}
// Whether this Policy is enforced or not?
func (o GetPolicyAssignmentResultOutput) Enforce() pulumi.BoolOutput {
return o.ApplyT(func(v GetPolicyAssignmentResult) bool { return v.Enforce }).(pulumi.BoolOutput)
}
// The provider-assigned unique ID for this managed resource.
func (o GetPolicyAssignmentResultOutput) Id() pulumi.StringOutput {
return o.ApplyT(func(v GetPolicyAssignmentResult) string { return v.Id }).(pulumi.StringOutput)
}
// A `identity` block as defined below.
func (o GetPolicyAssignmentResultOutput) Identities() GetPolicyAssignmentIdentityArrayOutput {
return o.ApplyT(func(v GetPolicyAssignmentResult) []GetPolicyAssignmentIdentity { return v.Identities }).(GetPolicyAssignmentIdentityArrayOutput)
}
// The Azure Region where the Policy Assignment exists.
func (o GetPolicyAssignmentResultOutput) Location() pulumi.StringOutput {
return o.ApplyT(func(v GetPolicyAssignmentResult) string { return v.Location }).(pulumi.StringOutput)
}
// A JSON mapping of any Metadata for this Policy.
func (o GetPolicyAssignmentResultOutput) Metadata() pulumi.StringOutput {
return o.ApplyT(func(v GetPolicyAssignmentResult) string { return v.Metadata }).(pulumi.StringOutput)
}
func (o GetPolicyAssignmentResultOutput) Name() pulumi.StringOutput {
return o.ApplyT(func(v GetPolicyAssignmentResult) string { return v.Name }).(pulumi.StringOutput)
}
// A `nonComplianceMessage` block as defined below.
func (o GetPolicyAssignmentResultOutput) NonComplianceMessages() GetPolicyAssignmentNonComplianceMessageArrayOutput {
return o.ApplyT(func(v GetPolicyAssignmentResult) []GetPolicyAssignmentNonComplianceMessage {
return v.NonComplianceMessages
}).(GetPolicyAssignmentNonComplianceMessageArrayOutput)
}
// A `notScopes` block as defined below.
func (o GetPolicyAssignmentResultOutput) NotScopes() pulumi.StringArrayOutput {
return o.ApplyT(func(v GetPolicyAssignmentResult) []string { return v.NotScopes }).(pulumi.StringArrayOutput)
}
// A JSON mapping of any Parameters for this Policy.
func (o GetPolicyAssignmentResultOutput) Parameters() pulumi.StringOutput {
return o.ApplyT(func(v GetPolicyAssignmentResult) string { return v.Parameters }).(pulumi.StringOutput)
}
// The ID of the assigned Policy Definition.
func (o GetPolicyAssignmentResultOutput) PolicyDefinitionId() pulumi.StringOutput {
return o.ApplyT(func(v GetPolicyAssignmentResult) string { return v.PolicyDefinitionId }).(pulumi.StringOutput)
}
func (o GetPolicyAssignmentResultOutput) ScopeId() pulumi.StringOutput {
return o.ApplyT(func(v GetPolicyAssignmentResult) string { return v.ScopeId }).(pulumi.StringOutput)
}
func init() {
pulumi.RegisterOutputType(GetPolicyAssignmentResultOutput{})
}