/
secretRole.go
461 lines (404 loc) · 18 KB
/
secretRole.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
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
// 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 mongodbatlas
import (
"context"
"reflect"
"errors"
"github.com/pulumi/pulumi-vault/sdk/v5/go/vault/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// ## Example Usage
//
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-vault/sdk/v5/go/vault"
// "github.com/pulumi/pulumi-vault/sdk/v5/go/vault/mongodbatlas"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// mongo, err := vault.NewMount(ctx, "mongo", &vault.MountArgs{
// Path: pulumi.String("%s"),
// Type: pulumi.String("mongodbatlas"),
// Description: pulumi.String("MongoDB Atlas secret engine mount"),
// })
// if err != nil {
// return err
// }
// _, err = mongodbatlas.NewSecretBackend(ctx, "config", &mongodbatlas.SecretBackendArgs{
// Mount: pulumi.String("vault_mount.mongo.path"),
// PrivateKey: pulumi.String("privateKey"),
// PublicKey: pulumi.String("publicKey"),
// })
// if err != nil {
// return err
// }
// _, err = mongodbatlas.NewSecretRole(ctx, "role", &mongodbatlas.SecretRoleArgs{
// Mount: mongo.Path,
// OrganizationId: pulumi.String("7cf5a45a9ccf6400e60981b7"),
// ProjectId: pulumi.String("5cf5a45a9ccf6400e60981b6"),
// Roles: pulumi.StringArray("ORG_READ_ONLY"),
// IpAddresses: pulumi.StringArray("192.168.1.5, 192.168.1.6"),
// CidrBlocks: pulumi.StringArray("192.168.1.3/35"),
// ProjectRoles: pulumi.StringArray("GROUP_READ_ONLY"),
// Ttl: pulumi.String("60"),
// MaxTtl: pulumi.String("120"),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
//
// ## Import
//
// The MongoDB Atlas secret role can be imported using the full path to the role of the form: `<mount_path>/roles/<role_name>` e.g.
//
// ```sh
//
// $ pulumi import vault:mongodbatlas/secretRole:SecretRole example mongodbatlas/roles/example-role
//
// ```
type SecretRole struct {
pulumi.CustomResourceState
// Whitelist entry in CIDR notation to be added for the API key.
CidrBlocks pulumi.StringArrayOutput `pulumi:"cidrBlocks"`
// IP address to be added to the whitelist for the API key.
IpAddresses pulumi.StringArrayOutput `pulumi:"ipAddresses"`
// The maximum allowed lifetime of credentials issued using this role.
MaxTtl pulumi.StringPtrOutput `pulumi:"maxTtl"`
// Path where the MongoDB Atlas Secrets Engine is mounted.
Mount pulumi.StringOutput `pulumi:"mount"`
// The name of the role.
Name pulumi.StringOutput `pulumi:"name"`
// The namespace to provision the resource in.
// The value should not contain leading or trailing forward slashes.
// The `namespace` is always relative to the provider's configured [namespace](https://www.terraform.io/docs/providers/vault#namespace).
// *Available only for Vault Enterprise*.
Namespace pulumi.StringPtrOutput `pulumi:"namespace"`
// Unique identifier for the organization to which the target API Key belongs.
// Required if `projectId` is not set.
OrganizationId pulumi.StringPtrOutput `pulumi:"organizationId"`
// Unique identifier for the project to which the target API Key belongs.
// Required if `organizationId is` not set.
ProjectId pulumi.StringPtrOutput `pulumi:"projectId"`
// Roles assigned when an org API key is assigned to a project API key.
ProjectRoles pulumi.StringArrayOutput `pulumi:"projectRoles"`
// List of roles that the API Key needs to have.
Roles pulumi.StringArrayOutput `pulumi:"roles"`
// Duration in seconds after which the issued credential should expire.
Ttl pulumi.StringPtrOutput `pulumi:"ttl"`
}
// NewSecretRole registers a new resource with the given unique name, arguments, and options.
func NewSecretRole(ctx *pulumi.Context,
name string, args *SecretRoleArgs, opts ...pulumi.ResourceOption) (*SecretRole, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.Mount == nil {
return nil, errors.New("invalid value for required argument 'Mount'")
}
if args.Roles == nil {
return nil, errors.New("invalid value for required argument 'Roles'")
}
opts = internal.PkgResourceDefaultOpts(opts)
var resource SecretRole
err := ctx.RegisterResource("vault:mongodbatlas/secretRole:SecretRole", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetSecretRole gets an existing SecretRole 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 GetSecretRole(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *SecretRoleState, opts ...pulumi.ResourceOption) (*SecretRole, error) {
var resource SecretRole
err := ctx.ReadResource("vault:mongodbatlas/secretRole:SecretRole", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering SecretRole resources.
type secretRoleState struct {
// Whitelist entry in CIDR notation to be added for the API key.
CidrBlocks []string `pulumi:"cidrBlocks"`
// IP address to be added to the whitelist for the API key.
IpAddresses []string `pulumi:"ipAddresses"`
// The maximum allowed lifetime of credentials issued using this role.
MaxTtl *string `pulumi:"maxTtl"`
// Path where the MongoDB Atlas Secrets Engine is mounted.
Mount *string `pulumi:"mount"`
// The name of the role.
Name *string `pulumi:"name"`
// The namespace to provision the resource in.
// The value should not contain leading or trailing forward slashes.
// The `namespace` is always relative to the provider's configured [namespace](https://www.terraform.io/docs/providers/vault#namespace).
// *Available only for Vault Enterprise*.
Namespace *string `pulumi:"namespace"`
// Unique identifier for the organization to which the target API Key belongs.
// Required if `projectId` is not set.
OrganizationId *string `pulumi:"organizationId"`
// Unique identifier for the project to which the target API Key belongs.
// Required if `organizationId is` not set.
ProjectId *string `pulumi:"projectId"`
// Roles assigned when an org API key is assigned to a project API key.
ProjectRoles []string `pulumi:"projectRoles"`
// List of roles that the API Key needs to have.
Roles []string `pulumi:"roles"`
// Duration in seconds after which the issued credential should expire.
Ttl *string `pulumi:"ttl"`
}
type SecretRoleState struct {
// Whitelist entry in CIDR notation to be added for the API key.
CidrBlocks pulumi.StringArrayInput
// IP address to be added to the whitelist for the API key.
IpAddresses pulumi.StringArrayInput
// The maximum allowed lifetime of credentials issued using this role.
MaxTtl pulumi.StringPtrInput
// Path where the MongoDB Atlas Secrets Engine is mounted.
Mount pulumi.StringPtrInput
// The name of the role.
Name pulumi.StringPtrInput
// The namespace to provision the resource in.
// The value should not contain leading or trailing forward slashes.
// The `namespace` is always relative to the provider's configured [namespace](https://www.terraform.io/docs/providers/vault#namespace).
// *Available only for Vault Enterprise*.
Namespace pulumi.StringPtrInput
// Unique identifier for the organization to which the target API Key belongs.
// Required if `projectId` is not set.
OrganizationId pulumi.StringPtrInput
// Unique identifier for the project to which the target API Key belongs.
// Required if `organizationId is` not set.
ProjectId pulumi.StringPtrInput
// Roles assigned when an org API key is assigned to a project API key.
ProjectRoles pulumi.StringArrayInput
// List of roles that the API Key needs to have.
Roles pulumi.StringArrayInput
// Duration in seconds after which the issued credential should expire.
Ttl pulumi.StringPtrInput
}
func (SecretRoleState) ElementType() reflect.Type {
return reflect.TypeOf((*secretRoleState)(nil)).Elem()
}
type secretRoleArgs struct {
// Whitelist entry in CIDR notation to be added for the API key.
CidrBlocks []string `pulumi:"cidrBlocks"`
// IP address to be added to the whitelist for the API key.
IpAddresses []string `pulumi:"ipAddresses"`
// The maximum allowed lifetime of credentials issued using this role.
MaxTtl *string `pulumi:"maxTtl"`
// Path where the MongoDB Atlas Secrets Engine is mounted.
Mount string `pulumi:"mount"`
// The name of the role.
Name *string `pulumi:"name"`
// The namespace to provision the resource in.
// The value should not contain leading or trailing forward slashes.
// The `namespace` is always relative to the provider's configured [namespace](https://www.terraform.io/docs/providers/vault#namespace).
// *Available only for Vault Enterprise*.
Namespace *string `pulumi:"namespace"`
// Unique identifier for the organization to which the target API Key belongs.
// Required if `projectId` is not set.
OrganizationId *string `pulumi:"organizationId"`
// Unique identifier for the project to which the target API Key belongs.
// Required if `organizationId is` not set.
ProjectId *string `pulumi:"projectId"`
// Roles assigned when an org API key is assigned to a project API key.
ProjectRoles []string `pulumi:"projectRoles"`
// List of roles that the API Key needs to have.
Roles []string `pulumi:"roles"`
// Duration in seconds after which the issued credential should expire.
Ttl *string `pulumi:"ttl"`
}
// The set of arguments for constructing a SecretRole resource.
type SecretRoleArgs struct {
// Whitelist entry in CIDR notation to be added for the API key.
CidrBlocks pulumi.StringArrayInput
// IP address to be added to the whitelist for the API key.
IpAddresses pulumi.StringArrayInput
// The maximum allowed lifetime of credentials issued using this role.
MaxTtl pulumi.StringPtrInput
// Path where the MongoDB Atlas Secrets Engine is mounted.
Mount pulumi.StringInput
// The name of the role.
Name pulumi.StringPtrInput
// The namespace to provision the resource in.
// The value should not contain leading or trailing forward slashes.
// The `namespace` is always relative to the provider's configured [namespace](https://www.terraform.io/docs/providers/vault#namespace).
// *Available only for Vault Enterprise*.
Namespace pulumi.StringPtrInput
// Unique identifier for the organization to which the target API Key belongs.
// Required if `projectId` is not set.
OrganizationId pulumi.StringPtrInput
// Unique identifier for the project to which the target API Key belongs.
// Required if `organizationId is` not set.
ProjectId pulumi.StringPtrInput
// Roles assigned when an org API key is assigned to a project API key.
ProjectRoles pulumi.StringArrayInput
// List of roles that the API Key needs to have.
Roles pulumi.StringArrayInput
// Duration in seconds after which the issued credential should expire.
Ttl pulumi.StringPtrInput
}
func (SecretRoleArgs) ElementType() reflect.Type {
return reflect.TypeOf((*secretRoleArgs)(nil)).Elem()
}
type SecretRoleInput interface {
pulumi.Input
ToSecretRoleOutput() SecretRoleOutput
ToSecretRoleOutputWithContext(ctx context.Context) SecretRoleOutput
}
func (*SecretRole) ElementType() reflect.Type {
return reflect.TypeOf((**SecretRole)(nil)).Elem()
}
func (i *SecretRole) ToSecretRoleOutput() SecretRoleOutput {
return i.ToSecretRoleOutputWithContext(context.Background())
}
func (i *SecretRole) ToSecretRoleOutputWithContext(ctx context.Context) SecretRoleOutput {
return pulumi.ToOutputWithContext(ctx, i).(SecretRoleOutput)
}
// SecretRoleArrayInput is an input type that accepts SecretRoleArray and SecretRoleArrayOutput values.
// You can construct a concrete instance of `SecretRoleArrayInput` via:
//
// SecretRoleArray{ SecretRoleArgs{...} }
type SecretRoleArrayInput interface {
pulumi.Input
ToSecretRoleArrayOutput() SecretRoleArrayOutput
ToSecretRoleArrayOutputWithContext(context.Context) SecretRoleArrayOutput
}
type SecretRoleArray []SecretRoleInput
func (SecretRoleArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*SecretRole)(nil)).Elem()
}
func (i SecretRoleArray) ToSecretRoleArrayOutput() SecretRoleArrayOutput {
return i.ToSecretRoleArrayOutputWithContext(context.Background())
}
func (i SecretRoleArray) ToSecretRoleArrayOutputWithContext(ctx context.Context) SecretRoleArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(SecretRoleArrayOutput)
}
// SecretRoleMapInput is an input type that accepts SecretRoleMap and SecretRoleMapOutput values.
// You can construct a concrete instance of `SecretRoleMapInput` via:
//
// SecretRoleMap{ "key": SecretRoleArgs{...} }
type SecretRoleMapInput interface {
pulumi.Input
ToSecretRoleMapOutput() SecretRoleMapOutput
ToSecretRoleMapOutputWithContext(context.Context) SecretRoleMapOutput
}
type SecretRoleMap map[string]SecretRoleInput
func (SecretRoleMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*SecretRole)(nil)).Elem()
}
func (i SecretRoleMap) ToSecretRoleMapOutput() SecretRoleMapOutput {
return i.ToSecretRoleMapOutputWithContext(context.Background())
}
func (i SecretRoleMap) ToSecretRoleMapOutputWithContext(ctx context.Context) SecretRoleMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(SecretRoleMapOutput)
}
type SecretRoleOutput struct{ *pulumi.OutputState }
func (SecretRoleOutput) ElementType() reflect.Type {
return reflect.TypeOf((**SecretRole)(nil)).Elem()
}
func (o SecretRoleOutput) ToSecretRoleOutput() SecretRoleOutput {
return o
}
func (o SecretRoleOutput) ToSecretRoleOutputWithContext(ctx context.Context) SecretRoleOutput {
return o
}
// Whitelist entry in CIDR notation to be added for the API key.
func (o SecretRoleOutput) CidrBlocks() pulumi.StringArrayOutput {
return o.ApplyT(func(v *SecretRole) pulumi.StringArrayOutput { return v.CidrBlocks }).(pulumi.StringArrayOutput)
}
// IP address to be added to the whitelist for the API key.
func (o SecretRoleOutput) IpAddresses() pulumi.StringArrayOutput {
return o.ApplyT(func(v *SecretRole) pulumi.StringArrayOutput { return v.IpAddresses }).(pulumi.StringArrayOutput)
}
// The maximum allowed lifetime of credentials issued using this role.
func (o SecretRoleOutput) MaxTtl() pulumi.StringPtrOutput {
return o.ApplyT(func(v *SecretRole) pulumi.StringPtrOutput { return v.MaxTtl }).(pulumi.StringPtrOutput)
}
// Path where the MongoDB Atlas Secrets Engine is mounted.
func (o SecretRoleOutput) Mount() pulumi.StringOutput {
return o.ApplyT(func(v *SecretRole) pulumi.StringOutput { return v.Mount }).(pulumi.StringOutput)
}
// The name of the role.
func (o SecretRoleOutput) Name() pulumi.StringOutput {
return o.ApplyT(func(v *SecretRole) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
}
// The namespace to provision the resource in.
// The value should not contain leading or trailing forward slashes.
// The `namespace` is always relative to the provider's configured [namespace](https://www.terraform.io/docs/providers/vault#namespace).
// *Available only for Vault Enterprise*.
func (o SecretRoleOutput) Namespace() pulumi.StringPtrOutput {
return o.ApplyT(func(v *SecretRole) pulumi.StringPtrOutput { return v.Namespace }).(pulumi.StringPtrOutput)
}
// Unique identifier for the organization to which the target API Key belongs.
// Required if `projectId` is not set.
func (o SecretRoleOutput) OrganizationId() pulumi.StringPtrOutput {
return o.ApplyT(func(v *SecretRole) pulumi.StringPtrOutput { return v.OrganizationId }).(pulumi.StringPtrOutput)
}
// Unique identifier for the project to which the target API Key belongs.
// Required if `organizationId is` not set.
func (o SecretRoleOutput) ProjectId() pulumi.StringPtrOutput {
return o.ApplyT(func(v *SecretRole) pulumi.StringPtrOutput { return v.ProjectId }).(pulumi.StringPtrOutput)
}
// Roles assigned when an org API key is assigned to a project API key.
func (o SecretRoleOutput) ProjectRoles() pulumi.StringArrayOutput {
return o.ApplyT(func(v *SecretRole) pulumi.StringArrayOutput { return v.ProjectRoles }).(pulumi.StringArrayOutput)
}
// List of roles that the API Key needs to have.
func (o SecretRoleOutput) Roles() pulumi.StringArrayOutput {
return o.ApplyT(func(v *SecretRole) pulumi.StringArrayOutput { return v.Roles }).(pulumi.StringArrayOutput)
}
// Duration in seconds after which the issued credential should expire.
func (o SecretRoleOutput) Ttl() pulumi.StringPtrOutput {
return o.ApplyT(func(v *SecretRole) pulumi.StringPtrOutput { return v.Ttl }).(pulumi.StringPtrOutput)
}
type SecretRoleArrayOutput struct{ *pulumi.OutputState }
func (SecretRoleArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*SecretRole)(nil)).Elem()
}
func (o SecretRoleArrayOutput) ToSecretRoleArrayOutput() SecretRoleArrayOutput {
return o
}
func (o SecretRoleArrayOutput) ToSecretRoleArrayOutputWithContext(ctx context.Context) SecretRoleArrayOutput {
return o
}
func (o SecretRoleArrayOutput) Index(i pulumi.IntInput) SecretRoleOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *SecretRole {
return vs[0].([]*SecretRole)[vs[1].(int)]
}).(SecretRoleOutput)
}
type SecretRoleMapOutput struct{ *pulumi.OutputState }
func (SecretRoleMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*SecretRole)(nil)).Elem()
}
func (o SecretRoleMapOutput) ToSecretRoleMapOutput() SecretRoleMapOutput {
return o
}
func (o SecretRoleMapOutput) ToSecretRoleMapOutputWithContext(ctx context.Context) SecretRoleMapOutput {
return o
}
func (o SecretRoleMapOutput) MapIndex(k pulumi.StringInput) SecretRoleOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *SecretRole {
return vs[0].(map[string]*SecretRole)[vs[1].(string)]
}).(SecretRoleOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*SecretRoleInput)(nil)).Elem(), &SecretRole{})
pulumi.RegisterInputType(reflect.TypeOf((*SecretRoleArrayInput)(nil)).Elem(), SecretRoleArray{})
pulumi.RegisterInputType(reflect.TypeOf((*SecretRoleMapInput)(nil)).Elem(), SecretRoleMap{})
pulumi.RegisterOutputType(SecretRoleOutput{})
pulumi.RegisterOutputType(SecretRoleArrayOutput{})
pulumi.RegisterOutputType(SecretRoleMapOutput{})
}