/
catalogTable.go
446 lines (400 loc) · 19.4 KB
/
catalogTable.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
// *** 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 glue
import (
"context"
"reflect"
"github.com/pkg/errors"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Provides a Glue Catalog Table Resource. You can refer to the [Glue Developer Guide](http://docs.aws.amazon.com/glue/latest/dg/populate-data-catalog.html) for a full explanation of the Glue Data Catalog functionality.
//
// ## Example Usage
// ### Basic Table
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-aws/sdk/v4/go/aws/glue"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := glue.NewCatalogTable(ctx, "awsGlueCatalogTable", &glue.CatalogTableArgs{
// DatabaseName: pulumi.String("MyCatalogDatabase"),
// Name: pulumi.String("MyCatalogTable"),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
// ### Parquet Table for Athena
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-aws/sdk/v4/go/aws/glue"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := glue.NewCatalogTable(ctx, "awsGlueCatalogTable", &glue.CatalogTableArgs{
// DatabaseName: pulumi.String("MyCatalogDatabase"),
// Name: pulumi.String("MyCatalogTable"),
// Parameters: pulumi.StringMap{
// "EXTERNAL": pulumi.String("TRUE"),
// "parquet.compression": pulumi.String("SNAPPY"),
// },
// StorageDescriptor: &glue.CatalogTableStorageDescriptorArgs{
// Columns: glue.CatalogTableStorageDescriptorColumnArray{
// &glue.CatalogTableStorageDescriptorColumnArgs{
// Name: pulumi.String("my_string"),
// Type: pulumi.String("string"),
// },
// &glue.CatalogTableStorageDescriptorColumnArgs{
// Name: pulumi.String("my_double"),
// Type: pulumi.String("double"),
// },
// &glue.CatalogTableStorageDescriptorColumnArgs{
// Comment: pulumi.String(""),
// Name: pulumi.String("my_date"),
// Type: pulumi.String("date"),
// },
// &glue.CatalogTableStorageDescriptorColumnArgs{
// Comment: pulumi.String(""),
// Name: pulumi.String("my_bigint"),
// Type: pulumi.String("bigint"),
// },
// &glue.CatalogTableStorageDescriptorColumnArgs{
// Comment: pulumi.String(""),
// Name: pulumi.String("my_struct"),
// Type: pulumi.String("struct<my_nested_string:string>"),
// },
// },
// InputFormat: pulumi.String("org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat"),
// Location: pulumi.String("s3://my-bucket/event-streams/my-stream"),
// OutputFormat: pulumi.String("org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat"),
// SerDeInfo: &glue.CatalogTableStorageDescriptorSerDeInfoArgs{
// Name: pulumi.String("my-stream"),
// Parameters: pulumi.StringMap{
// "serialization.format": pulumi.String("1"),
// },
// SerializationLibrary: pulumi.String("org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe"),
// },
// },
// TableType: pulumi.String("EXTERNAL_TABLE"),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// ## Import
//
// Glue Tables can be imported with their catalog ID (usually AWS account ID), database name, and table name, e.g.,
//
// ```sh
// $ pulumi import aws:glue/catalogTable:CatalogTable MyTable 123456789012:MyDatabase:MyTable
// ```
type CatalogTable struct {
pulumi.CustomResourceState
// The ARN of the Glue Table.
Arn pulumi.StringOutput `pulumi:"arn"`
// ID of the Data Catalog in which the table resides.
CatalogId pulumi.StringOutput `pulumi:"catalogId"`
// Name of the catalog database that contains the target table.
DatabaseName pulumi.StringOutput `pulumi:"databaseName"`
// Description of the table.
Description pulumi.StringPtrOutput `pulumi:"description"`
// Name of the target table.
Name pulumi.StringOutput `pulumi:"name"`
// Owner of the table.
Owner pulumi.StringPtrOutput `pulumi:"owner"`
// Map of initialization parameters for the SerDe, in key-value form.
Parameters pulumi.StringMapOutput `pulumi:"parameters"`
// Configuration block for a maximum of 3 partition indexes. See `partitionIndex` below.
PartitionIndices CatalogTablePartitionIndexArrayOutput `pulumi:"partitionIndices"`
// Configuration block of columns by which the table is partitioned. Only primitive types are supported as partition keys. See `partitionKeys` below.
PartitionKeys CatalogTablePartitionKeyArrayOutput `pulumi:"partitionKeys"`
// Retention time for this table.
Retention pulumi.IntPtrOutput `pulumi:"retention"`
// Configuration block for information about the physical storage of this table. For more information, refer to the [Glue Developer Guide](https://docs.aws.amazon.com/glue/latest/dg/aws-glue-api-catalog-tables.html#aws-glue-api-catalog-tables-StorageDescriptor). See `storageDescriptor` below.
StorageDescriptor CatalogTableStorageDescriptorPtrOutput `pulumi:"storageDescriptor"`
// Type of this table (EXTERNAL_TABLE, VIRTUAL_VIEW, etc.). While optional, some Athena DDL queries such as `ALTER TABLE` and `SHOW CREATE TABLE` will fail if this argument is empty.
TableType pulumi.StringPtrOutput `pulumi:"tableType"`
// Configuration block of a target table for resource linking. See `targetTable` below.
TargetTable CatalogTableTargetTablePtrOutput `pulumi:"targetTable"`
// If the table is a view, the expanded text of the view; otherwise null.
ViewExpandedText pulumi.StringPtrOutput `pulumi:"viewExpandedText"`
// If the table is a view, the original text of the view; otherwise null.
ViewOriginalText pulumi.StringPtrOutput `pulumi:"viewOriginalText"`
}
// NewCatalogTable registers a new resource with the given unique name, arguments, and options.
func NewCatalogTable(ctx *pulumi.Context,
name string, args *CatalogTableArgs, opts ...pulumi.ResourceOption) (*CatalogTable, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.DatabaseName == nil {
return nil, errors.New("invalid value for required argument 'DatabaseName'")
}
var resource CatalogTable
err := ctx.RegisterResource("aws:glue/catalogTable:CatalogTable", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetCatalogTable gets an existing CatalogTable 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 GetCatalogTable(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *CatalogTableState, opts ...pulumi.ResourceOption) (*CatalogTable, error) {
var resource CatalogTable
err := ctx.ReadResource("aws:glue/catalogTable:CatalogTable", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering CatalogTable resources.
type catalogTableState struct {
// The ARN of the Glue Table.
Arn *string `pulumi:"arn"`
// ID of the Data Catalog in which the table resides.
CatalogId *string `pulumi:"catalogId"`
// Name of the catalog database that contains the target table.
DatabaseName *string `pulumi:"databaseName"`
// Description of the table.
Description *string `pulumi:"description"`
// Name of the target table.
Name *string `pulumi:"name"`
// Owner of the table.
Owner *string `pulumi:"owner"`
// Map of initialization parameters for the SerDe, in key-value form.
Parameters map[string]string `pulumi:"parameters"`
// Configuration block for a maximum of 3 partition indexes. See `partitionIndex` below.
PartitionIndices []CatalogTablePartitionIndex `pulumi:"partitionIndices"`
// Configuration block of columns by which the table is partitioned. Only primitive types are supported as partition keys. See `partitionKeys` below.
PartitionKeys []CatalogTablePartitionKey `pulumi:"partitionKeys"`
// Retention time for this table.
Retention *int `pulumi:"retention"`
// Configuration block for information about the physical storage of this table. For more information, refer to the [Glue Developer Guide](https://docs.aws.amazon.com/glue/latest/dg/aws-glue-api-catalog-tables.html#aws-glue-api-catalog-tables-StorageDescriptor). See `storageDescriptor` below.
StorageDescriptor *CatalogTableStorageDescriptor `pulumi:"storageDescriptor"`
// Type of this table (EXTERNAL_TABLE, VIRTUAL_VIEW, etc.). While optional, some Athena DDL queries such as `ALTER TABLE` and `SHOW CREATE TABLE` will fail if this argument is empty.
TableType *string `pulumi:"tableType"`
// Configuration block of a target table for resource linking. See `targetTable` below.
TargetTable *CatalogTableTargetTable `pulumi:"targetTable"`
// If the table is a view, the expanded text of the view; otherwise null.
ViewExpandedText *string `pulumi:"viewExpandedText"`
// If the table is a view, the original text of the view; otherwise null.
ViewOriginalText *string `pulumi:"viewOriginalText"`
}
type CatalogTableState struct {
// The ARN of the Glue Table.
Arn pulumi.StringPtrInput
// ID of the Data Catalog in which the table resides.
CatalogId pulumi.StringPtrInput
// Name of the catalog database that contains the target table.
DatabaseName pulumi.StringPtrInput
// Description of the table.
Description pulumi.StringPtrInput
// Name of the target table.
Name pulumi.StringPtrInput
// Owner of the table.
Owner pulumi.StringPtrInput
// Map of initialization parameters for the SerDe, in key-value form.
Parameters pulumi.StringMapInput
// Configuration block for a maximum of 3 partition indexes. See `partitionIndex` below.
PartitionIndices CatalogTablePartitionIndexArrayInput
// Configuration block of columns by which the table is partitioned. Only primitive types are supported as partition keys. See `partitionKeys` below.
PartitionKeys CatalogTablePartitionKeyArrayInput
// Retention time for this table.
Retention pulumi.IntPtrInput
// Configuration block for information about the physical storage of this table. For more information, refer to the [Glue Developer Guide](https://docs.aws.amazon.com/glue/latest/dg/aws-glue-api-catalog-tables.html#aws-glue-api-catalog-tables-StorageDescriptor). See `storageDescriptor` below.
StorageDescriptor CatalogTableStorageDescriptorPtrInput
// Type of this table (EXTERNAL_TABLE, VIRTUAL_VIEW, etc.). While optional, some Athena DDL queries such as `ALTER TABLE` and `SHOW CREATE TABLE` will fail if this argument is empty.
TableType pulumi.StringPtrInput
// Configuration block of a target table for resource linking. See `targetTable` below.
TargetTable CatalogTableTargetTablePtrInput
// If the table is a view, the expanded text of the view; otherwise null.
ViewExpandedText pulumi.StringPtrInput
// If the table is a view, the original text of the view; otherwise null.
ViewOriginalText pulumi.StringPtrInput
}
func (CatalogTableState) ElementType() reflect.Type {
return reflect.TypeOf((*catalogTableState)(nil)).Elem()
}
type catalogTableArgs struct {
// ID of the Data Catalog in which the table resides.
CatalogId *string `pulumi:"catalogId"`
// Name of the catalog database that contains the target table.
DatabaseName string `pulumi:"databaseName"`
// Description of the table.
Description *string `pulumi:"description"`
// Name of the target table.
Name *string `pulumi:"name"`
// Owner of the table.
Owner *string `pulumi:"owner"`
// Map of initialization parameters for the SerDe, in key-value form.
Parameters map[string]string `pulumi:"parameters"`
// Configuration block for a maximum of 3 partition indexes. See `partitionIndex` below.
PartitionIndices []CatalogTablePartitionIndex `pulumi:"partitionIndices"`
// Configuration block of columns by which the table is partitioned. Only primitive types are supported as partition keys. See `partitionKeys` below.
PartitionKeys []CatalogTablePartitionKey `pulumi:"partitionKeys"`
// Retention time for this table.
Retention *int `pulumi:"retention"`
// Configuration block for information about the physical storage of this table. For more information, refer to the [Glue Developer Guide](https://docs.aws.amazon.com/glue/latest/dg/aws-glue-api-catalog-tables.html#aws-glue-api-catalog-tables-StorageDescriptor). See `storageDescriptor` below.
StorageDescriptor *CatalogTableStorageDescriptor `pulumi:"storageDescriptor"`
// Type of this table (EXTERNAL_TABLE, VIRTUAL_VIEW, etc.). While optional, some Athena DDL queries such as `ALTER TABLE` and `SHOW CREATE TABLE` will fail if this argument is empty.
TableType *string `pulumi:"tableType"`
// Configuration block of a target table for resource linking. See `targetTable` below.
TargetTable *CatalogTableTargetTable `pulumi:"targetTable"`
// If the table is a view, the expanded text of the view; otherwise null.
ViewExpandedText *string `pulumi:"viewExpandedText"`
// If the table is a view, the original text of the view; otherwise null.
ViewOriginalText *string `pulumi:"viewOriginalText"`
}
// The set of arguments for constructing a CatalogTable resource.
type CatalogTableArgs struct {
// ID of the Data Catalog in which the table resides.
CatalogId pulumi.StringPtrInput
// Name of the catalog database that contains the target table.
DatabaseName pulumi.StringInput
// Description of the table.
Description pulumi.StringPtrInput
// Name of the target table.
Name pulumi.StringPtrInput
// Owner of the table.
Owner pulumi.StringPtrInput
// Map of initialization parameters for the SerDe, in key-value form.
Parameters pulumi.StringMapInput
// Configuration block for a maximum of 3 partition indexes. See `partitionIndex` below.
PartitionIndices CatalogTablePartitionIndexArrayInput
// Configuration block of columns by which the table is partitioned. Only primitive types are supported as partition keys. See `partitionKeys` below.
PartitionKeys CatalogTablePartitionKeyArrayInput
// Retention time for this table.
Retention pulumi.IntPtrInput
// Configuration block for information about the physical storage of this table. For more information, refer to the [Glue Developer Guide](https://docs.aws.amazon.com/glue/latest/dg/aws-glue-api-catalog-tables.html#aws-glue-api-catalog-tables-StorageDescriptor). See `storageDescriptor` below.
StorageDescriptor CatalogTableStorageDescriptorPtrInput
// Type of this table (EXTERNAL_TABLE, VIRTUAL_VIEW, etc.). While optional, some Athena DDL queries such as `ALTER TABLE` and `SHOW CREATE TABLE` will fail if this argument is empty.
TableType pulumi.StringPtrInput
// Configuration block of a target table for resource linking. See `targetTable` below.
TargetTable CatalogTableTargetTablePtrInput
// If the table is a view, the expanded text of the view; otherwise null.
ViewExpandedText pulumi.StringPtrInput
// If the table is a view, the original text of the view; otherwise null.
ViewOriginalText pulumi.StringPtrInput
}
func (CatalogTableArgs) ElementType() reflect.Type {
return reflect.TypeOf((*catalogTableArgs)(nil)).Elem()
}
type CatalogTableInput interface {
pulumi.Input
ToCatalogTableOutput() CatalogTableOutput
ToCatalogTableOutputWithContext(ctx context.Context) CatalogTableOutput
}
func (*CatalogTable) ElementType() reflect.Type {
return reflect.TypeOf((**CatalogTable)(nil)).Elem()
}
func (i *CatalogTable) ToCatalogTableOutput() CatalogTableOutput {
return i.ToCatalogTableOutputWithContext(context.Background())
}
func (i *CatalogTable) ToCatalogTableOutputWithContext(ctx context.Context) CatalogTableOutput {
return pulumi.ToOutputWithContext(ctx, i).(CatalogTableOutput)
}
// CatalogTableArrayInput is an input type that accepts CatalogTableArray and CatalogTableArrayOutput values.
// You can construct a concrete instance of `CatalogTableArrayInput` via:
//
// CatalogTableArray{ CatalogTableArgs{...} }
type CatalogTableArrayInput interface {
pulumi.Input
ToCatalogTableArrayOutput() CatalogTableArrayOutput
ToCatalogTableArrayOutputWithContext(context.Context) CatalogTableArrayOutput
}
type CatalogTableArray []CatalogTableInput
func (CatalogTableArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*CatalogTable)(nil)).Elem()
}
func (i CatalogTableArray) ToCatalogTableArrayOutput() CatalogTableArrayOutput {
return i.ToCatalogTableArrayOutputWithContext(context.Background())
}
func (i CatalogTableArray) ToCatalogTableArrayOutputWithContext(ctx context.Context) CatalogTableArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(CatalogTableArrayOutput)
}
// CatalogTableMapInput is an input type that accepts CatalogTableMap and CatalogTableMapOutput values.
// You can construct a concrete instance of `CatalogTableMapInput` via:
//
// CatalogTableMap{ "key": CatalogTableArgs{...} }
type CatalogTableMapInput interface {
pulumi.Input
ToCatalogTableMapOutput() CatalogTableMapOutput
ToCatalogTableMapOutputWithContext(context.Context) CatalogTableMapOutput
}
type CatalogTableMap map[string]CatalogTableInput
func (CatalogTableMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*CatalogTable)(nil)).Elem()
}
func (i CatalogTableMap) ToCatalogTableMapOutput() CatalogTableMapOutput {
return i.ToCatalogTableMapOutputWithContext(context.Background())
}
func (i CatalogTableMap) ToCatalogTableMapOutputWithContext(ctx context.Context) CatalogTableMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(CatalogTableMapOutput)
}
type CatalogTableOutput struct{ *pulumi.OutputState }
func (CatalogTableOutput) ElementType() reflect.Type {
return reflect.TypeOf((**CatalogTable)(nil)).Elem()
}
func (o CatalogTableOutput) ToCatalogTableOutput() CatalogTableOutput {
return o
}
func (o CatalogTableOutput) ToCatalogTableOutputWithContext(ctx context.Context) CatalogTableOutput {
return o
}
type CatalogTableArrayOutput struct{ *pulumi.OutputState }
func (CatalogTableArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*CatalogTable)(nil)).Elem()
}
func (o CatalogTableArrayOutput) ToCatalogTableArrayOutput() CatalogTableArrayOutput {
return o
}
func (o CatalogTableArrayOutput) ToCatalogTableArrayOutputWithContext(ctx context.Context) CatalogTableArrayOutput {
return o
}
func (o CatalogTableArrayOutput) Index(i pulumi.IntInput) CatalogTableOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *CatalogTable {
return vs[0].([]*CatalogTable)[vs[1].(int)]
}).(CatalogTableOutput)
}
type CatalogTableMapOutput struct{ *pulumi.OutputState }
func (CatalogTableMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*CatalogTable)(nil)).Elem()
}
func (o CatalogTableMapOutput) ToCatalogTableMapOutput() CatalogTableMapOutput {
return o
}
func (o CatalogTableMapOutput) ToCatalogTableMapOutputWithContext(ctx context.Context) CatalogTableMapOutput {
return o
}
func (o CatalogTableMapOutput) MapIndex(k pulumi.StringInput) CatalogTableOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *CatalogTable {
return vs[0].(map[string]*CatalogTable)[vs[1].(string)]
}).(CatalogTableOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*CatalogTableInput)(nil)).Elem(), &CatalogTable{})
pulumi.RegisterInputType(reflect.TypeOf((*CatalogTableArrayInput)(nil)).Elem(), CatalogTableArray{})
pulumi.RegisterInputType(reflect.TypeOf((*CatalogTableMapInput)(nil)).Elem(), CatalogTableMap{})
pulumi.RegisterOutputType(CatalogTableOutput{})
pulumi.RegisterOutputType(CatalogTableArrayOutput{})
pulumi.RegisterOutputType(CatalogTableMapOutput{})
}