/
inventory.go
451 lines (397 loc) · 17.4 KB
/
inventory.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
// 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 a S3 bucket [inventory configuration](https://docs.aws.amazon.com/AmazonS3/latest/dev/storage-inventory.html) resource.
//
// > This resource cannot be used with S3 directory buckets.
//
// ## Example Usage
//
// ### Add inventory configuration
//
// <!--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 {
// test, err := s3.NewBucketV2(ctx, "test", &s3.BucketV2Args{
// Bucket: pulumi.String("my-tf-test-bucket"),
// })
// if err != nil {
// return err
// }
// inventory, err := s3.NewBucketV2(ctx, "inventory", &s3.BucketV2Args{
// Bucket: pulumi.String("my-tf-inventory-bucket"),
// })
// if err != nil {
// return err
// }
// _, err = s3.NewInventory(ctx, "test", &s3.InventoryArgs{
// Bucket: test.ID(),
// Name: pulumi.String("EntireBucketDaily"),
// IncludedObjectVersions: pulumi.String("All"),
// Schedule: &s3.InventoryScheduleArgs{
// Frequency: pulumi.String("Daily"),
// },
// Destination: &s3.InventoryDestinationArgs{
// Bucket: &s3.InventoryDestinationBucketArgs{
// Format: pulumi.String("ORC"),
// BucketArn: inventory.Arn,
// },
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
// <!--End PulumiCodeChooser -->
//
// ### Add inventory configuration with S3 object prefix
//
// <!--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 {
// test, err := s3.NewBucketV2(ctx, "test", &s3.BucketV2Args{
// Bucket: pulumi.String("my-tf-test-bucket"),
// })
// if err != nil {
// return err
// }
// inventory, err := s3.NewBucketV2(ctx, "inventory", &s3.BucketV2Args{
// Bucket: pulumi.String("my-tf-inventory-bucket"),
// })
// if err != nil {
// return err
// }
// _, err = s3.NewInventory(ctx, "test-prefix", &s3.InventoryArgs{
// Bucket: test.ID(),
// Name: pulumi.String("DocumentsWeekly"),
// IncludedObjectVersions: pulumi.String("All"),
// Schedule: &s3.InventoryScheduleArgs{
// Frequency: pulumi.String("Daily"),
// },
// Filter: &s3.InventoryFilterArgs{
// Prefix: pulumi.String("documents/"),
// },
// Destination: &s3.InventoryDestinationArgs{
// Bucket: &s3.InventoryDestinationBucketArgs{
// Format: pulumi.String("ORC"),
// BucketArn: inventory.Arn,
// Prefix: pulumi.String("inventory"),
// },
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
// <!--End PulumiCodeChooser -->
//
// ## Import
//
// Using `pulumi import`, import S3 bucket inventory configurations using `bucket:inventory`. For example:
//
// ```sh
// $ pulumi import aws:s3/inventory:Inventory my-bucket-entire-bucket my-bucket:EntireBucket
// ```
type Inventory struct {
pulumi.CustomResourceState
// Name of the source bucket that inventory lists the objects for.
Bucket pulumi.StringOutput `pulumi:"bucket"`
// Contains information about where to publish the inventory results (documented below).
Destination InventoryDestinationOutput `pulumi:"destination"`
// Specifies whether the inventory is enabled or disabled.
Enabled pulumi.BoolPtrOutput `pulumi:"enabled"`
// Specifies an inventory filter. The inventory only includes objects that meet the filter's criteria (documented below).
Filter InventoryFilterPtrOutput `pulumi:"filter"`
// Object versions to include in the inventory list. Valid values: `All`, `Current`.
IncludedObjectVersions pulumi.StringOutput `pulumi:"includedObjectVersions"`
// Unique identifier of the inventory configuration for the bucket.
Name pulumi.StringOutput `pulumi:"name"`
// List of optional fields that are included in the inventory results. Please refer to the S3 [documentation](https://docs.aws.amazon.com/AmazonS3/latest/API/API_InventoryConfiguration.html#AmazonS3-Type-InventoryConfiguration-OptionalFields) for more details.
OptionalFields pulumi.StringArrayOutput `pulumi:"optionalFields"`
// Specifies the schedule for generating inventory results (documented below).
Schedule InventoryScheduleOutput `pulumi:"schedule"`
}
// NewInventory registers a new resource with the given unique name, arguments, and options.
func NewInventory(ctx *pulumi.Context,
name string, args *InventoryArgs, opts ...pulumi.ResourceOption) (*Inventory, 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.Destination == nil {
return nil, errors.New("invalid value for required argument 'Destination'")
}
if args.IncludedObjectVersions == nil {
return nil, errors.New("invalid value for required argument 'IncludedObjectVersions'")
}
if args.Schedule == nil {
return nil, errors.New("invalid value for required argument 'Schedule'")
}
opts = internal.PkgResourceDefaultOpts(opts)
var resource Inventory
err := ctx.RegisterResource("aws:s3/inventory:Inventory", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetInventory gets an existing Inventory 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 GetInventory(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *InventoryState, opts ...pulumi.ResourceOption) (*Inventory, error) {
var resource Inventory
err := ctx.ReadResource("aws:s3/inventory:Inventory", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering Inventory resources.
type inventoryState struct {
// Name of the source bucket that inventory lists the objects for.
Bucket *string `pulumi:"bucket"`
// Contains information about where to publish the inventory results (documented below).
Destination *InventoryDestination `pulumi:"destination"`
// Specifies whether the inventory is enabled or disabled.
Enabled *bool `pulumi:"enabled"`
// Specifies an inventory filter. The inventory only includes objects that meet the filter's criteria (documented below).
Filter *InventoryFilter `pulumi:"filter"`
// Object versions to include in the inventory list. Valid values: `All`, `Current`.
IncludedObjectVersions *string `pulumi:"includedObjectVersions"`
// Unique identifier of the inventory configuration for the bucket.
Name *string `pulumi:"name"`
// List of optional fields that are included in the inventory results. Please refer to the S3 [documentation](https://docs.aws.amazon.com/AmazonS3/latest/API/API_InventoryConfiguration.html#AmazonS3-Type-InventoryConfiguration-OptionalFields) for more details.
OptionalFields []string `pulumi:"optionalFields"`
// Specifies the schedule for generating inventory results (documented below).
Schedule *InventorySchedule `pulumi:"schedule"`
}
type InventoryState struct {
// Name of the source bucket that inventory lists the objects for.
Bucket pulumi.StringPtrInput
// Contains information about where to publish the inventory results (documented below).
Destination InventoryDestinationPtrInput
// Specifies whether the inventory is enabled or disabled.
Enabled pulumi.BoolPtrInput
// Specifies an inventory filter. The inventory only includes objects that meet the filter's criteria (documented below).
Filter InventoryFilterPtrInput
// Object versions to include in the inventory list. Valid values: `All`, `Current`.
IncludedObjectVersions pulumi.StringPtrInput
// Unique identifier of the inventory configuration for the bucket.
Name pulumi.StringPtrInput
// List of optional fields that are included in the inventory results. Please refer to the S3 [documentation](https://docs.aws.amazon.com/AmazonS3/latest/API/API_InventoryConfiguration.html#AmazonS3-Type-InventoryConfiguration-OptionalFields) for more details.
OptionalFields pulumi.StringArrayInput
// Specifies the schedule for generating inventory results (documented below).
Schedule InventorySchedulePtrInput
}
func (InventoryState) ElementType() reflect.Type {
return reflect.TypeOf((*inventoryState)(nil)).Elem()
}
type inventoryArgs struct {
// Name of the source bucket that inventory lists the objects for.
Bucket string `pulumi:"bucket"`
// Contains information about where to publish the inventory results (documented below).
Destination InventoryDestination `pulumi:"destination"`
// Specifies whether the inventory is enabled or disabled.
Enabled *bool `pulumi:"enabled"`
// Specifies an inventory filter. The inventory only includes objects that meet the filter's criteria (documented below).
Filter *InventoryFilter `pulumi:"filter"`
// Object versions to include in the inventory list. Valid values: `All`, `Current`.
IncludedObjectVersions string `pulumi:"includedObjectVersions"`
// Unique identifier of the inventory configuration for the bucket.
Name *string `pulumi:"name"`
// List of optional fields that are included in the inventory results. Please refer to the S3 [documentation](https://docs.aws.amazon.com/AmazonS3/latest/API/API_InventoryConfiguration.html#AmazonS3-Type-InventoryConfiguration-OptionalFields) for more details.
OptionalFields []string `pulumi:"optionalFields"`
// Specifies the schedule for generating inventory results (documented below).
Schedule InventorySchedule `pulumi:"schedule"`
}
// The set of arguments for constructing a Inventory resource.
type InventoryArgs struct {
// Name of the source bucket that inventory lists the objects for.
Bucket pulumi.StringInput
// Contains information about where to publish the inventory results (documented below).
Destination InventoryDestinationInput
// Specifies whether the inventory is enabled or disabled.
Enabled pulumi.BoolPtrInput
// Specifies an inventory filter. The inventory only includes objects that meet the filter's criteria (documented below).
Filter InventoryFilterPtrInput
// Object versions to include in the inventory list. Valid values: `All`, `Current`.
IncludedObjectVersions pulumi.StringInput
// Unique identifier of the inventory configuration for the bucket.
Name pulumi.StringPtrInput
// List of optional fields that are included in the inventory results. Please refer to the S3 [documentation](https://docs.aws.amazon.com/AmazonS3/latest/API/API_InventoryConfiguration.html#AmazonS3-Type-InventoryConfiguration-OptionalFields) for more details.
OptionalFields pulumi.StringArrayInput
// Specifies the schedule for generating inventory results (documented below).
Schedule InventoryScheduleInput
}
func (InventoryArgs) ElementType() reflect.Type {
return reflect.TypeOf((*inventoryArgs)(nil)).Elem()
}
type InventoryInput interface {
pulumi.Input
ToInventoryOutput() InventoryOutput
ToInventoryOutputWithContext(ctx context.Context) InventoryOutput
}
func (*Inventory) ElementType() reflect.Type {
return reflect.TypeOf((**Inventory)(nil)).Elem()
}
func (i *Inventory) ToInventoryOutput() InventoryOutput {
return i.ToInventoryOutputWithContext(context.Background())
}
func (i *Inventory) ToInventoryOutputWithContext(ctx context.Context) InventoryOutput {
return pulumi.ToOutputWithContext(ctx, i).(InventoryOutput)
}
// InventoryArrayInput is an input type that accepts InventoryArray and InventoryArrayOutput values.
// You can construct a concrete instance of `InventoryArrayInput` via:
//
// InventoryArray{ InventoryArgs{...} }
type InventoryArrayInput interface {
pulumi.Input
ToInventoryArrayOutput() InventoryArrayOutput
ToInventoryArrayOutputWithContext(context.Context) InventoryArrayOutput
}
type InventoryArray []InventoryInput
func (InventoryArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Inventory)(nil)).Elem()
}
func (i InventoryArray) ToInventoryArrayOutput() InventoryArrayOutput {
return i.ToInventoryArrayOutputWithContext(context.Background())
}
func (i InventoryArray) ToInventoryArrayOutputWithContext(ctx context.Context) InventoryArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(InventoryArrayOutput)
}
// InventoryMapInput is an input type that accepts InventoryMap and InventoryMapOutput values.
// You can construct a concrete instance of `InventoryMapInput` via:
//
// InventoryMap{ "key": InventoryArgs{...} }
type InventoryMapInput interface {
pulumi.Input
ToInventoryMapOutput() InventoryMapOutput
ToInventoryMapOutputWithContext(context.Context) InventoryMapOutput
}
type InventoryMap map[string]InventoryInput
func (InventoryMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Inventory)(nil)).Elem()
}
func (i InventoryMap) ToInventoryMapOutput() InventoryMapOutput {
return i.ToInventoryMapOutputWithContext(context.Background())
}
func (i InventoryMap) ToInventoryMapOutputWithContext(ctx context.Context) InventoryMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(InventoryMapOutput)
}
type InventoryOutput struct{ *pulumi.OutputState }
func (InventoryOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Inventory)(nil)).Elem()
}
func (o InventoryOutput) ToInventoryOutput() InventoryOutput {
return o
}
func (o InventoryOutput) ToInventoryOutputWithContext(ctx context.Context) InventoryOutput {
return o
}
// Name of the source bucket that inventory lists the objects for.
func (o InventoryOutput) Bucket() pulumi.StringOutput {
return o.ApplyT(func(v *Inventory) pulumi.StringOutput { return v.Bucket }).(pulumi.StringOutput)
}
// Contains information about where to publish the inventory results (documented below).
func (o InventoryOutput) Destination() InventoryDestinationOutput {
return o.ApplyT(func(v *Inventory) InventoryDestinationOutput { return v.Destination }).(InventoryDestinationOutput)
}
// Specifies whether the inventory is enabled or disabled.
func (o InventoryOutput) Enabled() pulumi.BoolPtrOutput {
return o.ApplyT(func(v *Inventory) pulumi.BoolPtrOutput { return v.Enabled }).(pulumi.BoolPtrOutput)
}
// Specifies an inventory filter. The inventory only includes objects that meet the filter's criteria (documented below).
func (o InventoryOutput) Filter() InventoryFilterPtrOutput {
return o.ApplyT(func(v *Inventory) InventoryFilterPtrOutput { return v.Filter }).(InventoryFilterPtrOutput)
}
// Object versions to include in the inventory list. Valid values: `All`, `Current`.
func (o InventoryOutput) IncludedObjectVersions() pulumi.StringOutput {
return o.ApplyT(func(v *Inventory) pulumi.StringOutput { return v.IncludedObjectVersions }).(pulumi.StringOutput)
}
// Unique identifier of the inventory configuration for the bucket.
func (o InventoryOutput) Name() pulumi.StringOutput {
return o.ApplyT(func(v *Inventory) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
}
// List of optional fields that are included in the inventory results. Please refer to the S3 [documentation](https://docs.aws.amazon.com/AmazonS3/latest/API/API_InventoryConfiguration.html#AmazonS3-Type-InventoryConfiguration-OptionalFields) for more details.
func (o InventoryOutput) OptionalFields() pulumi.StringArrayOutput {
return o.ApplyT(func(v *Inventory) pulumi.StringArrayOutput { return v.OptionalFields }).(pulumi.StringArrayOutput)
}
// Specifies the schedule for generating inventory results (documented below).
func (o InventoryOutput) Schedule() InventoryScheduleOutput {
return o.ApplyT(func(v *Inventory) InventoryScheduleOutput { return v.Schedule }).(InventoryScheduleOutput)
}
type InventoryArrayOutput struct{ *pulumi.OutputState }
func (InventoryArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Inventory)(nil)).Elem()
}
func (o InventoryArrayOutput) ToInventoryArrayOutput() InventoryArrayOutput {
return o
}
func (o InventoryArrayOutput) ToInventoryArrayOutputWithContext(ctx context.Context) InventoryArrayOutput {
return o
}
func (o InventoryArrayOutput) Index(i pulumi.IntInput) InventoryOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Inventory {
return vs[0].([]*Inventory)[vs[1].(int)]
}).(InventoryOutput)
}
type InventoryMapOutput struct{ *pulumi.OutputState }
func (InventoryMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Inventory)(nil)).Elem()
}
func (o InventoryMapOutput) ToInventoryMapOutput() InventoryMapOutput {
return o
}
func (o InventoryMapOutput) ToInventoryMapOutputWithContext(ctx context.Context) InventoryMapOutput {
return o
}
func (o InventoryMapOutput) MapIndex(k pulumi.StringInput) InventoryOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Inventory {
return vs[0].(map[string]*Inventory)[vs[1].(string)]
}).(InventoryOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*InventoryInput)(nil)).Elem(), &Inventory{})
pulumi.RegisterInputType(reflect.TypeOf((*InventoryArrayInput)(nil)).Elem(), InventoryArray{})
pulumi.RegisterInputType(reflect.TypeOf((*InventoryMapInput)(nil)).Elem(), InventoryMap{})
pulumi.RegisterOutputType(InventoryOutput{})
pulumi.RegisterOutputType(InventoryArrayOutput{})
pulumi.RegisterOutputType(InventoryMapOutput{})
}