/
vaultLock.go
372 lines (312 loc) · 15.8 KB
/
vaultLock.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
// *** 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 glacier
import (
"context"
"reflect"
"github.com/pkg/errors"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
// Manages a Glacier Vault Lock. You can refer to the [Glacier Developer Guide](https://docs.aws.amazon.com/amazonglacier/latest/dev/vault-lock.html) for a full explanation of the Glacier Vault Lock functionality.
//
// > **NOTE:** This resource allows you to test Glacier Vault Lock policies by setting the `completeLock` argument to `false`. When testing policies in this manner, the Glacier Vault Lock automatically expires after 24 hours and this provider will show this resource as needing recreation after that time. To permanently apply the policy, set the `completeLock` argument to `true`. When changing `completeLock` to `true`, it is expected the resource will show as recreating.
//
// !> **WARNING:** Once a Glacier Vault Lock is completed, it is immutable. The deletion of the Glacier Vault Lock is not be possible and attempting to remove it from this provider will return an error. Set the `ignoreDeletionError` argument to `true` and apply this configuration before attempting to delete this resource via this provider or remove this resource from this provider's management.
//
// ## Example Usage
// ### Testing Glacier Vault Lock Policy
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-aws/sdk/v3/go/aws/glacier"
// "github.com/pulumi/pulumi-aws/sdk/v3/go/aws/iam"
// "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// exampleVault, err := glacier.NewVault(ctx, "exampleVault", nil)
// if err != nil {
// return err
// }
// _, err = glacier.NewVaultLock(ctx, "exampleVaultLock", &glacier.VaultLockArgs{
// CompleteLock: pulumi.Bool(false),
// Policy: examplePolicyDocument.ApplyT(func(examplePolicyDocument iam.GetPolicyDocumentResult) (string, error) {
// return examplePolicyDocument.Json, nil
// }).(pulumi.StringOutput),
// VaultName: exampleVault.Name,
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
// ### Permanently Applying Glacier Vault Lock Policy
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-aws/sdk/v3/go/aws/glacier"
// "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := glacier.NewVaultLock(ctx, "example", &glacier.VaultLockArgs{
// CompleteLock: pulumi.Bool(true),
// Policy: pulumi.Any(data.Aws_iam_policy_document.Example.Json),
// VaultName: pulumi.Any(aws_glacier_vault.Example.Name),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// ## Import
//
// Glacier Vault Locks can be imported using the Glacier Vault name, e.g.
//
// ```sh
// $ pulumi import aws:glacier/vaultLock:VaultLock example example-vault
// ```
type VaultLock struct {
pulumi.CustomResourceState
// Boolean whether to permanently apply this Glacier Lock Policy. Once completed, this cannot be undone. If set to `false`, the Glacier Lock Policy remains in a testing mode for 24 hours. After that time, the Glacier Lock Policy is automatically removed by Glacier and the this provider resource will show as needing recreation. Changing this from `false` to `true` will show as resource recreation, which is expected. Changing this from `true` to `false` is not possible unless the Glacier Vault is recreated at the same time.
CompleteLock pulumi.BoolOutput `pulumi:"completeLock"`
// Allow this provider to ignore the error returned when attempting to delete the Glacier Lock Policy. This can be used to delete or recreate the Glacier Vault via this provider, for example, if the Glacier Vault Lock policy permits that action. This should only be used in conjunction with `completeLock` being set to `true`.
IgnoreDeletionError pulumi.BoolPtrOutput `pulumi:"ignoreDeletionError"`
// JSON string containing the IAM policy to apply as the Glacier Vault Lock policy.
Policy pulumi.StringOutput `pulumi:"policy"`
// The name of the Glacier Vault.
VaultName pulumi.StringOutput `pulumi:"vaultName"`
}
// NewVaultLock registers a new resource with the given unique name, arguments, and options.
func NewVaultLock(ctx *pulumi.Context,
name string, args *VaultLockArgs, opts ...pulumi.ResourceOption) (*VaultLock, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.CompleteLock == nil {
return nil, errors.New("invalid value for required argument 'CompleteLock'")
}
if args.Policy == nil {
return nil, errors.New("invalid value for required argument 'Policy'")
}
if args.VaultName == nil {
return nil, errors.New("invalid value for required argument 'VaultName'")
}
var resource VaultLock
err := ctx.RegisterResource("aws:glacier/vaultLock:VaultLock", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetVaultLock gets an existing VaultLock 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 GetVaultLock(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *VaultLockState, opts ...pulumi.ResourceOption) (*VaultLock, error) {
var resource VaultLock
err := ctx.ReadResource("aws:glacier/vaultLock:VaultLock", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering VaultLock resources.
type vaultLockState struct {
// Boolean whether to permanently apply this Glacier Lock Policy. Once completed, this cannot be undone. If set to `false`, the Glacier Lock Policy remains in a testing mode for 24 hours. After that time, the Glacier Lock Policy is automatically removed by Glacier and the this provider resource will show as needing recreation. Changing this from `false` to `true` will show as resource recreation, which is expected. Changing this from `true` to `false` is not possible unless the Glacier Vault is recreated at the same time.
CompleteLock *bool `pulumi:"completeLock"`
// Allow this provider to ignore the error returned when attempting to delete the Glacier Lock Policy. This can be used to delete or recreate the Glacier Vault via this provider, for example, if the Glacier Vault Lock policy permits that action. This should only be used in conjunction with `completeLock` being set to `true`.
IgnoreDeletionError *bool `pulumi:"ignoreDeletionError"`
// JSON string containing the IAM policy to apply as the Glacier Vault Lock policy.
Policy *string `pulumi:"policy"`
// The name of the Glacier Vault.
VaultName *string `pulumi:"vaultName"`
}
type VaultLockState struct {
// Boolean whether to permanently apply this Glacier Lock Policy. Once completed, this cannot be undone. If set to `false`, the Glacier Lock Policy remains in a testing mode for 24 hours. After that time, the Glacier Lock Policy is automatically removed by Glacier and the this provider resource will show as needing recreation. Changing this from `false` to `true` will show as resource recreation, which is expected. Changing this from `true` to `false` is not possible unless the Glacier Vault is recreated at the same time.
CompleteLock pulumi.BoolPtrInput
// Allow this provider to ignore the error returned when attempting to delete the Glacier Lock Policy. This can be used to delete or recreate the Glacier Vault via this provider, for example, if the Glacier Vault Lock policy permits that action. This should only be used in conjunction with `completeLock` being set to `true`.
IgnoreDeletionError pulumi.BoolPtrInput
// JSON string containing the IAM policy to apply as the Glacier Vault Lock policy.
Policy pulumi.StringPtrInput
// The name of the Glacier Vault.
VaultName pulumi.StringPtrInput
}
func (VaultLockState) ElementType() reflect.Type {
return reflect.TypeOf((*vaultLockState)(nil)).Elem()
}
type vaultLockArgs struct {
// Boolean whether to permanently apply this Glacier Lock Policy. Once completed, this cannot be undone. If set to `false`, the Glacier Lock Policy remains in a testing mode for 24 hours. After that time, the Glacier Lock Policy is automatically removed by Glacier and the this provider resource will show as needing recreation. Changing this from `false` to `true` will show as resource recreation, which is expected. Changing this from `true` to `false` is not possible unless the Glacier Vault is recreated at the same time.
CompleteLock bool `pulumi:"completeLock"`
// Allow this provider to ignore the error returned when attempting to delete the Glacier Lock Policy. This can be used to delete or recreate the Glacier Vault via this provider, for example, if the Glacier Vault Lock policy permits that action. This should only be used in conjunction with `completeLock` being set to `true`.
IgnoreDeletionError *bool `pulumi:"ignoreDeletionError"`
// JSON string containing the IAM policy to apply as the Glacier Vault Lock policy.
Policy string `pulumi:"policy"`
// The name of the Glacier Vault.
VaultName string `pulumi:"vaultName"`
}
// The set of arguments for constructing a VaultLock resource.
type VaultLockArgs struct {
// Boolean whether to permanently apply this Glacier Lock Policy. Once completed, this cannot be undone. If set to `false`, the Glacier Lock Policy remains in a testing mode for 24 hours. After that time, the Glacier Lock Policy is automatically removed by Glacier and the this provider resource will show as needing recreation. Changing this from `false` to `true` will show as resource recreation, which is expected. Changing this from `true` to `false` is not possible unless the Glacier Vault is recreated at the same time.
CompleteLock pulumi.BoolInput
// Allow this provider to ignore the error returned when attempting to delete the Glacier Lock Policy. This can be used to delete or recreate the Glacier Vault via this provider, for example, if the Glacier Vault Lock policy permits that action. This should only be used in conjunction with `completeLock` being set to `true`.
IgnoreDeletionError pulumi.BoolPtrInput
// JSON string containing the IAM policy to apply as the Glacier Vault Lock policy.
Policy pulumi.StringInput
// The name of the Glacier Vault.
VaultName pulumi.StringInput
}
func (VaultLockArgs) ElementType() reflect.Type {
return reflect.TypeOf((*vaultLockArgs)(nil)).Elem()
}
type VaultLockInput interface {
pulumi.Input
ToVaultLockOutput() VaultLockOutput
ToVaultLockOutputWithContext(ctx context.Context) VaultLockOutput
}
func (*VaultLock) ElementType() reflect.Type {
return reflect.TypeOf((*VaultLock)(nil))
}
func (i *VaultLock) ToVaultLockOutput() VaultLockOutput {
return i.ToVaultLockOutputWithContext(context.Background())
}
func (i *VaultLock) ToVaultLockOutputWithContext(ctx context.Context) VaultLockOutput {
return pulumi.ToOutputWithContext(ctx, i).(VaultLockOutput)
}
func (i *VaultLock) ToVaultLockPtrOutput() VaultLockPtrOutput {
return i.ToVaultLockPtrOutputWithContext(context.Background())
}
func (i *VaultLock) ToVaultLockPtrOutputWithContext(ctx context.Context) VaultLockPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(VaultLockPtrOutput)
}
type VaultLockPtrInput interface {
pulumi.Input
ToVaultLockPtrOutput() VaultLockPtrOutput
ToVaultLockPtrOutputWithContext(ctx context.Context) VaultLockPtrOutput
}
type vaultLockPtrType VaultLockArgs
func (*vaultLockPtrType) ElementType() reflect.Type {
return reflect.TypeOf((**VaultLock)(nil))
}
func (i *vaultLockPtrType) ToVaultLockPtrOutput() VaultLockPtrOutput {
return i.ToVaultLockPtrOutputWithContext(context.Background())
}
func (i *vaultLockPtrType) ToVaultLockPtrOutputWithContext(ctx context.Context) VaultLockPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(VaultLockPtrOutput)
}
// VaultLockArrayInput is an input type that accepts VaultLockArray and VaultLockArrayOutput values.
// You can construct a concrete instance of `VaultLockArrayInput` via:
//
// VaultLockArray{ VaultLockArgs{...} }
type VaultLockArrayInput interface {
pulumi.Input
ToVaultLockArrayOutput() VaultLockArrayOutput
ToVaultLockArrayOutputWithContext(context.Context) VaultLockArrayOutput
}
type VaultLockArray []VaultLockInput
func (VaultLockArray) ElementType() reflect.Type {
return reflect.TypeOf(([]*VaultLock)(nil))
}
func (i VaultLockArray) ToVaultLockArrayOutput() VaultLockArrayOutput {
return i.ToVaultLockArrayOutputWithContext(context.Background())
}
func (i VaultLockArray) ToVaultLockArrayOutputWithContext(ctx context.Context) VaultLockArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(VaultLockArrayOutput)
}
// VaultLockMapInput is an input type that accepts VaultLockMap and VaultLockMapOutput values.
// You can construct a concrete instance of `VaultLockMapInput` via:
//
// VaultLockMap{ "key": VaultLockArgs{...} }
type VaultLockMapInput interface {
pulumi.Input
ToVaultLockMapOutput() VaultLockMapOutput
ToVaultLockMapOutputWithContext(context.Context) VaultLockMapOutput
}
type VaultLockMap map[string]VaultLockInput
func (VaultLockMap) ElementType() reflect.Type {
return reflect.TypeOf((map[string]*VaultLock)(nil))
}
func (i VaultLockMap) ToVaultLockMapOutput() VaultLockMapOutput {
return i.ToVaultLockMapOutputWithContext(context.Background())
}
func (i VaultLockMap) ToVaultLockMapOutputWithContext(ctx context.Context) VaultLockMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(VaultLockMapOutput)
}
type VaultLockOutput struct {
*pulumi.OutputState
}
func (VaultLockOutput) ElementType() reflect.Type {
return reflect.TypeOf((*VaultLock)(nil))
}
func (o VaultLockOutput) ToVaultLockOutput() VaultLockOutput {
return o
}
func (o VaultLockOutput) ToVaultLockOutputWithContext(ctx context.Context) VaultLockOutput {
return o
}
func (o VaultLockOutput) ToVaultLockPtrOutput() VaultLockPtrOutput {
return o.ToVaultLockPtrOutputWithContext(context.Background())
}
func (o VaultLockOutput) ToVaultLockPtrOutputWithContext(ctx context.Context) VaultLockPtrOutput {
return o.ApplyT(func(v VaultLock) *VaultLock {
return &v
}).(VaultLockPtrOutput)
}
type VaultLockPtrOutput struct {
*pulumi.OutputState
}
func (VaultLockPtrOutput) ElementType() reflect.Type {
return reflect.TypeOf((**VaultLock)(nil))
}
func (o VaultLockPtrOutput) ToVaultLockPtrOutput() VaultLockPtrOutput {
return o
}
func (o VaultLockPtrOutput) ToVaultLockPtrOutputWithContext(ctx context.Context) VaultLockPtrOutput {
return o
}
type VaultLockArrayOutput struct{ *pulumi.OutputState }
func (VaultLockArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]VaultLock)(nil))
}
func (o VaultLockArrayOutput) ToVaultLockArrayOutput() VaultLockArrayOutput {
return o
}
func (o VaultLockArrayOutput) ToVaultLockArrayOutputWithContext(ctx context.Context) VaultLockArrayOutput {
return o
}
func (o VaultLockArrayOutput) Index(i pulumi.IntInput) VaultLockOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) VaultLock {
return vs[0].([]VaultLock)[vs[1].(int)]
}).(VaultLockOutput)
}
type VaultLockMapOutput struct{ *pulumi.OutputState }
func (VaultLockMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]VaultLock)(nil))
}
func (o VaultLockMapOutput) ToVaultLockMapOutput() VaultLockMapOutput {
return o
}
func (o VaultLockMapOutput) ToVaultLockMapOutputWithContext(ctx context.Context) VaultLockMapOutput {
return o
}
func (o VaultLockMapOutput) MapIndex(k pulumi.StringInput) VaultLockOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) VaultLock {
return vs[0].(map[string]VaultLock)[vs[1].(string)]
}).(VaultLockOutput)
}
func init() {
pulumi.RegisterOutputType(VaultLockOutput{})
pulumi.RegisterOutputType(VaultLockPtrOutput{})
pulumi.RegisterOutputType(VaultLockArrayOutput{})
pulumi.RegisterOutputType(VaultLockMapOutput{})
}