/
egpPolicy.go
344 lines (283 loc) · 10.8 KB
/
egpPolicy.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
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
package vault
import (
"context"
"reflect"
"github.com/pkg/errors"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Provides a resource to manage Endpoint Governing Policy (EGP) via [Sentinel](https://www.vaultproject.io/docs/enterprise/sentinel/index.html).
//
// **Note** this feature is available only with Vault Enterprise.
//
// ## Example Usage
//
// ```go
// package main
//
// import (
// "fmt"
//
// "github.com/pulumi/pulumi-vault/sdk/v4/go/vault"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := vault.NewEgpPolicy(ctx, "allow_all", &vault.EgpPolicyArgs{
// EnforcementLevel: pulumi.String("soft-mandatory"),
// Paths: pulumi.StringArray{
// pulumi.String("*"),
// },
// Policy: pulumi.String(fmt.Sprintf("%v%v%v%v", "main = rule {\n", " true\n", "}\n", "\n")),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
type EgpPolicy struct {
pulumi.CustomResourceState
// Enforcement level of Sentinel policy. Can be either `advisory` or `soft-mandatory` or `hard-mandatory`
EnforcementLevel pulumi.StringOutput `pulumi:"enforcementLevel"`
// The name of the policy
Name pulumi.StringOutput `pulumi:"name"`
// List of paths to which the policy will be applied to
Paths pulumi.StringArrayOutput `pulumi:"paths"`
// String containing a Sentinel policy
Policy pulumi.StringOutput `pulumi:"policy"`
}
// NewEgpPolicy registers a new resource with the given unique name, arguments, and options.
func NewEgpPolicy(ctx *pulumi.Context,
name string, args *EgpPolicyArgs, opts ...pulumi.ResourceOption) (*EgpPolicy, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.EnforcementLevel == nil {
return nil, errors.New("invalid value for required argument 'EnforcementLevel'")
}
if args.Paths == nil {
return nil, errors.New("invalid value for required argument 'Paths'")
}
if args.Policy == nil {
return nil, errors.New("invalid value for required argument 'Policy'")
}
var resource EgpPolicy
err := ctx.RegisterResource("vault:index/egpPolicy:EgpPolicy", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetEgpPolicy gets an existing EgpPolicy 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 GetEgpPolicy(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *EgpPolicyState, opts ...pulumi.ResourceOption) (*EgpPolicy, error) {
var resource EgpPolicy
err := ctx.ReadResource("vault:index/egpPolicy:EgpPolicy", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering EgpPolicy resources.
type egpPolicyState struct {
// Enforcement level of Sentinel policy. Can be either `advisory` or `soft-mandatory` or `hard-mandatory`
EnforcementLevel *string `pulumi:"enforcementLevel"`
// The name of the policy
Name *string `pulumi:"name"`
// List of paths to which the policy will be applied to
Paths []string `pulumi:"paths"`
// String containing a Sentinel policy
Policy *string `pulumi:"policy"`
}
type EgpPolicyState struct {
// Enforcement level of Sentinel policy. Can be either `advisory` or `soft-mandatory` or `hard-mandatory`
EnforcementLevel pulumi.StringPtrInput
// The name of the policy
Name pulumi.StringPtrInput
// List of paths to which the policy will be applied to
Paths pulumi.StringArrayInput
// String containing a Sentinel policy
Policy pulumi.StringPtrInput
}
func (EgpPolicyState) ElementType() reflect.Type {
return reflect.TypeOf((*egpPolicyState)(nil)).Elem()
}
type egpPolicyArgs struct {
// Enforcement level of Sentinel policy. Can be either `advisory` or `soft-mandatory` or `hard-mandatory`
EnforcementLevel string `pulumi:"enforcementLevel"`
// The name of the policy
Name *string `pulumi:"name"`
// List of paths to which the policy will be applied to
Paths []string `pulumi:"paths"`
// String containing a Sentinel policy
Policy string `pulumi:"policy"`
}
// The set of arguments for constructing a EgpPolicy resource.
type EgpPolicyArgs struct {
// Enforcement level of Sentinel policy. Can be either `advisory` or `soft-mandatory` or `hard-mandatory`
EnforcementLevel pulumi.StringInput
// The name of the policy
Name pulumi.StringPtrInput
// List of paths to which the policy will be applied to
Paths pulumi.StringArrayInput
// String containing a Sentinel policy
Policy pulumi.StringInput
}
func (EgpPolicyArgs) ElementType() reflect.Type {
return reflect.TypeOf((*egpPolicyArgs)(nil)).Elem()
}
type EgpPolicyInput interface {
pulumi.Input
ToEgpPolicyOutput() EgpPolicyOutput
ToEgpPolicyOutputWithContext(ctx context.Context) EgpPolicyOutput
}
func (*EgpPolicy) ElementType() reflect.Type {
return reflect.TypeOf((*EgpPolicy)(nil))
}
func (i *EgpPolicy) ToEgpPolicyOutput() EgpPolicyOutput {
return i.ToEgpPolicyOutputWithContext(context.Background())
}
func (i *EgpPolicy) ToEgpPolicyOutputWithContext(ctx context.Context) EgpPolicyOutput {
return pulumi.ToOutputWithContext(ctx, i).(EgpPolicyOutput)
}
func (i *EgpPolicy) ToEgpPolicyPtrOutput() EgpPolicyPtrOutput {
return i.ToEgpPolicyPtrOutputWithContext(context.Background())
}
func (i *EgpPolicy) ToEgpPolicyPtrOutputWithContext(ctx context.Context) EgpPolicyPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(EgpPolicyPtrOutput)
}
type EgpPolicyPtrInput interface {
pulumi.Input
ToEgpPolicyPtrOutput() EgpPolicyPtrOutput
ToEgpPolicyPtrOutputWithContext(ctx context.Context) EgpPolicyPtrOutput
}
type egpPolicyPtrType EgpPolicyArgs
func (*egpPolicyPtrType) ElementType() reflect.Type {
return reflect.TypeOf((**EgpPolicy)(nil))
}
func (i *egpPolicyPtrType) ToEgpPolicyPtrOutput() EgpPolicyPtrOutput {
return i.ToEgpPolicyPtrOutputWithContext(context.Background())
}
func (i *egpPolicyPtrType) ToEgpPolicyPtrOutputWithContext(ctx context.Context) EgpPolicyPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(EgpPolicyPtrOutput)
}
// EgpPolicyArrayInput is an input type that accepts EgpPolicyArray and EgpPolicyArrayOutput values.
// You can construct a concrete instance of `EgpPolicyArrayInput` via:
//
// EgpPolicyArray{ EgpPolicyArgs{...} }
type EgpPolicyArrayInput interface {
pulumi.Input
ToEgpPolicyArrayOutput() EgpPolicyArrayOutput
ToEgpPolicyArrayOutputWithContext(context.Context) EgpPolicyArrayOutput
}
type EgpPolicyArray []EgpPolicyInput
func (EgpPolicyArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*EgpPolicy)(nil)).Elem()
}
func (i EgpPolicyArray) ToEgpPolicyArrayOutput() EgpPolicyArrayOutput {
return i.ToEgpPolicyArrayOutputWithContext(context.Background())
}
func (i EgpPolicyArray) ToEgpPolicyArrayOutputWithContext(ctx context.Context) EgpPolicyArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(EgpPolicyArrayOutput)
}
// EgpPolicyMapInput is an input type that accepts EgpPolicyMap and EgpPolicyMapOutput values.
// You can construct a concrete instance of `EgpPolicyMapInput` via:
//
// EgpPolicyMap{ "key": EgpPolicyArgs{...} }
type EgpPolicyMapInput interface {
pulumi.Input
ToEgpPolicyMapOutput() EgpPolicyMapOutput
ToEgpPolicyMapOutputWithContext(context.Context) EgpPolicyMapOutput
}
type EgpPolicyMap map[string]EgpPolicyInput
func (EgpPolicyMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*EgpPolicy)(nil)).Elem()
}
func (i EgpPolicyMap) ToEgpPolicyMapOutput() EgpPolicyMapOutput {
return i.ToEgpPolicyMapOutputWithContext(context.Background())
}
func (i EgpPolicyMap) ToEgpPolicyMapOutputWithContext(ctx context.Context) EgpPolicyMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(EgpPolicyMapOutput)
}
type EgpPolicyOutput struct{ *pulumi.OutputState }
func (EgpPolicyOutput) ElementType() reflect.Type {
return reflect.TypeOf((*EgpPolicy)(nil))
}
func (o EgpPolicyOutput) ToEgpPolicyOutput() EgpPolicyOutput {
return o
}
func (o EgpPolicyOutput) ToEgpPolicyOutputWithContext(ctx context.Context) EgpPolicyOutput {
return o
}
func (o EgpPolicyOutput) ToEgpPolicyPtrOutput() EgpPolicyPtrOutput {
return o.ToEgpPolicyPtrOutputWithContext(context.Background())
}
func (o EgpPolicyOutput) ToEgpPolicyPtrOutputWithContext(ctx context.Context) EgpPolicyPtrOutput {
return o.ApplyTWithContext(ctx, func(_ context.Context, v EgpPolicy) *EgpPolicy {
return &v
}).(EgpPolicyPtrOutput)
}
type EgpPolicyPtrOutput struct{ *pulumi.OutputState }
func (EgpPolicyPtrOutput) ElementType() reflect.Type {
return reflect.TypeOf((**EgpPolicy)(nil))
}
func (o EgpPolicyPtrOutput) ToEgpPolicyPtrOutput() EgpPolicyPtrOutput {
return o
}
func (o EgpPolicyPtrOutput) ToEgpPolicyPtrOutputWithContext(ctx context.Context) EgpPolicyPtrOutput {
return o
}
func (o EgpPolicyPtrOutput) Elem() EgpPolicyOutput {
return o.ApplyT(func(v *EgpPolicy) EgpPolicy {
if v != nil {
return *v
}
var ret EgpPolicy
return ret
}).(EgpPolicyOutput)
}
type EgpPolicyArrayOutput struct{ *pulumi.OutputState }
func (EgpPolicyArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]EgpPolicy)(nil))
}
func (o EgpPolicyArrayOutput) ToEgpPolicyArrayOutput() EgpPolicyArrayOutput {
return o
}
func (o EgpPolicyArrayOutput) ToEgpPolicyArrayOutputWithContext(ctx context.Context) EgpPolicyArrayOutput {
return o
}
func (o EgpPolicyArrayOutput) Index(i pulumi.IntInput) EgpPolicyOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) EgpPolicy {
return vs[0].([]EgpPolicy)[vs[1].(int)]
}).(EgpPolicyOutput)
}
type EgpPolicyMapOutput struct{ *pulumi.OutputState }
func (EgpPolicyMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]EgpPolicy)(nil))
}
func (o EgpPolicyMapOutput) ToEgpPolicyMapOutput() EgpPolicyMapOutput {
return o
}
func (o EgpPolicyMapOutput) ToEgpPolicyMapOutputWithContext(ctx context.Context) EgpPolicyMapOutput {
return o
}
func (o EgpPolicyMapOutput) MapIndex(k pulumi.StringInput) EgpPolicyOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) EgpPolicy {
return vs[0].(map[string]EgpPolicy)[vs[1].(string)]
}).(EgpPolicyOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*EgpPolicyInput)(nil)).Elem(), &EgpPolicy{})
pulumi.RegisterInputType(reflect.TypeOf((*EgpPolicyPtrInput)(nil)).Elem(), &EgpPolicy{})
pulumi.RegisterInputType(reflect.TypeOf((*EgpPolicyArrayInput)(nil)).Elem(), EgpPolicyArray{})
pulumi.RegisterInputType(reflect.TypeOf((*EgpPolicyMapInput)(nil)).Elem(), EgpPolicyMap{})
pulumi.RegisterOutputType(EgpPolicyOutput{})
pulumi.RegisterOutputType(EgpPolicyPtrOutput{})
pulumi.RegisterOutputType(EgpPolicyArrayOutput{})
pulumi.RegisterOutputType(EgpPolicyMapOutput{})
}