/
secretBackend.go
403 lines (349 loc) · 16 KB
/
secretBackend.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
// 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 gcp
import (
"context"
"reflect"
"github.com/pulumi/pulumi-vault/sdk/v5/go/vault/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// ## Example Usage
//
// ```go
// package main
//
// import (
//
// "os"
//
// "github.com/pulumi/pulumi-vault/sdk/v5/go/vault/gcp"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func readFileOrPanic(path string) pulumi.StringPtrInput {
// data, err := os.ReadFile(path)
// if err != nil {
// panic(err.Error())
// }
// return pulumi.String(string(data))
// }
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := gcp.NewSecretBackend(ctx, "gcp", &gcp.SecretBackendArgs{
// Credentials: readFileOrPanic("credentials.json"),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
type SecretBackend struct {
pulumi.CustomResourceState
// JSON-encoded credentials to use to connect to GCP
Credentials pulumi.StringPtrOutput `pulumi:"credentials"`
// The default TTL for credentials
// issued by this backend. Defaults to '0'.
DefaultLeaseTtlSeconds pulumi.IntPtrOutput `pulumi:"defaultLeaseTtlSeconds"`
// A human-friendly description for this backend.
Description pulumi.StringPtrOutput `pulumi:"description"`
// If set, opts out of mount migration on path updates.
// See here for more info on [Mount Migration](https://www.vaultproject.io/docs/concepts/mount-migration)
DisableRemount pulumi.BoolPtrOutput `pulumi:"disableRemount"`
// Boolean flag that can be explicitly set to true to enforce local mount in HA environment
Local pulumi.BoolPtrOutput `pulumi:"local"`
// The maximum TTL that can be requested
// for credentials issued by this backend. Defaults to '0'.
MaxLeaseTtlSeconds pulumi.IntPtrOutput `pulumi:"maxLeaseTtlSeconds"`
// 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"`
// The unique path this backend should be mounted at. Must
// not begin or end with a `/`. Defaults to `gcp`.
Path pulumi.StringPtrOutput `pulumi:"path"`
}
// NewSecretBackend registers a new resource with the given unique name, arguments, and options.
func NewSecretBackend(ctx *pulumi.Context,
name string, args *SecretBackendArgs, opts ...pulumi.ResourceOption) (*SecretBackend, error) {
if args == nil {
args = &SecretBackendArgs{}
}
if args.Credentials != nil {
args.Credentials = pulumi.ToSecret(args.Credentials).(pulumi.StringPtrInput)
}
secrets := pulumi.AdditionalSecretOutputs([]string{
"credentials",
})
opts = append(opts, secrets)
opts = internal.PkgResourceDefaultOpts(opts)
var resource SecretBackend
err := ctx.RegisterResource("vault:gcp/secretBackend:SecretBackend", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetSecretBackend gets an existing SecretBackend 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 GetSecretBackend(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *SecretBackendState, opts ...pulumi.ResourceOption) (*SecretBackend, error) {
var resource SecretBackend
err := ctx.ReadResource("vault:gcp/secretBackend:SecretBackend", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering SecretBackend resources.
type secretBackendState struct {
// JSON-encoded credentials to use to connect to GCP
Credentials *string `pulumi:"credentials"`
// The default TTL for credentials
// issued by this backend. Defaults to '0'.
DefaultLeaseTtlSeconds *int `pulumi:"defaultLeaseTtlSeconds"`
// A human-friendly description for this backend.
Description *string `pulumi:"description"`
// If set, opts out of mount migration on path updates.
// See here for more info on [Mount Migration](https://www.vaultproject.io/docs/concepts/mount-migration)
DisableRemount *bool `pulumi:"disableRemount"`
// Boolean flag that can be explicitly set to true to enforce local mount in HA environment
Local *bool `pulumi:"local"`
// The maximum TTL that can be requested
// for credentials issued by this backend. Defaults to '0'.
MaxLeaseTtlSeconds *int `pulumi:"maxLeaseTtlSeconds"`
// 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"`
// The unique path this backend should be mounted at. Must
// not begin or end with a `/`. Defaults to `gcp`.
Path *string `pulumi:"path"`
}
type SecretBackendState struct {
// JSON-encoded credentials to use to connect to GCP
Credentials pulumi.StringPtrInput
// The default TTL for credentials
// issued by this backend. Defaults to '0'.
DefaultLeaseTtlSeconds pulumi.IntPtrInput
// A human-friendly description for this backend.
Description pulumi.StringPtrInput
// If set, opts out of mount migration on path updates.
// See here for more info on [Mount Migration](https://www.vaultproject.io/docs/concepts/mount-migration)
DisableRemount pulumi.BoolPtrInput
// Boolean flag that can be explicitly set to true to enforce local mount in HA environment
Local pulumi.BoolPtrInput
// The maximum TTL that can be requested
// for credentials issued by this backend. Defaults to '0'.
MaxLeaseTtlSeconds pulumi.IntPtrInput
// 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
// The unique path this backend should be mounted at. Must
// not begin or end with a `/`. Defaults to `gcp`.
Path pulumi.StringPtrInput
}
func (SecretBackendState) ElementType() reflect.Type {
return reflect.TypeOf((*secretBackendState)(nil)).Elem()
}
type secretBackendArgs struct {
// JSON-encoded credentials to use to connect to GCP
Credentials *string `pulumi:"credentials"`
// The default TTL for credentials
// issued by this backend. Defaults to '0'.
DefaultLeaseTtlSeconds *int `pulumi:"defaultLeaseTtlSeconds"`
// A human-friendly description for this backend.
Description *string `pulumi:"description"`
// If set, opts out of mount migration on path updates.
// See here for more info on [Mount Migration](https://www.vaultproject.io/docs/concepts/mount-migration)
DisableRemount *bool `pulumi:"disableRemount"`
// Boolean flag that can be explicitly set to true to enforce local mount in HA environment
Local *bool `pulumi:"local"`
// The maximum TTL that can be requested
// for credentials issued by this backend. Defaults to '0'.
MaxLeaseTtlSeconds *int `pulumi:"maxLeaseTtlSeconds"`
// 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"`
// The unique path this backend should be mounted at. Must
// not begin or end with a `/`. Defaults to `gcp`.
Path *string `pulumi:"path"`
}
// The set of arguments for constructing a SecretBackend resource.
type SecretBackendArgs struct {
// JSON-encoded credentials to use to connect to GCP
Credentials pulumi.StringPtrInput
// The default TTL for credentials
// issued by this backend. Defaults to '0'.
DefaultLeaseTtlSeconds pulumi.IntPtrInput
// A human-friendly description for this backend.
Description pulumi.StringPtrInput
// If set, opts out of mount migration on path updates.
// See here for more info on [Mount Migration](https://www.vaultproject.io/docs/concepts/mount-migration)
DisableRemount pulumi.BoolPtrInput
// Boolean flag that can be explicitly set to true to enforce local mount in HA environment
Local pulumi.BoolPtrInput
// The maximum TTL that can be requested
// for credentials issued by this backend. Defaults to '0'.
MaxLeaseTtlSeconds pulumi.IntPtrInput
// 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
// The unique path this backend should be mounted at. Must
// not begin or end with a `/`. Defaults to `gcp`.
Path pulumi.StringPtrInput
}
func (SecretBackendArgs) ElementType() reflect.Type {
return reflect.TypeOf((*secretBackendArgs)(nil)).Elem()
}
type SecretBackendInput interface {
pulumi.Input
ToSecretBackendOutput() SecretBackendOutput
ToSecretBackendOutputWithContext(ctx context.Context) SecretBackendOutput
}
func (*SecretBackend) ElementType() reflect.Type {
return reflect.TypeOf((**SecretBackend)(nil)).Elem()
}
func (i *SecretBackend) ToSecretBackendOutput() SecretBackendOutput {
return i.ToSecretBackendOutputWithContext(context.Background())
}
func (i *SecretBackend) ToSecretBackendOutputWithContext(ctx context.Context) SecretBackendOutput {
return pulumi.ToOutputWithContext(ctx, i).(SecretBackendOutput)
}
// SecretBackendArrayInput is an input type that accepts SecretBackendArray and SecretBackendArrayOutput values.
// You can construct a concrete instance of `SecretBackendArrayInput` via:
//
// SecretBackendArray{ SecretBackendArgs{...} }
type SecretBackendArrayInput interface {
pulumi.Input
ToSecretBackendArrayOutput() SecretBackendArrayOutput
ToSecretBackendArrayOutputWithContext(context.Context) SecretBackendArrayOutput
}
type SecretBackendArray []SecretBackendInput
func (SecretBackendArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*SecretBackend)(nil)).Elem()
}
func (i SecretBackendArray) ToSecretBackendArrayOutput() SecretBackendArrayOutput {
return i.ToSecretBackendArrayOutputWithContext(context.Background())
}
func (i SecretBackendArray) ToSecretBackendArrayOutputWithContext(ctx context.Context) SecretBackendArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(SecretBackendArrayOutput)
}
// SecretBackendMapInput is an input type that accepts SecretBackendMap and SecretBackendMapOutput values.
// You can construct a concrete instance of `SecretBackendMapInput` via:
//
// SecretBackendMap{ "key": SecretBackendArgs{...} }
type SecretBackendMapInput interface {
pulumi.Input
ToSecretBackendMapOutput() SecretBackendMapOutput
ToSecretBackendMapOutputWithContext(context.Context) SecretBackendMapOutput
}
type SecretBackendMap map[string]SecretBackendInput
func (SecretBackendMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*SecretBackend)(nil)).Elem()
}
func (i SecretBackendMap) ToSecretBackendMapOutput() SecretBackendMapOutput {
return i.ToSecretBackendMapOutputWithContext(context.Background())
}
func (i SecretBackendMap) ToSecretBackendMapOutputWithContext(ctx context.Context) SecretBackendMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(SecretBackendMapOutput)
}
type SecretBackendOutput struct{ *pulumi.OutputState }
func (SecretBackendOutput) ElementType() reflect.Type {
return reflect.TypeOf((**SecretBackend)(nil)).Elem()
}
func (o SecretBackendOutput) ToSecretBackendOutput() SecretBackendOutput {
return o
}
func (o SecretBackendOutput) ToSecretBackendOutputWithContext(ctx context.Context) SecretBackendOutput {
return o
}
// JSON-encoded credentials to use to connect to GCP
func (o SecretBackendOutput) Credentials() pulumi.StringPtrOutput {
return o.ApplyT(func(v *SecretBackend) pulumi.StringPtrOutput { return v.Credentials }).(pulumi.StringPtrOutput)
}
// The default TTL for credentials
// issued by this backend. Defaults to '0'.
func (o SecretBackendOutput) DefaultLeaseTtlSeconds() pulumi.IntPtrOutput {
return o.ApplyT(func(v *SecretBackend) pulumi.IntPtrOutput { return v.DefaultLeaseTtlSeconds }).(pulumi.IntPtrOutput)
}
// A human-friendly description for this backend.
func (o SecretBackendOutput) Description() pulumi.StringPtrOutput {
return o.ApplyT(func(v *SecretBackend) pulumi.StringPtrOutput { return v.Description }).(pulumi.StringPtrOutput)
}
// If set, opts out of mount migration on path updates.
// See here for more info on [Mount Migration](https://www.vaultproject.io/docs/concepts/mount-migration)
func (o SecretBackendOutput) DisableRemount() pulumi.BoolPtrOutput {
return o.ApplyT(func(v *SecretBackend) pulumi.BoolPtrOutput { return v.DisableRemount }).(pulumi.BoolPtrOutput)
}
// Boolean flag that can be explicitly set to true to enforce local mount in HA environment
func (o SecretBackendOutput) Local() pulumi.BoolPtrOutput {
return o.ApplyT(func(v *SecretBackend) pulumi.BoolPtrOutput { return v.Local }).(pulumi.BoolPtrOutput)
}
// The maximum TTL that can be requested
// for credentials issued by this backend. Defaults to '0'.
func (o SecretBackendOutput) MaxLeaseTtlSeconds() pulumi.IntPtrOutput {
return o.ApplyT(func(v *SecretBackend) pulumi.IntPtrOutput { return v.MaxLeaseTtlSeconds }).(pulumi.IntPtrOutput)
}
// 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 SecretBackendOutput) Namespace() pulumi.StringPtrOutput {
return o.ApplyT(func(v *SecretBackend) pulumi.StringPtrOutput { return v.Namespace }).(pulumi.StringPtrOutput)
}
// The unique path this backend should be mounted at. Must
// not begin or end with a `/`. Defaults to `gcp`.
func (o SecretBackendOutput) Path() pulumi.StringPtrOutput {
return o.ApplyT(func(v *SecretBackend) pulumi.StringPtrOutput { return v.Path }).(pulumi.StringPtrOutput)
}
type SecretBackendArrayOutput struct{ *pulumi.OutputState }
func (SecretBackendArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*SecretBackend)(nil)).Elem()
}
func (o SecretBackendArrayOutput) ToSecretBackendArrayOutput() SecretBackendArrayOutput {
return o
}
func (o SecretBackendArrayOutput) ToSecretBackendArrayOutputWithContext(ctx context.Context) SecretBackendArrayOutput {
return o
}
func (o SecretBackendArrayOutput) Index(i pulumi.IntInput) SecretBackendOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *SecretBackend {
return vs[0].([]*SecretBackend)[vs[1].(int)]
}).(SecretBackendOutput)
}
type SecretBackendMapOutput struct{ *pulumi.OutputState }
func (SecretBackendMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*SecretBackend)(nil)).Elem()
}
func (o SecretBackendMapOutput) ToSecretBackendMapOutput() SecretBackendMapOutput {
return o
}
func (o SecretBackendMapOutput) ToSecretBackendMapOutputWithContext(ctx context.Context) SecretBackendMapOutput {
return o
}
func (o SecretBackendMapOutput) MapIndex(k pulumi.StringInput) SecretBackendOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *SecretBackend {
return vs[0].(map[string]*SecretBackend)[vs[1].(string)]
}).(SecretBackendOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*SecretBackendInput)(nil)).Elem(), &SecretBackend{})
pulumi.RegisterInputType(reflect.TypeOf((*SecretBackendArrayInput)(nil)).Elem(), SecretBackendArray{})
pulumi.RegisterInputType(reflect.TypeOf((*SecretBackendMapInput)(nil)).Elem(), SecretBackendMap{})
pulumi.RegisterOutputType(SecretBackendOutput{})
pulumi.RegisterOutputType(SecretBackendArrayOutput{})
pulumi.RegisterOutputType(SecretBackendMapOutput{})
}