/
kmsconfig.go
468 lines (412 loc) · 18.5 KB
/
kmsconfig.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
// 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 netapp
import (
"context"
"reflect"
"errors"
"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// NetApp Volumes always encrypts your data at rest using volume-specific keys.
//
// A CMEK policy (customer-managed encryption key) warps such volume-specific keys in a key stored in Cloud Key Management Service (KMS).
//
// To get more information about kmsconfig, see:
//
// * [API documentation](https://cloud.google.com/netapp/volumes/docs/reference/rest/v1/projects.locations.kmsConfigs)
// * How-to Guides
// - [Documentation](https://cloud.google.com/netapp/volumes/docs/configure-and-use/cmek/cmek-overview)
//
// ## Example Usage
//
// ### Kms Config Create
//
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/kms"
// "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/netapp"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// keyring, err := kms.NewKeyRing(ctx, "keyring", &kms.KeyRingArgs{
// Name: pulumi.String("key-ring"),
// Location: pulumi.String("us-central1"),
// })
// if err != nil {
// return err
// }
// cryptoKey, err := kms.NewCryptoKey(ctx, "crypto_key", &kms.CryptoKeyArgs{
// Name: pulumi.String("crypto-name"),
// KeyRing: keyring.ID(),
// })
// if err != nil {
// return err
// }
// _, err = netapp.NewKmsconfig(ctx, "kmsConfig", &netapp.KmsconfigArgs{
// Name: pulumi.String("kms-test"),
// Description: pulumi.String("this is a test description"),
// CryptoKeyName: cryptoKey.ID(),
// Location: pulumi.String("us-central1"),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
//
// ## Import
//
// kmsconfig can be imported using any of these accepted formats:
//
// * `projects/{{project}}/locations/{{location}}/kmsConfigs/{{name}}`
//
// * `{{project}}/{{location}}/{{name}}`
//
// * `{{location}}/{{name}}`
//
// When using the `pulumi import` command, kmsconfig can be imported using one of the formats above. For example:
//
// ```sh
// $ pulumi import gcp:netapp/kmsconfig:Kmsconfig default projects/{{project}}/locations/{{location}}/kmsConfigs/{{name}}
// ```
//
// ```sh
// $ pulumi import gcp:netapp/kmsconfig:Kmsconfig default {{project}}/{{location}}/{{name}}
// ```
//
// ```sh
// $ pulumi import gcp:netapp/kmsconfig:Kmsconfig default {{location}}/{{name}}
// ```
type Kmsconfig struct {
pulumi.CustomResourceState
// Resource name of the KMS key to use. Only regional keys are supported. Format: `projects/{{project}}/locations/{{location}}/keyRings/{{key_ring}}/cryptoKeys/{{key}}`.
CryptoKeyName pulumi.StringOutput `pulumi:"cryptoKeyName"`
// Description for the CMEK policy.
Description pulumi.StringPtrOutput `pulumi:"description"`
// All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
EffectiveLabels pulumi.StringMapOutput `pulumi:"effectiveLabels"`
// Access to the key needs to be granted. The instructions contain gcloud commands to run to grant access.
// To make the policy work, a CMEK policy check is required, which verifies key access.
Instructions pulumi.StringOutput `pulumi:"instructions"`
// Labels as key value pairs. Example: `{ "owner": "Bob", "department": "finance", "purpose": "testing" }`.
//
// **Note**: This field is non-authoritative, and will only manage the labels present in your configuration.
// Please refer to the field `effectiveLabels` for all of the labels present on the resource.
Labels pulumi.StringMapOutput `pulumi:"labels"`
// Name of the policy location. CMEK policies apply to the whole region.
Location pulumi.StringOutput `pulumi:"location"`
// Name of the CMEK policy.
//
// ***
Name pulumi.StringOutput `pulumi:"name"`
// The ID of the project in which the resource belongs.
// If it is not provided, the provider project is used.
Project pulumi.StringOutput `pulumi:"project"`
// The combination of labels configured directly on the resource
// and default labels configured on the provider.
PulumiLabels pulumi.StringMapOutput `pulumi:"pulumiLabels"`
// The Service account which needs to have access to the provided KMS key.
ServiceAccount pulumi.StringOutput `pulumi:"serviceAccount"`
}
// NewKmsconfig registers a new resource with the given unique name, arguments, and options.
func NewKmsconfig(ctx *pulumi.Context,
name string, args *KmsconfigArgs, opts ...pulumi.ResourceOption) (*Kmsconfig, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.CryptoKeyName == nil {
return nil, errors.New("invalid value for required argument 'CryptoKeyName'")
}
if args.Location == nil {
return nil, errors.New("invalid value for required argument 'Location'")
}
secrets := pulumi.AdditionalSecretOutputs([]string{
"effectiveLabels",
"pulumiLabels",
})
opts = append(opts, secrets)
opts = internal.PkgResourceDefaultOpts(opts)
var resource Kmsconfig
err := ctx.RegisterResource("gcp:netapp/kmsconfig:Kmsconfig", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetKmsconfig gets an existing Kmsconfig 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 GetKmsconfig(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *KmsconfigState, opts ...pulumi.ResourceOption) (*Kmsconfig, error) {
var resource Kmsconfig
err := ctx.ReadResource("gcp:netapp/kmsconfig:Kmsconfig", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering Kmsconfig resources.
type kmsconfigState struct {
// Resource name of the KMS key to use. Only regional keys are supported. Format: `projects/{{project}}/locations/{{location}}/keyRings/{{key_ring}}/cryptoKeys/{{key}}`.
CryptoKeyName *string `pulumi:"cryptoKeyName"`
// Description for the CMEK policy.
Description *string `pulumi:"description"`
// All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
EffectiveLabels map[string]string `pulumi:"effectiveLabels"`
// Access to the key needs to be granted. The instructions contain gcloud commands to run to grant access.
// To make the policy work, a CMEK policy check is required, which verifies key access.
Instructions *string `pulumi:"instructions"`
// Labels as key value pairs. Example: `{ "owner": "Bob", "department": "finance", "purpose": "testing" }`.
//
// **Note**: This field is non-authoritative, and will only manage the labels present in your configuration.
// Please refer to the field `effectiveLabels` for all of the labels present on the resource.
Labels map[string]string `pulumi:"labels"`
// Name of the policy location. CMEK policies apply to the whole region.
Location *string `pulumi:"location"`
// Name of the CMEK policy.
//
// ***
Name *string `pulumi:"name"`
// The ID of the project in which the resource belongs.
// If it is not provided, the provider project is used.
Project *string `pulumi:"project"`
// The combination of labels configured directly on the resource
// and default labels configured on the provider.
PulumiLabels map[string]string `pulumi:"pulumiLabels"`
// The Service account which needs to have access to the provided KMS key.
ServiceAccount *string `pulumi:"serviceAccount"`
}
type KmsconfigState struct {
// Resource name of the KMS key to use. Only regional keys are supported. Format: `projects/{{project}}/locations/{{location}}/keyRings/{{key_ring}}/cryptoKeys/{{key}}`.
CryptoKeyName pulumi.StringPtrInput
// Description for the CMEK policy.
Description pulumi.StringPtrInput
// All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
EffectiveLabels pulumi.StringMapInput
// Access to the key needs to be granted. The instructions contain gcloud commands to run to grant access.
// To make the policy work, a CMEK policy check is required, which verifies key access.
Instructions pulumi.StringPtrInput
// Labels as key value pairs. Example: `{ "owner": "Bob", "department": "finance", "purpose": "testing" }`.
//
// **Note**: This field is non-authoritative, and will only manage the labels present in your configuration.
// Please refer to the field `effectiveLabels` for all of the labels present on the resource.
Labels pulumi.StringMapInput
// Name of the policy location. CMEK policies apply to the whole region.
Location pulumi.StringPtrInput
// Name of the CMEK policy.
//
// ***
Name pulumi.StringPtrInput
// The ID of the project in which the resource belongs.
// If it is not provided, the provider project is used.
Project pulumi.StringPtrInput
// The combination of labels configured directly on the resource
// and default labels configured on the provider.
PulumiLabels pulumi.StringMapInput
// The Service account which needs to have access to the provided KMS key.
ServiceAccount pulumi.StringPtrInput
}
func (KmsconfigState) ElementType() reflect.Type {
return reflect.TypeOf((*kmsconfigState)(nil)).Elem()
}
type kmsconfigArgs struct {
// Resource name of the KMS key to use. Only regional keys are supported. Format: `projects/{{project}}/locations/{{location}}/keyRings/{{key_ring}}/cryptoKeys/{{key}}`.
CryptoKeyName string `pulumi:"cryptoKeyName"`
// Description for the CMEK policy.
Description *string `pulumi:"description"`
// Labels as key value pairs. Example: `{ "owner": "Bob", "department": "finance", "purpose": "testing" }`.
//
// **Note**: This field is non-authoritative, and will only manage the labels present in your configuration.
// Please refer to the field `effectiveLabels` for all of the labels present on the resource.
Labels map[string]string `pulumi:"labels"`
// Name of the policy location. CMEK policies apply to the whole region.
Location string `pulumi:"location"`
// Name of the CMEK policy.
//
// ***
Name *string `pulumi:"name"`
// The ID of the project in which the resource belongs.
// If it is not provided, the provider project is used.
Project *string `pulumi:"project"`
}
// The set of arguments for constructing a Kmsconfig resource.
type KmsconfigArgs struct {
// Resource name of the KMS key to use. Only regional keys are supported. Format: `projects/{{project}}/locations/{{location}}/keyRings/{{key_ring}}/cryptoKeys/{{key}}`.
CryptoKeyName pulumi.StringInput
// Description for the CMEK policy.
Description pulumi.StringPtrInput
// Labels as key value pairs. Example: `{ "owner": "Bob", "department": "finance", "purpose": "testing" }`.
//
// **Note**: This field is non-authoritative, and will only manage the labels present in your configuration.
// Please refer to the field `effectiveLabels` for all of the labels present on the resource.
Labels pulumi.StringMapInput
// Name of the policy location. CMEK policies apply to the whole region.
Location pulumi.StringInput
// Name of the CMEK policy.
//
// ***
Name pulumi.StringPtrInput
// The ID of the project in which the resource belongs.
// If it is not provided, the provider project is used.
Project pulumi.StringPtrInput
}
func (KmsconfigArgs) ElementType() reflect.Type {
return reflect.TypeOf((*kmsconfigArgs)(nil)).Elem()
}
type KmsconfigInput interface {
pulumi.Input
ToKmsconfigOutput() KmsconfigOutput
ToKmsconfigOutputWithContext(ctx context.Context) KmsconfigOutput
}
func (*Kmsconfig) ElementType() reflect.Type {
return reflect.TypeOf((**Kmsconfig)(nil)).Elem()
}
func (i *Kmsconfig) ToKmsconfigOutput() KmsconfigOutput {
return i.ToKmsconfigOutputWithContext(context.Background())
}
func (i *Kmsconfig) ToKmsconfigOutputWithContext(ctx context.Context) KmsconfigOutput {
return pulumi.ToOutputWithContext(ctx, i).(KmsconfigOutput)
}
// KmsconfigArrayInput is an input type that accepts KmsconfigArray and KmsconfigArrayOutput values.
// You can construct a concrete instance of `KmsconfigArrayInput` via:
//
// KmsconfigArray{ KmsconfigArgs{...} }
type KmsconfigArrayInput interface {
pulumi.Input
ToKmsconfigArrayOutput() KmsconfigArrayOutput
ToKmsconfigArrayOutputWithContext(context.Context) KmsconfigArrayOutput
}
type KmsconfigArray []KmsconfigInput
func (KmsconfigArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Kmsconfig)(nil)).Elem()
}
func (i KmsconfigArray) ToKmsconfigArrayOutput() KmsconfigArrayOutput {
return i.ToKmsconfigArrayOutputWithContext(context.Background())
}
func (i KmsconfigArray) ToKmsconfigArrayOutputWithContext(ctx context.Context) KmsconfigArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(KmsconfigArrayOutput)
}
// KmsconfigMapInput is an input type that accepts KmsconfigMap and KmsconfigMapOutput values.
// You can construct a concrete instance of `KmsconfigMapInput` via:
//
// KmsconfigMap{ "key": KmsconfigArgs{...} }
type KmsconfigMapInput interface {
pulumi.Input
ToKmsconfigMapOutput() KmsconfigMapOutput
ToKmsconfigMapOutputWithContext(context.Context) KmsconfigMapOutput
}
type KmsconfigMap map[string]KmsconfigInput
func (KmsconfigMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Kmsconfig)(nil)).Elem()
}
func (i KmsconfigMap) ToKmsconfigMapOutput() KmsconfigMapOutput {
return i.ToKmsconfigMapOutputWithContext(context.Background())
}
func (i KmsconfigMap) ToKmsconfigMapOutputWithContext(ctx context.Context) KmsconfigMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(KmsconfigMapOutput)
}
type KmsconfigOutput struct{ *pulumi.OutputState }
func (KmsconfigOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Kmsconfig)(nil)).Elem()
}
func (o KmsconfigOutput) ToKmsconfigOutput() KmsconfigOutput {
return o
}
func (o KmsconfigOutput) ToKmsconfigOutputWithContext(ctx context.Context) KmsconfigOutput {
return o
}
// Resource name of the KMS key to use. Only regional keys are supported. Format: `projects/{{project}}/locations/{{location}}/keyRings/{{key_ring}}/cryptoKeys/{{key}}`.
func (o KmsconfigOutput) CryptoKeyName() pulumi.StringOutput {
return o.ApplyT(func(v *Kmsconfig) pulumi.StringOutput { return v.CryptoKeyName }).(pulumi.StringOutput)
}
// Description for the CMEK policy.
func (o KmsconfigOutput) Description() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Kmsconfig) pulumi.StringPtrOutput { return v.Description }).(pulumi.StringPtrOutput)
}
// All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
func (o KmsconfigOutput) EffectiveLabels() pulumi.StringMapOutput {
return o.ApplyT(func(v *Kmsconfig) pulumi.StringMapOutput { return v.EffectiveLabels }).(pulumi.StringMapOutput)
}
// Access to the key needs to be granted. The instructions contain gcloud commands to run to grant access.
// To make the policy work, a CMEK policy check is required, which verifies key access.
func (o KmsconfigOutput) Instructions() pulumi.StringOutput {
return o.ApplyT(func(v *Kmsconfig) pulumi.StringOutput { return v.Instructions }).(pulumi.StringOutput)
}
// Labels as key value pairs. Example: `{ "owner": "Bob", "department": "finance", "purpose": "testing" }`.
//
// **Note**: This field is non-authoritative, and will only manage the labels present in your configuration.
// Please refer to the field `effectiveLabels` for all of the labels present on the resource.
func (o KmsconfigOutput) Labels() pulumi.StringMapOutput {
return o.ApplyT(func(v *Kmsconfig) pulumi.StringMapOutput { return v.Labels }).(pulumi.StringMapOutput)
}
// Name of the policy location. CMEK policies apply to the whole region.
func (o KmsconfigOutput) Location() pulumi.StringOutput {
return o.ApplyT(func(v *Kmsconfig) pulumi.StringOutput { return v.Location }).(pulumi.StringOutput)
}
// Name of the CMEK policy.
//
// ***
func (o KmsconfigOutput) Name() pulumi.StringOutput {
return o.ApplyT(func(v *Kmsconfig) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
}
// The ID of the project in which the resource belongs.
// If it is not provided, the provider project is used.
func (o KmsconfigOutput) Project() pulumi.StringOutput {
return o.ApplyT(func(v *Kmsconfig) pulumi.StringOutput { return v.Project }).(pulumi.StringOutput)
}
// The combination of labels configured directly on the resource
// and default labels configured on the provider.
func (o KmsconfigOutput) PulumiLabels() pulumi.StringMapOutput {
return o.ApplyT(func(v *Kmsconfig) pulumi.StringMapOutput { return v.PulumiLabels }).(pulumi.StringMapOutput)
}
// The Service account which needs to have access to the provided KMS key.
func (o KmsconfigOutput) ServiceAccount() pulumi.StringOutput {
return o.ApplyT(func(v *Kmsconfig) pulumi.StringOutput { return v.ServiceAccount }).(pulumi.StringOutput)
}
type KmsconfigArrayOutput struct{ *pulumi.OutputState }
func (KmsconfigArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Kmsconfig)(nil)).Elem()
}
func (o KmsconfigArrayOutput) ToKmsconfigArrayOutput() KmsconfigArrayOutput {
return o
}
func (o KmsconfigArrayOutput) ToKmsconfigArrayOutputWithContext(ctx context.Context) KmsconfigArrayOutput {
return o
}
func (o KmsconfigArrayOutput) Index(i pulumi.IntInput) KmsconfigOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Kmsconfig {
return vs[0].([]*Kmsconfig)[vs[1].(int)]
}).(KmsconfigOutput)
}
type KmsconfigMapOutput struct{ *pulumi.OutputState }
func (KmsconfigMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Kmsconfig)(nil)).Elem()
}
func (o KmsconfigMapOutput) ToKmsconfigMapOutput() KmsconfigMapOutput {
return o
}
func (o KmsconfigMapOutput) ToKmsconfigMapOutputWithContext(ctx context.Context) KmsconfigMapOutput {
return o
}
func (o KmsconfigMapOutput) MapIndex(k pulumi.StringInput) KmsconfigOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Kmsconfig {
return vs[0].(map[string]*Kmsconfig)[vs[1].(string)]
}).(KmsconfigOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*KmsconfigInput)(nil)).Elem(), &Kmsconfig{})
pulumi.RegisterInputType(reflect.TypeOf((*KmsconfigArrayInput)(nil)).Elem(), KmsconfigArray{})
pulumi.RegisterInputType(reflect.TypeOf((*KmsconfigMapInput)(nil)).Elem(), KmsconfigMap{})
pulumi.RegisterOutputType(KmsconfigOutput{})
pulumi.RegisterOutputType(KmsconfigArrayOutput{})
pulumi.RegisterOutputType(KmsconfigMapOutput{})
}