/
bucketObjectLockConfigurationV2.go
369 lines (318 loc) · 18 KB
/
bucketObjectLockConfigurationV2.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
// 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 s3
import (
"context"
"reflect"
"errors"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Provides an S3 bucket Object Lock configuration resource. For more information about Object Locking, go to [Using S3 Object Lock](https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lock.html) in the Amazon S3 User Guide.
//
// > This resource can be used enable Object Lock for **new** and **existing** buckets.
//
// > This resource cannot be used with S3 directory buckets.
//
// ## Example Usage
//
// ### Object Lock configuration for new or existing buckets
//
// <!--Start PulumiCodeChooser -->
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/s3"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// example, err := s3.NewBucketV2(ctx, "example", &s3.BucketV2Args{
// Bucket: pulumi.String("mybucket"),
// })
// if err != nil {
// return err
// }
// _, err = s3.NewBucketVersioningV2(ctx, "example", &s3.BucketVersioningV2Args{
// Bucket: example.ID(),
// VersioningConfiguration: &s3.BucketVersioningV2VersioningConfigurationArgs{
// Status: pulumi.String("Enabled"),
// },
// })
// if err != nil {
// return err
// }
// _, err = s3.NewBucketObjectLockConfigurationV2(ctx, "example", &s3.BucketObjectLockConfigurationV2Args{
// Bucket: example.ID(),
// Rule: &s3.BucketObjectLockConfigurationV2RuleArgs{
// DefaultRetention: &s3.BucketObjectLockConfigurationV2RuleDefaultRetentionArgs{
// Mode: pulumi.String("COMPLIANCE"),
// Days: pulumi.Int(5),
// },
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
// <!--End PulumiCodeChooser -->
//
// ## Import
//
// If the owner (account ID) of the source bucket differs from the account used to configure the AWS Provider, import using the `bucket` and `expected_bucket_owner` separated by a comma (`,`):
//
// import {
// to = aws_s3_bucket_object_lock_configuration.example
// id = "bucket-name,123456789012"
// }
//
// __Using `pulumi import` to import__ S3 bucket Object Lock configuration using the `bucket` or using the `bucket` and `expected_bucket_owner` separated by a comma (`,`). For example:
//
// If the owner (account ID) of the source bucket is the same account used to configure the AWS Provider, import using the `bucket`:
//
// ```sh
// $ pulumi import aws:s3/bucketObjectLockConfigurationV2:BucketObjectLockConfigurationV2 example bucket-name
// ```
// If the owner (account ID) of the source bucket differs from the account used to configure the AWS Provider, import using the `bucket` and `expected_bucket_owner` separated by a comma (`,`):
//
// ```sh
// $ pulumi import aws:s3/bucketObjectLockConfigurationV2:BucketObjectLockConfigurationV2 example bucket-name,123456789012
// ```
type BucketObjectLockConfigurationV2 struct {
pulumi.CustomResourceState
// Name of the bucket.
Bucket pulumi.StringOutput `pulumi:"bucket"`
// Account ID of the expected bucket owner.
ExpectedBucketOwner pulumi.StringPtrOutput `pulumi:"expectedBucketOwner"`
// Indicates whether this bucket has an Object Lock configuration enabled. Defaults to `Enabled`. Valid values: `Enabled`.
ObjectLockEnabled pulumi.StringPtrOutput `pulumi:"objectLockEnabled"`
// Configuration block for specifying the Object Lock rule for the specified object. See below.
Rule BucketObjectLockConfigurationV2RulePtrOutput `pulumi:"rule"`
// Token to allow Object Lock to be enabled for an existing bucket. You must contact AWS support for the bucket's "Object Lock token".
// The token is generated in the back-end when [versioning](https://docs.aws.amazon.com/AmazonS3/latest/userguide/manage-versioning-examples.html) is enabled on a bucket. For more details on versioning, see the `s3.BucketVersioningV2` resource.
Token pulumi.StringPtrOutput `pulumi:"token"`
}
// NewBucketObjectLockConfigurationV2 registers a new resource with the given unique name, arguments, and options.
func NewBucketObjectLockConfigurationV2(ctx *pulumi.Context,
name string, args *BucketObjectLockConfigurationV2Args, opts ...pulumi.ResourceOption) (*BucketObjectLockConfigurationV2, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.Bucket == nil {
return nil, errors.New("invalid value for required argument 'Bucket'")
}
if args.Token != nil {
args.Token = pulumi.ToSecret(args.Token).(pulumi.StringPtrInput)
}
secrets := pulumi.AdditionalSecretOutputs([]string{
"token",
})
opts = append(opts, secrets)
opts = internal.PkgResourceDefaultOpts(opts)
var resource BucketObjectLockConfigurationV2
err := ctx.RegisterResource("aws:s3/bucketObjectLockConfigurationV2:BucketObjectLockConfigurationV2", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetBucketObjectLockConfigurationV2 gets an existing BucketObjectLockConfigurationV2 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 GetBucketObjectLockConfigurationV2(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *BucketObjectLockConfigurationV2State, opts ...pulumi.ResourceOption) (*BucketObjectLockConfigurationV2, error) {
var resource BucketObjectLockConfigurationV2
err := ctx.ReadResource("aws:s3/bucketObjectLockConfigurationV2:BucketObjectLockConfigurationV2", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering BucketObjectLockConfigurationV2 resources.
type bucketObjectLockConfigurationV2State struct {
// Name of the bucket.
Bucket *string `pulumi:"bucket"`
// Account ID of the expected bucket owner.
ExpectedBucketOwner *string `pulumi:"expectedBucketOwner"`
// Indicates whether this bucket has an Object Lock configuration enabled. Defaults to `Enabled`. Valid values: `Enabled`.
ObjectLockEnabled *string `pulumi:"objectLockEnabled"`
// Configuration block for specifying the Object Lock rule for the specified object. See below.
Rule *BucketObjectLockConfigurationV2Rule `pulumi:"rule"`
// Token to allow Object Lock to be enabled for an existing bucket. You must contact AWS support for the bucket's "Object Lock token".
// The token is generated in the back-end when [versioning](https://docs.aws.amazon.com/AmazonS3/latest/userguide/manage-versioning-examples.html) is enabled on a bucket. For more details on versioning, see the `s3.BucketVersioningV2` resource.
Token *string `pulumi:"token"`
}
type BucketObjectLockConfigurationV2State struct {
// Name of the bucket.
Bucket pulumi.StringPtrInput
// Account ID of the expected bucket owner.
ExpectedBucketOwner pulumi.StringPtrInput
// Indicates whether this bucket has an Object Lock configuration enabled. Defaults to `Enabled`. Valid values: `Enabled`.
ObjectLockEnabled pulumi.StringPtrInput
// Configuration block for specifying the Object Lock rule for the specified object. See below.
Rule BucketObjectLockConfigurationV2RulePtrInput
// Token to allow Object Lock to be enabled for an existing bucket. You must contact AWS support for the bucket's "Object Lock token".
// The token is generated in the back-end when [versioning](https://docs.aws.amazon.com/AmazonS3/latest/userguide/manage-versioning-examples.html) is enabled on a bucket. For more details on versioning, see the `s3.BucketVersioningV2` resource.
Token pulumi.StringPtrInput
}
func (BucketObjectLockConfigurationV2State) ElementType() reflect.Type {
return reflect.TypeOf((*bucketObjectLockConfigurationV2State)(nil)).Elem()
}
type bucketObjectLockConfigurationV2Args struct {
// Name of the bucket.
Bucket string `pulumi:"bucket"`
// Account ID of the expected bucket owner.
ExpectedBucketOwner *string `pulumi:"expectedBucketOwner"`
// Indicates whether this bucket has an Object Lock configuration enabled. Defaults to `Enabled`. Valid values: `Enabled`.
ObjectLockEnabled *string `pulumi:"objectLockEnabled"`
// Configuration block for specifying the Object Lock rule for the specified object. See below.
Rule *BucketObjectLockConfigurationV2Rule `pulumi:"rule"`
// Token to allow Object Lock to be enabled for an existing bucket. You must contact AWS support for the bucket's "Object Lock token".
// The token is generated in the back-end when [versioning](https://docs.aws.amazon.com/AmazonS3/latest/userguide/manage-versioning-examples.html) is enabled on a bucket. For more details on versioning, see the `s3.BucketVersioningV2` resource.
Token *string `pulumi:"token"`
}
// The set of arguments for constructing a BucketObjectLockConfigurationV2 resource.
type BucketObjectLockConfigurationV2Args struct {
// Name of the bucket.
Bucket pulumi.StringInput
// Account ID of the expected bucket owner.
ExpectedBucketOwner pulumi.StringPtrInput
// Indicates whether this bucket has an Object Lock configuration enabled. Defaults to `Enabled`. Valid values: `Enabled`.
ObjectLockEnabled pulumi.StringPtrInput
// Configuration block for specifying the Object Lock rule for the specified object. See below.
Rule BucketObjectLockConfigurationV2RulePtrInput
// Token to allow Object Lock to be enabled for an existing bucket. You must contact AWS support for the bucket's "Object Lock token".
// The token is generated in the back-end when [versioning](https://docs.aws.amazon.com/AmazonS3/latest/userguide/manage-versioning-examples.html) is enabled on a bucket. For more details on versioning, see the `s3.BucketVersioningV2` resource.
Token pulumi.StringPtrInput
}
func (BucketObjectLockConfigurationV2Args) ElementType() reflect.Type {
return reflect.TypeOf((*bucketObjectLockConfigurationV2Args)(nil)).Elem()
}
type BucketObjectLockConfigurationV2Input interface {
pulumi.Input
ToBucketObjectLockConfigurationV2Output() BucketObjectLockConfigurationV2Output
ToBucketObjectLockConfigurationV2OutputWithContext(ctx context.Context) BucketObjectLockConfigurationV2Output
}
func (*BucketObjectLockConfigurationV2) ElementType() reflect.Type {
return reflect.TypeOf((**BucketObjectLockConfigurationV2)(nil)).Elem()
}
func (i *BucketObjectLockConfigurationV2) ToBucketObjectLockConfigurationV2Output() BucketObjectLockConfigurationV2Output {
return i.ToBucketObjectLockConfigurationV2OutputWithContext(context.Background())
}
func (i *BucketObjectLockConfigurationV2) ToBucketObjectLockConfigurationV2OutputWithContext(ctx context.Context) BucketObjectLockConfigurationV2Output {
return pulumi.ToOutputWithContext(ctx, i).(BucketObjectLockConfigurationV2Output)
}
// BucketObjectLockConfigurationV2ArrayInput is an input type that accepts BucketObjectLockConfigurationV2Array and BucketObjectLockConfigurationV2ArrayOutput values.
// You can construct a concrete instance of `BucketObjectLockConfigurationV2ArrayInput` via:
//
// BucketObjectLockConfigurationV2Array{ BucketObjectLockConfigurationV2Args{...} }
type BucketObjectLockConfigurationV2ArrayInput interface {
pulumi.Input
ToBucketObjectLockConfigurationV2ArrayOutput() BucketObjectLockConfigurationV2ArrayOutput
ToBucketObjectLockConfigurationV2ArrayOutputWithContext(context.Context) BucketObjectLockConfigurationV2ArrayOutput
}
type BucketObjectLockConfigurationV2Array []BucketObjectLockConfigurationV2Input
func (BucketObjectLockConfigurationV2Array) ElementType() reflect.Type {
return reflect.TypeOf((*[]*BucketObjectLockConfigurationV2)(nil)).Elem()
}
func (i BucketObjectLockConfigurationV2Array) ToBucketObjectLockConfigurationV2ArrayOutput() BucketObjectLockConfigurationV2ArrayOutput {
return i.ToBucketObjectLockConfigurationV2ArrayOutputWithContext(context.Background())
}
func (i BucketObjectLockConfigurationV2Array) ToBucketObjectLockConfigurationV2ArrayOutputWithContext(ctx context.Context) BucketObjectLockConfigurationV2ArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(BucketObjectLockConfigurationV2ArrayOutput)
}
// BucketObjectLockConfigurationV2MapInput is an input type that accepts BucketObjectLockConfigurationV2Map and BucketObjectLockConfigurationV2MapOutput values.
// You can construct a concrete instance of `BucketObjectLockConfigurationV2MapInput` via:
//
// BucketObjectLockConfigurationV2Map{ "key": BucketObjectLockConfigurationV2Args{...} }
type BucketObjectLockConfigurationV2MapInput interface {
pulumi.Input
ToBucketObjectLockConfigurationV2MapOutput() BucketObjectLockConfigurationV2MapOutput
ToBucketObjectLockConfigurationV2MapOutputWithContext(context.Context) BucketObjectLockConfigurationV2MapOutput
}
type BucketObjectLockConfigurationV2Map map[string]BucketObjectLockConfigurationV2Input
func (BucketObjectLockConfigurationV2Map) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*BucketObjectLockConfigurationV2)(nil)).Elem()
}
func (i BucketObjectLockConfigurationV2Map) ToBucketObjectLockConfigurationV2MapOutput() BucketObjectLockConfigurationV2MapOutput {
return i.ToBucketObjectLockConfigurationV2MapOutputWithContext(context.Background())
}
func (i BucketObjectLockConfigurationV2Map) ToBucketObjectLockConfigurationV2MapOutputWithContext(ctx context.Context) BucketObjectLockConfigurationV2MapOutput {
return pulumi.ToOutputWithContext(ctx, i).(BucketObjectLockConfigurationV2MapOutput)
}
type BucketObjectLockConfigurationV2Output struct{ *pulumi.OutputState }
func (BucketObjectLockConfigurationV2Output) ElementType() reflect.Type {
return reflect.TypeOf((**BucketObjectLockConfigurationV2)(nil)).Elem()
}
func (o BucketObjectLockConfigurationV2Output) ToBucketObjectLockConfigurationV2Output() BucketObjectLockConfigurationV2Output {
return o
}
func (o BucketObjectLockConfigurationV2Output) ToBucketObjectLockConfigurationV2OutputWithContext(ctx context.Context) BucketObjectLockConfigurationV2Output {
return o
}
// Name of the bucket.
func (o BucketObjectLockConfigurationV2Output) Bucket() pulumi.StringOutput {
return o.ApplyT(func(v *BucketObjectLockConfigurationV2) pulumi.StringOutput { return v.Bucket }).(pulumi.StringOutput)
}
// Account ID of the expected bucket owner.
func (o BucketObjectLockConfigurationV2Output) ExpectedBucketOwner() pulumi.StringPtrOutput {
return o.ApplyT(func(v *BucketObjectLockConfigurationV2) pulumi.StringPtrOutput { return v.ExpectedBucketOwner }).(pulumi.StringPtrOutput)
}
// Indicates whether this bucket has an Object Lock configuration enabled. Defaults to `Enabled`. Valid values: `Enabled`.
func (o BucketObjectLockConfigurationV2Output) ObjectLockEnabled() pulumi.StringPtrOutput {
return o.ApplyT(func(v *BucketObjectLockConfigurationV2) pulumi.StringPtrOutput { return v.ObjectLockEnabled }).(pulumi.StringPtrOutput)
}
// Configuration block for specifying the Object Lock rule for the specified object. See below.
func (o BucketObjectLockConfigurationV2Output) Rule() BucketObjectLockConfigurationV2RulePtrOutput {
return o.ApplyT(func(v *BucketObjectLockConfigurationV2) BucketObjectLockConfigurationV2RulePtrOutput { return v.Rule }).(BucketObjectLockConfigurationV2RulePtrOutput)
}
// Token to allow Object Lock to be enabled for an existing bucket. You must contact AWS support for the bucket's "Object Lock token".
// The token is generated in the back-end when [versioning](https://docs.aws.amazon.com/AmazonS3/latest/userguide/manage-versioning-examples.html) is enabled on a bucket. For more details on versioning, see the `s3.BucketVersioningV2` resource.
func (o BucketObjectLockConfigurationV2Output) Token() pulumi.StringPtrOutput {
return o.ApplyT(func(v *BucketObjectLockConfigurationV2) pulumi.StringPtrOutput { return v.Token }).(pulumi.StringPtrOutput)
}
type BucketObjectLockConfigurationV2ArrayOutput struct{ *pulumi.OutputState }
func (BucketObjectLockConfigurationV2ArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*BucketObjectLockConfigurationV2)(nil)).Elem()
}
func (o BucketObjectLockConfigurationV2ArrayOutput) ToBucketObjectLockConfigurationV2ArrayOutput() BucketObjectLockConfigurationV2ArrayOutput {
return o
}
func (o BucketObjectLockConfigurationV2ArrayOutput) ToBucketObjectLockConfigurationV2ArrayOutputWithContext(ctx context.Context) BucketObjectLockConfigurationV2ArrayOutput {
return o
}
func (o BucketObjectLockConfigurationV2ArrayOutput) Index(i pulumi.IntInput) BucketObjectLockConfigurationV2Output {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *BucketObjectLockConfigurationV2 {
return vs[0].([]*BucketObjectLockConfigurationV2)[vs[1].(int)]
}).(BucketObjectLockConfigurationV2Output)
}
type BucketObjectLockConfigurationV2MapOutput struct{ *pulumi.OutputState }
func (BucketObjectLockConfigurationV2MapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*BucketObjectLockConfigurationV2)(nil)).Elem()
}
func (o BucketObjectLockConfigurationV2MapOutput) ToBucketObjectLockConfigurationV2MapOutput() BucketObjectLockConfigurationV2MapOutput {
return o
}
func (o BucketObjectLockConfigurationV2MapOutput) ToBucketObjectLockConfigurationV2MapOutputWithContext(ctx context.Context) BucketObjectLockConfigurationV2MapOutput {
return o
}
func (o BucketObjectLockConfigurationV2MapOutput) MapIndex(k pulumi.StringInput) BucketObjectLockConfigurationV2Output {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *BucketObjectLockConfigurationV2 {
return vs[0].(map[string]*BucketObjectLockConfigurationV2)[vs[1].(string)]
}).(BucketObjectLockConfigurationV2Output)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*BucketObjectLockConfigurationV2Input)(nil)).Elem(), &BucketObjectLockConfigurationV2{})
pulumi.RegisterInputType(reflect.TypeOf((*BucketObjectLockConfigurationV2ArrayInput)(nil)).Elem(), BucketObjectLockConfigurationV2Array{})
pulumi.RegisterInputType(reflect.TypeOf((*BucketObjectLockConfigurationV2MapInput)(nil)).Elem(), BucketObjectLockConfigurationV2Map{})
pulumi.RegisterOutputType(BucketObjectLockConfigurationV2Output{})
pulumi.RegisterOutputType(BucketObjectLockConfigurationV2ArrayOutput{})
pulumi.RegisterOutputType(BucketObjectLockConfigurationV2MapOutput{})
}