/
tableItem.go
332 lines (282 loc) · 11.8 KB
/
tableItem.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
// 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 dynamodb
import (
"context"
"reflect"
"errors"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Provides a DynamoDB table item resource
//
// > **Note:** This resource is not meant to be used for managing large amounts of data in your table, it is not designed to scale.
//
// You should perform **regular backups** of all data in the table, see [AWS docs for more](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/BackupRestore.html).
//
// ## Example Usage
//
// <!--Start PulumiCodeChooser -->
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/dynamodb"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// exampleTable, err := dynamodb.NewTable(ctx, "example", &dynamodb.TableArgs{
// Name: pulumi.String("example-name"),
// ReadCapacity: pulumi.Int(10),
// WriteCapacity: pulumi.Int(10),
// HashKey: pulumi.String("exampleHashKey"),
// Attributes: dynamodb.TableAttributeArray{
// &dynamodb.TableAttributeArgs{
// Name: pulumi.String("exampleHashKey"),
// Type: pulumi.String("S"),
// },
// },
// })
// if err != nil {
// return err
// }
// _, err = dynamodb.NewTableItem(ctx, "example", &dynamodb.TableItemArgs{
// TableName: exampleTable.Name,
// HashKey: exampleTable.HashKey,
// Item: pulumi.String(`{
// "exampleHashKey": {"S": "something"},
// "one": {"N": "11111"},
// "two": {"N": "22222"},
// "three": {"N": "33333"},
// "four": {"N": "44444"}
// }
//
// `),
//
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
// <!--End PulumiCodeChooser -->
//
// ## Import
//
// You cannot import DynamoDB table items.
type TableItem struct {
pulumi.CustomResourceState
// Hash key to use for lookups and identification of the item
HashKey pulumi.StringOutput `pulumi:"hashKey"`
// JSON representation of a map of attribute name/value pairs, one for each attribute. Only the primary key attributes are required; you can optionally provide other attribute name-value pairs for the item.
Item pulumi.StringOutput `pulumi:"item"`
// Range key to use for lookups and identification of the item. Required if there is range key defined in the table.
RangeKey pulumi.StringPtrOutput `pulumi:"rangeKey"`
// Name of the table to contain the item.
TableName pulumi.StringOutput `pulumi:"tableName"`
}
// NewTableItem registers a new resource with the given unique name, arguments, and options.
func NewTableItem(ctx *pulumi.Context,
name string, args *TableItemArgs, opts ...pulumi.ResourceOption) (*TableItem, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.HashKey == nil {
return nil, errors.New("invalid value for required argument 'HashKey'")
}
if args.Item == nil {
return nil, errors.New("invalid value for required argument 'Item'")
}
if args.TableName == nil {
return nil, errors.New("invalid value for required argument 'TableName'")
}
opts = internal.PkgResourceDefaultOpts(opts)
var resource TableItem
err := ctx.RegisterResource("aws:dynamodb/tableItem:TableItem", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetTableItem gets an existing TableItem 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 GetTableItem(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *TableItemState, opts ...pulumi.ResourceOption) (*TableItem, error) {
var resource TableItem
err := ctx.ReadResource("aws:dynamodb/tableItem:TableItem", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering TableItem resources.
type tableItemState struct {
// Hash key to use for lookups and identification of the item
HashKey *string `pulumi:"hashKey"`
// JSON representation of a map of attribute name/value pairs, one for each attribute. Only the primary key attributes are required; you can optionally provide other attribute name-value pairs for the item.
Item *string `pulumi:"item"`
// Range key to use for lookups and identification of the item. Required if there is range key defined in the table.
RangeKey *string `pulumi:"rangeKey"`
// Name of the table to contain the item.
TableName *string `pulumi:"tableName"`
}
type TableItemState struct {
// Hash key to use for lookups and identification of the item
HashKey pulumi.StringPtrInput
// JSON representation of a map of attribute name/value pairs, one for each attribute. Only the primary key attributes are required; you can optionally provide other attribute name-value pairs for the item.
Item pulumi.StringPtrInput
// Range key to use for lookups and identification of the item. Required if there is range key defined in the table.
RangeKey pulumi.StringPtrInput
// Name of the table to contain the item.
TableName pulumi.StringPtrInput
}
func (TableItemState) ElementType() reflect.Type {
return reflect.TypeOf((*tableItemState)(nil)).Elem()
}
type tableItemArgs struct {
// Hash key to use for lookups and identification of the item
HashKey string `pulumi:"hashKey"`
// JSON representation of a map of attribute name/value pairs, one for each attribute. Only the primary key attributes are required; you can optionally provide other attribute name-value pairs for the item.
Item string `pulumi:"item"`
// Range key to use for lookups and identification of the item. Required if there is range key defined in the table.
RangeKey *string `pulumi:"rangeKey"`
// Name of the table to contain the item.
TableName string `pulumi:"tableName"`
}
// The set of arguments for constructing a TableItem resource.
type TableItemArgs struct {
// Hash key to use for lookups and identification of the item
HashKey pulumi.StringInput
// JSON representation of a map of attribute name/value pairs, one for each attribute. Only the primary key attributes are required; you can optionally provide other attribute name-value pairs for the item.
Item pulumi.StringInput
// Range key to use for lookups and identification of the item. Required if there is range key defined in the table.
RangeKey pulumi.StringPtrInput
// Name of the table to contain the item.
TableName pulumi.StringInput
}
func (TableItemArgs) ElementType() reflect.Type {
return reflect.TypeOf((*tableItemArgs)(nil)).Elem()
}
type TableItemInput interface {
pulumi.Input
ToTableItemOutput() TableItemOutput
ToTableItemOutputWithContext(ctx context.Context) TableItemOutput
}
func (*TableItem) ElementType() reflect.Type {
return reflect.TypeOf((**TableItem)(nil)).Elem()
}
func (i *TableItem) ToTableItemOutput() TableItemOutput {
return i.ToTableItemOutputWithContext(context.Background())
}
func (i *TableItem) ToTableItemOutputWithContext(ctx context.Context) TableItemOutput {
return pulumi.ToOutputWithContext(ctx, i).(TableItemOutput)
}
// TableItemArrayInput is an input type that accepts TableItemArray and TableItemArrayOutput values.
// You can construct a concrete instance of `TableItemArrayInput` via:
//
// TableItemArray{ TableItemArgs{...} }
type TableItemArrayInput interface {
pulumi.Input
ToTableItemArrayOutput() TableItemArrayOutput
ToTableItemArrayOutputWithContext(context.Context) TableItemArrayOutput
}
type TableItemArray []TableItemInput
func (TableItemArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*TableItem)(nil)).Elem()
}
func (i TableItemArray) ToTableItemArrayOutput() TableItemArrayOutput {
return i.ToTableItemArrayOutputWithContext(context.Background())
}
func (i TableItemArray) ToTableItemArrayOutputWithContext(ctx context.Context) TableItemArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(TableItemArrayOutput)
}
// TableItemMapInput is an input type that accepts TableItemMap and TableItemMapOutput values.
// You can construct a concrete instance of `TableItemMapInput` via:
//
// TableItemMap{ "key": TableItemArgs{...} }
type TableItemMapInput interface {
pulumi.Input
ToTableItemMapOutput() TableItemMapOutput
ToTableItemMapOutputWithContext(context.Context) TableItemMapOutput
}
type TableItemMap map[string]TableItemInput
func (TableItemMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*TableItem)(nil)).Elem()
}
func (i TableItemMap) ToTableItemMapOutput() TableItemMapOutput {
return i.ToTableItemMapOutputWithContext(context.Background())
}
func (i TableItemMap) ToTableItemMapOutputWithContext(ctx context.Context) TableItemMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(TableItemMapOutput)
}
type TableItemOutput struct{ *pulumi.OutputState }
func (TableItemOutput) ElementType() reflect.Type {
return reflect.TypeOf((**TableItem)(nil)).Elem()
}
func (o TableItemOutput) ToTableItemOutput() TableItemOutput {
return o
}
func (o TableItemOutput) ToTableItemOutputWithContext(ctx context.Context) TableItemOutput {
return o
}
// Hash key to use for lookups and identification of the item
func (o TableItemOutput) HashKey() pulumi.StringOutput {
return o.ApplyT(func(v *TableItem) pulumi.StringOutput { return v.HashKey }).(pulumi.StringOutput)
}
// JSON representation of a map of attribute name/value pairs, one for each attribute. Only the primary key attributes are required; you can optionally provide other attribute name-value pairs for the item.
func (o TableItemOutput) Item() pulumi.StringOutput {
return o.ApplyT(func(v *TableItem) pulumi.StringOutput { return v.Item }).(pulumi.StringOutput)
}
// Range key to use for lookups and identification of the item. Required if there is range key defined in the table.
func (o TableItemOutput) RangeKey() pulumi.StringPtrOutput {
return o.ApplyT(func(v *TableItem) pulumi.StringPtrOutput { return v.RangeKey }).(pulumi.StringPtrOutput)
}
// Name of the table to contain the item.
func (o TableItemOutput) TableName() pulumi.StringOutput {
return o.ApplyT(func(v *TableItem) pulumi.StringOutput { return v.TableName }).(pulumi.StringOutput)
}
type TableItemArrayOutput struct{ *pulumi.OutputState }
func (TableItemArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*TableItem)(nil)).Elem()
}
func (o TableItemArrayOutput) ToTableItemArrayOutput() TableItemArrayOutput {
return o
}
func (o TableItemArrayOutput) ToTableItemArrayOutputWithContext(ctx context.Context) TableItemArrayOutput {
return o
}
func (o TableItemArrayOutput) Index(i pulumi.IntInput) TableItemOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *TableItem {
return vs[0].([]*TableItem)[vs[1].(int)]
}).(TableItemOutput)
}
type TableItemMapOutput struct{ *pulumi.OutputState }
func (TableItemMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*TableItem)(nil)).Elem()
}
func (o TableItemMapOutput) ToTableItemMapOutput() TableItemMapOutput {
return o
}
func (o TableItemMapOutput) ToTableItemMapOutputWithContext(ctx context.Context) TableItemMapOutput {
return o
}
func (o TableItemMapOutput) MapIndex(k pulumi.StringInput) TableItemOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *TableItem {
return vs[0].(map[string]*TableItem)[vs[1].(string)]
}).(TableItemOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*TableItemInput)(nil)).Elem(), &TableItem{})
pulumi.RegisterInputType(reflect.TypeOf((*TableItemArrayInput)(nil)).Elem(), TableItemArray{})
pulumi.RegisterInputType(reflect.TypeOf((*TableItemMapInput)(nil)).Elem(), TableItemMap{})
pulumi.RegisterOutputType(TableItemOutput{})
pulumi.RegisterOutputType(TableItemArrayOutput{})
pulumi.RegisterOutputType(TableItemMapOutput{})
}