/
key.go
383 lines (337 loc) · 20 KB
/
key.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
// *** 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 kms
import (
"context"
"reflect"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Manages a single-Region or multi-Region primary KMS key.
//
// ## Example Usage
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-aws/sdk/v4/go/aws/kms"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := kms.NewKey(ctx, "key", &kms.KeyArgs{
// DeletionWindowInDays: pulumi.Int(10),
// Description: pulumi.String("KMS key 1"),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// ## Import
//
// KMS Keys can be imported using the `id`, e.g.,
//
// ```sh
// $ pulumi import aws:kms/key:Key a 1234abcd-12ab-34cd-56ef-1234567890ab
// ```
type Key struct {
pulumi.CustomResourceState
// The Amazon Resource Name (ARN) of the key.
Arn pulumi.StringOutput `pulumi:"arn"`
// A flag to indicate whether to bypass the key policy lockout safety check.
// Setting this value to true increases the risk that the KMS key becomes unmanageable. Do not set this value to true indiscriminately.
// For more information, refer to the scenario in the [Default Key Policy](https://docs.aws.amazon.com/kms/latest/developerguide/key-policies.html#key-policy-default-allow-root-enable-iam) section in the _AWS Key Management Service Developer Guide_.
// The default value is `false`.
BypassPolicyLockoutSafetyCheck pulumi.BoolPtrOutput `pulumi:"bypassPolicyLockoutSafetyCheck"`
// Specifies whether the key contains a symmetric key or an asymmetric key pair and the encryption algorithms or signing algorithms that the key supports.
// Valid values: `SYMMETRIC_DEFAULT`, `RSA_2048`, `RSA_3072`, `RSA_4096`, `ECC_NIST_P256`, `ECC_NIST_P384`, `ECC_NIST_P521`, or `ECC_SECG_P256K1`. Defaults to `SYMMETRIC_DEFAULT`. For help with choosing a key spec, see the [AWS KMS Developer Guide](https://docs.aws.amazon.com/kms/latest/developerguide/symm-asymm-choose.html).
CustomerMasterKeySpec pulumi.StringPtrOutput `pulumi:"customerMasterKeySpec"`
// The waiting period, specified in number of days. After the waiting period ends, AWS KMS deletes the KMS key.
// If you specify a value, it must be between `7` and `30`, inclusive. If you do not specify a value, it defaults to `30`.
// If the KMS key is a multi-Region primary key with replicas, the waiting period begins when the last of its replica keys is deleted. Otherwise, the waiting period begins immediately.
DeletionWindowInDays pulumi.IntPtrOutput `pulumi:"deletionWindowInDays"`
// The description of the key as viewed in AWS console.
Description pulumi.StringOutput `pulumi:"description"`
// Specifies whether [key rotation](http://docs.aws.amazon.com/kms/latest/developerguide/rotate-keys.html) is enabled. Defaults to false.
EnableKeyRotation pulumi.BoolPtrOutput `pulumi:"enableKeyRotation"`
// Specifies whether the key is enabled. Defaults to `true`.
IsEnabled pulumi.BoolPtrOutput `pulumi:"isEnabled"`
// The globally unique identifier for the key.
KeyId pulumi.StringOutput `pulumi:"keyId"`
// Specifies the intended use of the key. Valid values: `ENCRYPT_DECRYPT` or `SIGN_VERIFY`.
// Defaults to `ENCRYPT_DECRYPT`.
KeyUsage pulumi.StringPtrOutput `pulumi:"keyUsage"`
// Indicates whether the KMS key is a multi-Region (`true`) or regional (`false`) key. Defaults to `false`.
MultiRegion pulumi.BoolOutput `pulumi:"multiRegion"`
// A valid policy JSON document. Although this is a key policy, not an IAM policy, an `iam.getPolicyDocument`, in the form that designates a principal, can be used.
Policy pulumi.StringOutput `pulumi:"policy"`
// A map of tags to assign to the object. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
Tags pulumi.StringMapOutput `pulumi:"tags"`
// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
TagsAll pulumi.StringMapOutput `pulumi:"tagsAll"`
}
// NewKey registers a new resource with the given unique name, arguments, and options.
func NewKey(ctx *pulumi.Context,
name string, args *KeyArgs, opts ...pulumi.ResourceOption) (*Key, error) {
if args == nil {
args = &KeyArgs{}
}
var resource Key
err := ctx.RegisterResource("aws:kms/key:Key", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetKey gets an existing Key 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 GetKey(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *KeyState, opts ...pulumi.ResourceOption) (*Key, error) {
var resource Key
err := ctx.ReadResource("aws:kms/key:Key", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering Key resources.
type keyState struct {
// The Amazon Resource Name (ARN) of the key.
Arn *string `pulumi:"arn"`
// A flag to indicate whether to bypass the key policy lockout safety check.
// Setting this value to true increases the risk that the KMS key becomes unmanageable. Do not set this value to true indiscriminately.
// For more information, refer to the scenario in the [Default Key Policy](https://docs.aws.amazon.com/kms/latest/developerguide/key-policies.html#key-policy-default-allow-root-enable-iam) section in the _AWS Key Management Service Developer Guide_.
// The default value is `false`.
BypassPolicyLockoutSafetyCheck *bool `pulumi:"bypassPolicyLockoutSafetyCheck"`
// Specifies whether the key contains a symmetric key or an asymmetric key pair and the encryption algorithms or signing algorithms that the key supports.
// Valid values: `SYMMETRIC_DEFAULT`, `RSA_2048`, `RSA_3072`, `RSA_4096`, `ECC_NIST_P256`, `ECC_NIST_P384`, `ECC_NIST_P521`, or `ECC_SECG_P256K1`. Defaults to `SYMMETRIC_DEFAULT`. For help with choosing a key spec, see the [AWS KMS Developer Guide](https://docs.aws.amazon.com/kms/latest/developerguide/symm-asymm-choose.html).
CustomerMasterKeySpec *string `pulumi:"customerMasterKeySpec"`
// The waiting period, specified in number of days. After the waiting period ends, AWS KMS deletes the KMS key.
// If you specify a value, it must be between `7` and `30`, inclusive. If you do not specify a value, it defaults to `30`.
// If the KMS key is a multi-Region primary key with replicas, the waiting period begins when the last of its replica keys is deleted. Otherwise, the waiting period begins immediately.
DeletionWindowInDays *int `pulumi:"deletionWindowInDays"`
// The description of the key as viewed in AWS console.
Description *string `pulumi:"description"`
// Specifies whether [key rotation](http://docs.aws.amazon.com/kms/latest/developerguide/rotate-keys.html) is enabled. Defaults to false.
EnableKeyRotation *bool `pulumi:"enableKeyRotation"`
// Specifies whether the key is enabled. Defaults to `true`.
IsEnabled *bool `pulumi:"isEnabled"`
// The globally unique identifier for the key.
KeyId *string `pulumi:"keyId"`
// Specifies the intended use of the key. Valid values: `ENCRYPT_DECRYPT` or `SIGN_VERIFY`.
// Defaults to `ENCRYPT_DECRYPT`.
KeyUsage *string `pulumi:"keyUsage"`
// Indicates whether the KMS key is a multi-Region (`true`) or regional (`false`) key. Defaults to `false`.
MultiRegion *bool `pulumi:"multiRegion"`
// A valid policy JSON document. Although this is a key policy, not an IAM policy, an `iam.getPolicyDocument`, in the form that designates a principal, can be used.
Policy *string `pulumi:"policy"`
// A map of tags to assign to the object. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
Tags map[string]string `pulumi:"tags"`
// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
TagsAll map[string]string `pulumi:"tagsAll"`
}
type KeyState struct {
// The Amazon Resource Name (ARN) of the key.
Arn pulumi.StringPtrInput
// A flag to indicate whether to bypass the key policy lockout safety check.
// Setting this value to true increases the risk that the KMS key becomes unmanageable. Do not set this value to true indiscriminately.
// For more information, refer to the scenario in the [Default Key Policy](https://docs.aws.amazon.com/kms/latest/developerguide/key-policies.html#key-policy-default-allow-root-enable-iam) section in the _AWS Key Management Service Developer Guide_.
// The default value is `false`.
BypassPolicyLockoutSafetyCheck pulumi.BoolPtrInput
// Specifies whether the key contains a symmetric key or an asymmetric key pair and the encryption algorithms or signing algorithms that the key supports.
// Valid values: `SYMMETRIC_DEFAULT`, `RSA_2048`, `RSA_3072`, `RSA_4096`, `ECC_NIST_P256`, `ECC_NIST_P384`, `ECC_NIST_P521`, or `ECC_SECG_P256K1`. Defaults to `SYMMETRIC_DEFAULT`. For help with choosing a key spec, see the [AWS KMS Developer Guide](https://docs.aws.amazon.com/kms/latest/developerguide/symm-asymm-choose.html).
CustomerMasterKeySpec pulumi.StringPtrInput
// The waiting period, specified in number of days. After the waiting period ends, AWS KMS deletes the KMS key.
// If you specify a value, it must be between `7` and `30`, inclusive. If you do not specify a value, it defaults to `30`.
// If the KMS key is a multi-Region primary key with replicas, the waiting period begins when the last of its replica keys is deleted. Otherwise, the waiting period begins immediately.
DeletionWindowInDays pulumi.IntPtrInput
// The description of the key as viewed in AWS console.
Description pulumi.StringPtrInput
// Specifies whether [key rotation](http://docs.aws.amazon.com/kms/latest/developerguide/rotate-keys.html) is enabled. Defaults to false.
EnableKeyRotation pulumi.BoolPtrInput
// Specifies whether the key is enabled. Defaults to `true`.
IsEnabled pulumi.BoolPtrInput
// The globally unique identifier for the key.
KeyId pulumi.StringPtrInput
// Specifies the intended use of the key. Valid values: `ENCRYPT_DECRYPT` or `SIGN_VERIFY`.
// Defaults to `ENCRYPT_DECRYPT`.
KeyUsage pulumi.StringPtrInput
// Indicates whether the KMS key is a multi-Region (`true`) or regional (`false`) key. Defaults to `false`.
MultiRegion pulumi.BoolPtrInput
// A valid policy JSON document. Although this is a key policy, not an IAM policy, an `iam.getPolicyDocument`, in the form that designates a principal, can be used.
Policy pulumi.StringPtrInput
// A map of tags to assign to the object. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
Tags pulumi.StringMapInput
// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
TagsAll pulumi.StringMapInput
}
func (KeyState) ElementType() reflect.Type {
return reflect.TypeOf((*keyState)(nil)).Elem()
}
type keyArgs struct {
// A flag to indicate whether to bypass the key policy lockout safety check.
// Setting this value to true increases the risk that the KMS key becomes unmanageable. Do not set this value to true indiscriminately.
// For more information, refer to the scenario in the [Default Key Policy](https://docs.aws.amazon.com/kms/latest/developerguide/key-policies.html#key-policy-default-allow-root-enable-iam) section in the _AWS Key Management Service Developer Guide_.
// The default value is `false`.
BypassPolicyLockoutSafetyCheck *bool `pulumi:"bypassPolicyLockoutSafetyCheck"`
// Specifies whether the key contains a symmetric key or an asymmetric key pair and the encryption algorithms or signing algorithms that the key supports.
// Valid values: `SYMMETRIC_DEFAULT`, `RSA_2048`, `RSA_3072`, `RSA_4096`, `ECC_NIST_P256`, `ECC_NIST_P384`, `ECC_NIST_P521`, or `ECC_SECG_P256K1`. Defaults to `SYMMETRIC_DEFAULT`. For help with choosing a key spec, see the [AWS KMS Developer Guide](https://docs.aws.amazon.com/kms/latest/developerguide/symm-asymm-choose.html).
CustomerMasterKeySpec *string `pulumi:"customerMasterKeySpec"`
// The waiting period, specified in number of days. After the waiting period ends, AWS KMS deletes the KMS key.
// If you specify a value, it must be between `7` and `30`, inclusive. If you do not specify a value, it defaults to `30`.
// If the KMS key is a multi-Region primary key with replicas, the waiting period begins when the last of its replica keys is deleted. Otherwise, the waiting period begins immediately.
DeletionWindowInDays *int `pulumi:"deletionWindowInDays"`
// The description of the key as viewed in AWS console.
Description *string `pulumi:"description"`
// Specifies whether [key rotation](http://docs.aws.amazon.com/kms/latest/developerguide/rotate-keys.html) is enabled. Defaults to false.
EnableKeyRotation *bool `pulumi:"enableKeyRotation"`
// Specifies whether the key is enabled. Defaults to `true`.
IsEnabled *bool `pulumi:"isEnabled"`
// Specifies the intended use of the key. Valid values: `ENCRYPT_DECRYPT` or `SIGN_VERIFY`.
// Defaults to `ENCRYPT_DECRYPT`.
KeyUsage *string `pulumi:"keyUsage"`
// Indicates whether the KMS key is a multi-Region (`true`) or regional (`false`) key. Defaults to `false`.
MultiRegion *bool `pulumi:"multiRegion"`
// A valid policy JSON document. Although this is a key policy, not an IAM policy, an `iam.getPolicyDocument`, in the form that designates a principal, can be used.
Policy *string `pulumi:"policy"`
// A map of tags to assign to the object. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
Tags map[string]string `pulumi:"tags"`
}
// The set of arguments for constructing a Key resource.
type KeyArgs struct {
// A flag to indicate whether to bypass the key policy lockout safety check.
// Setting this value to true increases the risk that the KMS key becomes unmanageable. Do not set this value to true indiscriminately.
// For more information, refer to the scenario in the [Default Key Policy](https://docs.aws.amazon.com/kms/latest/developerguide/key-policies.html#key-policy-default-allow-root-enable-iam) section in the _AWS Key Management Service Developer Guide_.
// The default value is `false`.
BypassPolicyLockoutSafetyCheck pulumi.BoolPtrInput
// Specifies whether the key contains a symmetric key or an asymmetric key pair and the encryption algorithms or signing algorithms that the key supports.
// Valid values: `SYMMETRIC_DEFAULT`, `RSA_2048`, `RSA_3072`, `RSA_4096`, `ECC_NIST_P256`, `ECC_NIST_P384`, `ECC_NIST_P521`, or `ECC_SECG_P256K1`. Defaults to `SYMMETRIC_DEFAULT`. For help with choosing a key spec, see the [AWS KMS Developer Guide](https://docs.aws.amazon.com/kms/latest/developerguide/symm-asymm-choose.html).
CustomerMasterKeySpec pulumi.StringPtrInput
// The waiting period, specified in number of days. After the waiting period ends, AWS KMS deletes the KMS key.
// If you specify a value, it must be between `7` and `30`, inclusive. If you do not specify a value, it defaults to `30`.
// If the KMS key is a multi-Region primary key with replicas, the waiting period begins when the last of its replica keys is deleted. Otherwise, the waiting period begins immediately.
DeletionWindowInDays pulumi.IntPtrInput
// The description of the key as viewed in AWS console.
Description pulumi.StringPtrInput
// Specifies whether [key rotation](http://docs.aws.amazon.com/kms/latest/developerguide/rotate-keys.html) is enabled. Defaults to false.
EnableKeyRotation pulumi.BoolPtrInput
// Specifies whether the key is enabled. Defaults to `true`.
IsEnabled pulumi.BoolPtrInput
// Specifies the intended use of the key. Valid values: `ENCRYPT_DECRYPT` or `SIGN_VERIFY`.
// Defaults to `ENCRYPT_DECRYPT`.
KeyUsage pulumi.StringPtrInput
// Indicates whether the KMS key is a multi-Region (`true`) or regional (`false`) key. Defaults to `false`.
MultiRegion pulumi.BoolPtrInput
// A valid policy JSON document. Although this is a key policy, not an IAM policy, an `iam.getPolicyDocument`, in the form that designates a principal, can be used.
Policy pulumi.StringPtrInput
// A map of tags to assign to the object. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
Tags pulumi.StringMapInput
}
func (KeyArgs) ElementType() reflect.Type {
return reflect.TypeOf((*keyArgs)(nil)).Elem()
}
type KeyInput interface {
pulumi.Input
ToKeyOutput() KeyOutput
ToKeyOutputWithContext(ctx context.Context) KeyOutput
}
func (*Key) ElementType() reflect.Type {
return reflect.TypeOf((**Key)(nil)).Elem()
}
func (i *Key) ToKeyOutput() KeyOutput {
return i.ToKeyOutputWithContext(context.Background())
}
func (i *Key) ToKeyOutputWithContext(ctx context.Context) KeyOutput {
return pulumi.ToOutputWithContext(ctx, i).(KeyOutput)
}
// KeyArrayInput is an input type that accepts KeyArray and KeyArrayOutput values.
// You can construct a concrete instance of `KeyArrayInput` via:
//
// KeyArray{ KeyArgs{...} }
type KeyArrayInput interface {
pulumi.Input
ToKeyArrayOutput() KeyArrayOutput
ToKeyArrayOutputWithContext(context.Context) KeyArrayOutput
}
type KeyArray []KeyInput
func (KeyArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Key)(nil)).Elem()
}
func (i KeyArray) ToKeyArrayOutput() KeyArrayOutput {
return i.ToKeyArrayOutputWithContext(context.Background())
}
func (i KeyArray) ToKeyArrayOutputWithContext(ctx context.Context) KeyArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(KeyArrayOutput)
}
// KeyMapInput is an input type that accepts KeyMap and KeyMapOutput values.
// You can construct a concrete instance of `KeyMapInput` via:
//
// KeyMap{ "key": KeyArgs{...} }
type KeyMapInput interface {
pulumi.Input
ToKeyMapOutput() KeyMapOutput
ToKeyMapOutputWithContext(context.Context) KeyMapOutput
}
type KeyMap map[string]KeyInput
func (KeyMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Key)(nil)).Elem()
}
func (i KeyMap) ToKeyMapOutput() KeyMapOutput {
return i.ToKeyMapOutputWithContext(context.Background())
}
func (i KeyMap) ToKeyMapOutputWithContext(ctx context.Context) KeyMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(KeyMapOutput)
}
type KeyOutput struct{ *pulumi.OutputState }
func (KeyOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Key)(nil)).Elem()
}
func (o KeyOutput) ToKeyOutput() KeyOutput {
return o
}
func (o KeyOutput) ToKeyOutputWithContext(ctx context.Context) KeyOutput {
return o
}
type KeyArrayOutput struct{ *pulumi.OutputState }
func (KeyArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Key)(nil)).Elem()
}
func (o KeyArrayOutput) ToKeyArrayOutput() KeyArrayOutput {
return o
}
func (o KeyArrayOutput) ToKeyArrayOutputWithContext(ctx context.Context) KeyArrayOutput {
return o
}
func (o KeyArrayOutput) Index(i pulumi.IntInput) KeyOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Key {
return vs[0].([]*Key)[vs[1].(int)]
}).(KeyOutput)
}
type KeyMapOutput struct{ *pulumi.OutputState }
func (KeyMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Key)(nil)).Elem()
}
func (o KeyMapOutput) ToKeyMapOutput() KeyMapOutput {
return o
}
func (o KeyMapOutput) ToKeyMapOutputWithContext(ctx context.Context) KeyMapOutput {
return o
}
func (o KeyMapOutput) MapIndex(k pulumi.StringInput) KeyOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Key {
return vs[0].(map[string]*Key)[vs[1].(string)]
}).(KeyOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*KeyInput)(nil)).Elem(), &Key{})
pulumi.RegisterInputType(reflect.TypeOf((*KeyArrayInput)(nil)).Elem(), KeyArray{})
pulumi.RegisterInputType(reflect.TypeOf((*KeyMapInput)(nil)).Elem(), KeyMap{})
pulumi.RegisterOutputType(KeyOutput{})
pulumi.RegisterOutputType(KeyArrayOutput{})
pulumi.RegisterOutputType(KeyMapOutput{})
}