generated from pulumi/pulumi-tf-provider-boilerplate
/
aclToken.go
517 lines (461 loc) · 17.9 KB
/
aclToken.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
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
// 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 nomad
import (
"context"
"reflect"
"errors"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// ## Example Usage
//
// Creating a token with limited policies:
//
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-nomad/sdk/go/nomad"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := nomad.NewAclToken(ctx, "dakota", &nomad.AclTokenArgs{
// Policies: pulumi.StringArray{
// pulumi.String("dev"),
// pulumi.String("qa"),
// },
// Type: pulumi.String("client"),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
//
// Creating a global token that will be replicated to all regions:
//
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-nomad/sdk/go/nomad"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := nomad.NewAclToken(ctx, "dakota", &nomad.AclTokenArgs{
// Global: pulumi.Bool(true),
// Policies: pulumi.StringArray{
// pulumi.String("dev"),
// pulumi.String("qa"),
// },
// Type: pulumi.String("client"),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
//
// Creating a token with full access to the cluster:
//
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-nomad/sdk/go/nomad"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := nomad.NewAclToken(ctx, "iman", &nomad.AclTokenArgs{
// Type: pulumi.String("management"),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
//
// Accessing the token:
//
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-nomad/sdk/go/nomad"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// token, err := nomad.NewAclToken(ctx, "token", &nomad.AclTokenArgs{
// Type: pulumi.String("client"),
// Policies: pulumi.StringArray{
// pulumi.String("dev"),
// },
// })
// if err != nil {
// return err
// }
// ctx.Export("nomadToken", token.SecretId)
// return nil
// })
// }
//
// ```
type AclToken struct {
pulumi.CustomResourceState
// `(string)` - A non-sensitive identifier for this token that
// can be logged and shared safely without granting any access to the cluster.
AccessorId pulumi.StringOutput `pulumi:"accessorId"`
// `(string)` - The timestamp the token was created.
CreateTime pulumi.StringOutput `pulumi:"createTime"`
// `(string)` - The timestamp after which the token is
// considered expired and eligible for destruction.
ExpirationTime pulumi.StringOutput `pulumi:"expirationTime"`
// `(string: "")` - Provides a TTL for the token in the form of
// a time duration such as `"5m"` or `"1h"`.
ExpirationTtl pulumi.StringPtrOutput `pulumi:"expirationTtl"`
// `(bool: false)` - Whether the token should be replicated to all
// regions, or if it will only be used in the region it was created in.
Global pulumi.BoolPtrOutput `pulumi:"global"`
// `(string: "")` - A human-friendly name for this token.
Name pulumi.StringOutput `pulumi:"name"`
// `(set: [])` - A set of policy names to associate with this
// token. Must be set on `client`-type tokens, must not be set on
// `management`-type tokens. Policies do not need to exist before being
// used here.
Policies pulumi.StringArrayOutput `pulumi:"policies"`
// `(set: [])` - The list of roles attached to the token. Each entry has
// `name` and `id` attributes. It may be used multiple times.
Roles AclTokenRoleArrayOutput `pulumi:"roles"`
// `(string)` - The token value itself, which is presented for
// access to the cluster.
SecretId pulumi.StringOutput `pulumi:"secretId"`
// `(string: <required>)` - The type of token this is. Use `client`
// for tokens that will have policies associated with them. Use `management`
// for tokens that can perform any action.
Type pulumi.StringOutput `pulumi:"type"`
}
// NewAclToken registers a new resource with the given unique name, arguments, and options.
func NewAclToken(ctx *pulumi.Context,
name string, args *AclTokenArgs, opts ...pulumi.ResourceOption) (*AclToken, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.Type == nil {
return nil, errors.New("invalid value for required argument 'Type'")
}
secrets := pulumi.AdditionalSecretOutputs([]string{
"secretId",
})
opts = append(opts, secrets)
var resource AclToken
err := ctx.RegisterResource("nomad:index/aclToken:AclToken", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetAclToken gets an existing AclToken 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 GetAclToken(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *AclTokenState, opts ...pulumi.ResourceOption) (*AclToken, error) {
var resource AclToken
err := ctx.ReadResource("nomad:index/aclToken:AclToken", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering AclToken resources.
type aclTokenState struct {
// `(string)` - A non-sensitive identifier for this token that
// can be logged and shared safely without granting any access to the cluster.
AccessorId *string `pulumi:"accessorId"`
// `(string)` - The timestamp the token was created.
CreateTime *string `pulumi:"createTime"`
// `(string)` - The timestamp after which the token is
// considered expired and eligible for destruction.
ExpirationTime *string `pulumi:"expirationTime"`
// `(string: "")` - Provides a TTL for the token in the form of
// a time duration such as `"5m"` or `"1h"`.
ExpirationTtl *string `pulumi:"expirationTtl"`
// `(bool: false)` - Whether the token should be replicated to all
// regions, or if it will only be used in the region it was created in.
Global *bool `pulumi:"global"`
// `(string: "")` - A human-friendly name for this token.
Name *string `pulumi:"name"`
// `(set: [])` - A set of policy names to associate with this
// token. Must be set on `client`-type tokens, must not be set on
// `management`-type tokens. Policies do not need to exist before being
// used here.
Policies []string `pulumi:"policies"`
// `(set: [])` - The list of roles attached to the token. Each entry has
// `name` and `id` attributes. It may be used multiple times.
Roles []AclTokenRole `pulumi:"roles"`
// `(string)` - The token value itself, which is presented for
// access to the cluster.
SecretId *string `pulumi:"secretId"`
// `(string: <required>)` - The type of token this is. Use `client`
// for tokens that will have policies associated with them. Use `management`
// for tokens that can perform any action.
Type *string `pulumi:"type"`
}
type AclTokenState struct {
// `(string)` - A non-sensitive identifier for this token that
// can be logged and shared safely without granting any access to the cluster.
AccessorId pulumi.StringPtrInput
// `(string)` - The timestamp the token was created.
CreateTime pulumi.StringPtrInput
// `(string)` - The timestamp after which the token is
// considered expired and eligible for destruction.
ExpirationTime pulumi.StringPtrInput
// `(string: "")` - Provides a TTL for the token in the form of
// a time duration such as `"5m"` or `"1h"`.
ExpirationTtl pulumi.StringPtrInput
// `(bool: false)` - Whether the token should be replicated to all
// regions, or if it will only be used in the region it was created in.
Global pulumi.BoolPtrInput
// `(string: "")` - A human-friendly name for this token.
Name pulumi.StringPtrInput
// `(set: [])` - A set of policy names to associate with this
// token. Must be set on `client`-type tokens, must not be set on
// `management`-type tokens. Policies do not need to exist before being
// used here.
Policies pulumi.StringArrayInput
// `(set: [])` - The list of roles attached to the token. Each entry has
// `name` and `id` attributes. It may be used multiple times.
Roles AclTokenRoleArrayInput
// `(string)` - The token value itself, which is presented for
// access to the cluster.
SecretId pulumi.StringPtrInput
// `(string: <required>)` - The type of token this is. Use `client`
// for tokens that will have policies associated with them. Use `management`
// for tokens that can perform any action.
Type pulumi.StringPtrInput
}
func (AclTokenState) ElementType() reflect.Type {
return reflect.TypeOf((*aclTokenState)(nil)).Elem()
}
type aclTokenArgs struct {
// `(string: "")` - Provides a TTL for the token in the form of
// a time duration such as `"5m"` or `"1h"`.
ExpirationTtl *string `pulumi:"expirationTtl"`
// `(bool: false)` - Whether the token should be replicated to all
// regions, or if it will only be used in the region it was created in.
Global *bool `pulumi:"global"`
// `(string: "")` - A human-friendly name for this token.
Name *string `pulumi:"name"`
// `(set: [])` - A set of policy names to associate with this
// token. Must be set on `client`-type tokens, must not be set on
// `management`-type tokens. Policies do not need to exist before being
// used here.
Policies []string `pulumi:"policies"`
// `(set: [])` - The list of roles attached to the token. Each entry has
// `name` and `id` attributes. It may be used multiple times.
Roles []AclTokenRole `pulumi:"roles"`
// `(string: <required>)` - The type of token this is. Use `client`
// for tokens that will have policies associated with them. Use `management`
// for tokens that can perform any action.
Type string `pulumi:"type"`
}
// The set of arguments for constructing a AclToken resource.
type AclTokenArgs struct {
// `(string: "")` - Provides a TTL for the token in the form of
// a time duration such as `"5m"` or `"1h"`.
ExpirationTtl pulumi.StringPtrInput
// `(bool: false)` - Whether the token should be replicated to all
// regions, or if it will only be used in the region it was created in.
Global pulumi.BoolPtrInput
// `(string: "")` - A human-friendly name for this token.
Name pulumi.StringPtrInput
// `(set: [])` - A set of policy names to associate with this
// token. Must be set on `client`-type tokens, must not be set on
// `management`-type tokens. Policies do not need to exist before being
// used here.
Policies pulumi.StringArrayInput
// `(set: [])` - The list of roles attached to the token. Each entry has
// `name` and `id` attributes. It may be used multiple times.
Roles AclTokenRoleArrayInput
// `(string: <required>)` - The type of token this is. Use `client`
// for tokens that will have policies associated with them. Use `management`
// for tokens that can perform any action.
Type pulumi.StringInput
}
func (AclTokenArgs) ElementType() reflect.Type {
return reflect.TypeOf((*aclTokenArgs)(nil)).Elem()
}
type AclTokenInput interface {
pulumi.Input
ToAclTokenOutput() AclTokenOutput
ToAclTokenOutputWithContext(ctx context.Context) AclTokenOutput
}
func (*AclToken) ElementType() reflect.Type {
return reflect.TypeOf((**AclToken)(nil)).Elem()
}
func (i *AclToken) ToAclTokenOutput() AclTokenOutput {
return i.ToAclTokenOutputWithContext(context.Background())
}
func (i *AclToken) ToAclTokenOutputWithContext(ctx context.Context) AclTokenOutput {
return pulumi.ToOutputWithContext(ctx, i).(AclTokenOutput)
}
// AclTokenArrayInput is an input type that accepts AclTokenArray and AclTokenArrayOutput values.
// You can construct a concrete instance of `AclTokenArrayInput` via:
//
// AclTokenArray{ AclTokenArgs{...} }
type AclTokenArrayInput interface {
pulumi.Input
ToAclTokenArrayOutput() AclTokenArrayOutput
ToAclTokenArrayOutputWithContext(context.Context) AclTokenArrayOutput
}
type AclTokenArray []AclTokenInput
func (AclTokenArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*AclToken)(nil)).Elem()
}
func (i AclTokenArray) ToAclTokenArrayOutput() AclTokenArrayOutput {
return i.ToAclTokenArrayOutputWithContext(context.Background())
}
func (i AclTokenArray) ToAclTokenArrayOutputWithContext(ctx context.Context) AclTokenArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(AclTokenArrayOutput)
}
// AclTokenMapInput is an input type that accepts AclTokenMap and AclTokenMapOutput values.
// You can construct a concrete instance of `AclTokenMapInput` via:
//
// AclTokenMap{ "key": AclTokenArgs{...} }
type AclTokenMapInput interface {
pulumi.Input
ToAclTokenMapOutput() AclTokenMapOutput
ToAclTokenMapOutputWithContext(context.Context) AclTokenMapOutput
}
type AclTokenMap map[string]AclTokenInput
func (AclTokenMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*AclToken)(nil)).Elem()
}
func (i AclTokenMap) ToAclTokenMapOutput() AclTokenMapOutput {
return i.ToAclTokenMapOutputWithContext(context.Background())
}
func (i AclTokenMap) ToAclTokenMapOutputWithContext(ctx context.Context) AclTokenMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(AclTokenMapOutput)
}
type AclTokenOutput struct{ *pulumi.OutputState }
func (AclTokenOutput) ElementType() reflect.Type {
return reflect.TypeOf((**AclToken)(nil)).Elem()
}
func (o AclTokenOutput) ToAclTokenOutput() AclTokenOutput {
return o
}
func (o AclTokenOutput) ToAclTokenOutputWithContext(ctx context.Context) AclTokenOutput {
return o
}
// `(string)` - A non-sensitive identifier for this token that
// can be logged and shared safely without granting any access to the cluster.
func (o AclTokenOutput) AccessorId() pulumi.StringOutput {
return o.ApplyT(func(v *AclToken) pulumi.StringOutput { return v.AccessorId }).(pulumi.StringOutput)
}
// `(string)` - The timestamp the token was created.
func (o AclTokenOutput) CreateTime() pulumi.StringOutput {
return o.ApplyT(func(v *AclToken) pulumi.StringOutput { return v.CreateTime }).(pulumi.StringOutput)
}
// `(string)` - The timestamp after which the token is
// considered expired and eligible for destruction.
func (o AclTokenOutput) ExpirationTime() pulumi.StringOutput {
return o.ApplyT(func(v *AclToken) pulumi.StringOutput { return v.ExpirationTime }).(pulumi.StringOutput)
}
// `(string: "")` - Provides a TTL for the token in the form of
// a time duration such as `"5m"` or `"1h"`.
func (o AclTokenOutput) ExpirationTtl() pulumi.StringPtrOutput {
return o.ApplyT(func(v *AclToken) pulumi.StringPtrOutput { return v.ExpirationTtl }).(pulumi.StringPtrOutput)
}
// `(bool: false)` - Whether the token should be replicated to all
// regions, or if it will only be used in the region it was created in.
func (o AclTokenOutput) Global() pulumi.BoolPtrOutput {
return o.ApplyT(func(v *AclToken) pulumi.BoolPtrOutput { return v.Global }).(pulumi.BoolPtrOutput)
}
// `(string: "")` - A human-friendly name for this token.
func (o AclTokenOutput) Name() pulumi.StringOutput {
return o.ApplyT(func(v *AclToken) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
}
// `(set: [])` - A set of policy names to associate with this
// token. Must be set on `client`-type tokens, must not be set on
// `management`-type tokens. Policies do not need to exist before being
// used here.
func (o AclTokenOutput) Policies() pulumi.StringArrayOutput {
return o.ApplyT(func(v *AclToken) pulumi.StringArrayOutput { return v.Policies }).(pulumi.StringArrayOutput)
}
// `(set: [])` - The list of roles attached to the token. Each entry has
// `name` and `id` attributes. It may be used multiple times.
func (o AclTokenOutput) Roles() AclTokenRoleArrayOutput {
return o.ApplyT(func(v *AclToken) AclTokenRoleArrayOutput { return v.Roles }).(AclTokenRoleArrayOutput)
}
// `(string)` - The token value itself, which is presented for
// access to the cluster.
func (o AclTokenOutput) SecretId() pulumi.StringOutput {
return o.ApplyT(func(v *AclToken) pulumi.StringOutput { return v.SecretId }).(pulumi.StringOutput)
}
// `(string: <required>)` - The type of token this is. Use `client`
// for tokens that will have policies associated with them. Use `management`
// for tokens that can perform any action.
func (o AclTokenOutput) Type() pulumi.StringOutput {
return o.ApplyT(func(v *AclToken) pulumi.StringOutput { return v.Type }).(pulumi.StringOutput)
}
type AclTokenArrayOutput struct{ *pulumi.OutputState }
func (AclTokenArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*AclToken)(nil)).Elem()
}
func (o AclTokenArrayOutput) ToAclTokenArrayOutput() AclTokenArrayOutput {
return o
}
func (o AclTokenArrayOutput) ToAclTokenArrayOutputWithContext(ctx context.Context) AclTokenArrayOutput {
return o
}
func (o AclTokenArrayOutput) Index(i pulumi.IntInput) AclTokenOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *AclToken {
return vs[0].([]*AclToken)[vs[1].(int)]
}).(AclTokenOutput)
}
type AclTokenMapOutput struct{ *pulumi.OutputState }
func (AclTokenMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*AclToken)(nil)).Elem()
}
func (o AclTokenMapOutput) ToAclTokenMapOutput() AclTokenMapOutput {
return o
}
func (o AclTokenMapOutput) ToAclTokenMapOutputWithContext(ctx context.Context) AclTokenMapOutput {
return o
}
func (o AclTokenMapOutput) MapIndex(k pulumi.StringInput) AclTokenOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *AclToken {
return vs[0].(map[string]*AclToken)[vs[1].(string)]
}).(AclTokenOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*AclTokenInput)(nil)).Elem(), &AclToken{})
pulumi.RegisterInputType(reflect.TypeOf((*AclTokenArrayInput)(nil)).Elem(), AclTokenArray{})
pulumi.RegisterInputType(reflect.TypeOf((*AclTokenMapInput)(nil)).Elem(), AclTokenMap{})
pulumi.RegisterOutputType(AclTokenOutput{})
pulumi.RegisterOutputType(AclTokenArrayOutput{})
pulumi.RegisterOutputType(AclTokenMapOutput{})
}