github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/dynamodb/tableItem.go (about)

     1  // Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT.
     2  // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
     3  
     4  package dynamodb
     5  
     6  import (
     7  	"context"
     8  	"reflect"
     9  
    10  	"errors"
    11  	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal"
    12  	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    13  )
    14  
    15  // Provides a DynamoDB table item resource
    16  //
    17  // > **Note:** This resource is not meant to be used for managing large amounts of data in your table, it is not designed to scale.
    18  //
    19  //	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).
    20  //
    21  // ## Example Usage
    22  //
    23  // <!--Start PulumiCodeChooser -->
    24  // ```go
    25  // package main
    26  //
    27  // import (
    28  //
    29  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/dynamodb"
    30  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    31  //
    32  // )
    33  //
    34  //	func main() {
    35  //		pulumi.Run(func(ctx *pulumi.Context) error {
    36  //			exampleTable, err := dynamodb.NewTable(ctx, "example", &dynamodb.TableArgs{
    37  //				Name:          pulumi.String("example-name"),
    38  //				ReadCapacity:  pulumi.Int(10),
    39  //				WriteCapacity: pulumi.Int(10),
    40  //				HashKey:       pulumi.String("exampleHashKey"),
    41  //				Attributes: dynamodb.TableAttributeArray{
    42  //					&dynamodb.TableAttributeArgs{
    43  //						Name: pulumi.String("exampleHashKey"),
    44  //						Type: pulumi.String("S"),
    45  //					},
    46  //				},
    47  //			})
    48  //			if err != nil {
    49  //				return err
    50  //			}
    51  //			_, err = dynamodb.NewTableItem(ctx, "example", &dynamodb.TableItemArgs{
    52  //				TableName: exampleTable.Name,
    53  //				HashKey:   exampleTable.HashKey,
    54  //				Item: pulumi.String(`{
    55  //	  "exampleHashKey": {"S": "something"},
    56  //	  "one": {"N": "11111"},
    57  //	  "two": {"N": "22222"},
    58  //	  "three": {"N": "33333"},
    59  //	  "four": {"N": "44444"}
    60  //	}
    61  //
    62  // `),
    63  //
    64  //			})
    65  //			if err != nil {
    66  //				return err
    67  //			}
    68  //			return nil
    69  //		})
    70  //	}
    71  //
    72  // ```
    73  // <!--End PulumiCodeChooser -->
    74  //
    75  // ## Import
    76  //
    77  // You cannot import DynamoDB table items.
    78  type TableItem struct {
    79  	pulumi.CustomResourceState
    80  
    81  	// Hash key to use for lookups and identification of the item
    82  	HashKey pulumi.StringOutput `pulumi:"hashKey"`
    83  	// 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.
    84  	Item pulumi.StringOutput `pulumi:"item"`
    85  	// Range key to use for lookups and identification of the item. Required if there is range key defined in the table.
    86  	RangeKey pulumi.StringPtrOutput `pulumi:"rangeKey"`
    87  	// Name of the table to contain the item.
    88  	TableName pulumi.StringOutput `pulumi:"tableName"`
    89  }
    90  
    91  // NewTableItem registers a new resource with the given unique name, arguments, and options.
    92  func NewTableItem(ctx *pulumi.Context,
    93  	name string, args *TableItemArgs, opts ...pulumi.ResourceOption) (*TableItem, error) {
    94  	if args == nil {
    95  		return nil, errors.New("missing one or more required arguments")
    96  	}
    97  
    98  	if args.HashKey == nil {
    99  		return nil, errors.New("invalid value for required argument 'HashKey'")
   100  	}
   101  	if args.Item == nil {
   102  		return nil, errors.New("invalid value for required argument 'Item'")
   103  	}
   104  	if args.TableName == nil {
   105  		return nil, errors.New("invalid value for required argument 'TableName'")
   106  	}
   107  	opts = internal.PkgResourceDefaultOpts(opts)
   108  	var resource TableItem
   109  	err := ctx.RegisterResource("aws:dynamodb/tableItem:TableItem", name, args, &resource, opts...)
   110  	if err != nil {
   111  		return nil, err
   112  	}
   113  	return &resource, nil
   114  }
   115  
   116  // GetTableItem gets an existing TableItem resource's state with the given name, ID, and optional
   117  // state properties that are used to uniquely qualify the lookup (nil if not required).
   118  func GetTableItem(ctx *pulumi.Context,
   119  	name string, id pulumi.IDInput, state *TableItemState, opts ...pulumi.ResourceOption) (*TableItem, error) {
   120  	var resource TableItem
   121  	err := ctx.ReadResource("aws:dynamodb/tableItem:TableItem", name, id, state, &resource, opts...)
   122  	if err != nil {
   123  		return nil, err
   124  	}
   125  	return &resource, nil
   126  }
   127  
   128  // Input properties used for looking up and filtering TableItem resources.
   129  type tableItemState struct {
   130  	// Hash key to use for lookups and identification of the item
   131  	HashKey *string `pulumi:"hashKey"`
   132  	// 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.
   133  	Item *string `pulumi:"item"`
   134  	// Range key to use for lookups and identification of the item. Required if there is range key defined in the table.
   135  	RangeKey *string `pulumi:"rangeKey"`
   136  	// Name of the table to contain the item.
   137  	TableName *string `pulumi:"tableName"`
   138  }
   139  
   140  type TableItemState struct {
   141  	// Hash key to use for lookups and identification of the item
   142  	HashKey pulumi.StringPtrInput
   143  	// 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.
   144  	Item pulumi.StringPtrInput
   145  	// Range key to use for lookups and identification of the item. Required if there is range key defined in the table.
   146  	RangeKey pulumi.StringPtrInput
   147  	// Name of the table to contain the item.
   148  	TableName pulumi.StringPtrInput
   149  }
   150  
   151  func (TableItemState) ElementType() reflect.Type {
   152  	return reflect.TypeOf((*tableItemState)(nil)).Elem()
   153  }
   154  
   155  type tableItemArgs struct {
   156  	// Hash key to use for lookups and identification of the item
   157  	HashKey string `pulumi:"hashKey"`
   158  	// 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.
   159  	Item string `pulumi:"item"`
   160  	// Range key to use for lookups and identification of the item. Required if there is range key defined in the table.
   161  	RangeKey *string `pulumi:"rangeKey"`
   162  	// Name of the table to contain the item.
   163  	TableName string `pulumi:"tableName"`
   164  }
   165  
   166  // The set of arguments for constructing a TableItem resource.
   167  type TableItemArgs struct {
   168  	// Hash key to use for lookups and identification of the item
   169  	HashKey pulumi.StringInput
   170  	// 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.
   171  	Item pulumi.StringInput
   172  	// Range key to use for lookups and identification of the item. Required if there is range key defined in the table.
   173  	RangeKey pulumi.StringPtrInput
   174  	// Name of the table to contain the item.
   175  	TableName pulumi.StringInput
   176  }
   177  
   178  func (TableItemArgs) ElementType() reflect.Type {
   179  	return reflect.TypeOf((*tableItemArgs)(nil)).Elem()
   180  }
   181  
   182  type TableItemInput interface {
   183  	pulumi.Input
   184  
   185  	ToTableItemOutput() TableItemOutput
   186  	ToTableItemOutputWithContext(ctx context.Context) TableItemOutput
   187  }
   188  
   189  func (*TableItem) ElementType() reflect.Type {
   190  	return reflect.TypeOf((**TableItem)(nil)).Elem()
   191  }
   192  
   193  func (i *TableItem) ToTableItemOutput() TableItemOutput {
   194  	return i.ToTableItemOutputWithContext(context.Background())
   195  }
   196  
   197  func (i *TableItem) ToTableItemOutputWithContext(ctx context.Context) TableItemOutput {
   198  	return pulumi.ToOutputWithContext(ctx, i).(TableItemOutput)
   199  }
   200  
   201  // TableItemArrayInput is an input type that accepts TableItemArray and TableItemArrayOutput values.
   202  // You can construct a concrete instance of `TableItemArrayInput` via:
   203  //
   204  //	TableItemArray{ TableItemArgs{...} }
   205  type TableItemArrayInput interface {
   206  	pulumi.Input
   207  
   208  	ToTableItemArrayOutput() TableItemArrayOutput
   209  	ToTableItemArrayOutputWithContext(context.Context) TableItemArrayOutput
   210  }
   211  
   212  type TableItemArray []TableItemInput
   213  
   214  func (TableItemArray) ElementType() reflect.Type {
   215  	return reflect.TypeOf((*[]*TableItem)(nil)).Elem()
   216  }
   217  
   218  func (i TableItemArray) ToTableItemArrayOutput() TableItemArrayOutput {
   219  	return i.ToTableItemArrayOutputWithContext(context.Background())
   220  }
   221  
   222  func (i TableItemArray) ToTableItemArrayOutputWithContext(ctx context.Context) TableItemArrayOutput {
   223  	return pulumi.ToOutputWithContext(ctx, i).(TableItemArrayOutput)
   224  }
   225  
   226  // TableItemMapInput is an input type that accepts TableItemMap and TableItemMapOutput values.
   227  // You can construct a concrete instance of `TableItemMapInput` via:
   228  //
   229  //	TableItemMap{ "key": TableItemArgs{...} }
   230  type TableItemMapInput interface {
   231  	pulumi.Input
   232  
   233  	ToTableItemMapOutput() TableItemMapOutput
   234  	ToTableItemMapOutputWithContext(context.Context) TableItemMapOutput
   235  }
   236  
   237  type TableItemMap map[string]TableItemInput
   238  
   239  func (TableItemMap) ElementType() reflect.Type {
   240  	return reflect.TypeOf((*map[string]*TableItem)(nil)).Elem()
   241  }
   242  
   243  func (i TableItemMap) ToTableItemMapOutput() TableItemMapOutput {
   244  	return i.ToTableItemMapOutputWithContext(context.Background())
   245  }
   246  
   247  func (i TableItemMap) ToTableItemMapOutputWithContext(ctx context.Context) TableItemMapOutput {
   248  	return pulumi.ToOutputWithContext(ctx, i).(TableItemMapOutput)
   249  }
   250  
   251  type TableItemOutput struct{ *pulumi.OutputState }
   252  
   253  func (TableItemOutput) ElementType() reflect.Type {
   254  	return reflect.TypeOf((**TableItem)(nil)).Elem()
   255  }
   256  
   257  func (o TableItemOutput) ToTableItemOutput() TableItemOutput {
   258  	return o
   259  }
   260  
   261  func (o TableItemOutput) ToTableItemOutputWithContext(ctx context.Context) TableItemOutput {
   262  	return o
   263  }
   264  
   265  // Hash key to use for lookups and identification of the item
   266  func (o TableItemOutput) HashKey() pulumi.StringOutput {
   267  	return o.ApplyT(func(v *TableItem) pulumi.StringOutput { return v.HashKey }).(pulumi.StringOutput)
   268  }
   269  
   270  // 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.
   271  func (o TableItemOutput) Item() pulumi.StringOutput {
   272  	return o.ApplyT(func(v *TableItem) pulumi.StringOutput { return v.Item }).(pulumi.StringOutput)
   273  }
   274  
   275  // Range key to use for lookups and identification of the item. Required if there is range key defined in the table.
   276  func (o TableItemOutput) RangeKey() pulumi.StringPtrOutput {
   277  	return o.ApplyT(func(v *TableItem) pulumi.StringPtrOutput { return v.RangeKey }).(pulumi.StringPtrOutput)
   278  }
   279  
   280  // Name of the table to contain the item.
   281  func (o TableItemOutput) TableName() pulumi.StringOutput {
   282  	return o.ApplyT(func(v *TableItem) pulumi.StringOutput { return v.TableName }).(pulumi.StringOutput)
   283  }
   284  
   285  type TableItemArrayOutput struct{ *pulumi.OutputState }
   286  
   287  func (TableItemArrayOutput) ElementType() reflect.Type {
   288  	return reflect.TypeOf((*[]*TableItem)(nil)).Elem()
   289  }
   290  
   291  func (o TableItemArrayOutput) ToTableItemArrayOutput() TableItemArrayOutput {
   292  	return o
   293  }
   294  
   295  func (o TableItemArrayOutput) ToTableItemArrayOutputWithContext(ctx context.Context) TableItemArrayOutput {
   296  	return o
   297  }
   298  
   299  func (o TableItemArrayOutput) Index(i pulumi.IntInput) TableItemOutput {
   300  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *TableItem {
   301  		return vs[0].([]*TableItem)[vs[1].(int)]
   302  	}).(TableItemOutput)
   303  }
   304  
   305  type TableItemMapOutput struct{ *pulumi.OutputState }
   306  
   307  func (TableItemMapOutput) ElementType() reflect.Type {
   308  	return reflect.TypeOf((*map[string]*TableItem)(nil)).Elem()
   309  }
   310  
   311  func (o TableItemMapOutput) ToTableItemMapOutput() TableItemMapOutput {
   312  	return o
   313  }
   314  
   315  func (o TableItemMapOutput) ToTableItemMapOutputWithContext(ctx context.Context) TableItemMapOutput {
   316  	return o
   317  }
   318  
   319  func (o TableItemMapOutput) MapIndex(k pulumi.StringInput) TableItemOutput {
   320  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *TableItem {
   321  		return vs[0].(map[string]*TableItem)[vs[1].(string)]
   322  	}).(TableItemOutput)
   323  }
   324  
   325  func init() {
   326  	pulumi.RegisterInputType(reflect.TypeOf((*TableItemInput)(nil)).Elem(), &TableItem{})
   327  	pulumi.RegisterInputType(reflect.TypeOf((*TableItemArrayInput)(nil)).Elem(), TableItemArray{})
   328  	pulumi.RegisterInputType(reflect.TypeOf((*TableItemMapInput)(nil)).Elem(), TableItemMap{})
   329  	pulumi.RegisterOutputType(TableItemOutput{})
   330  	pulumi.RegisterOutputType(TableItemArrayOutput{})
   331  	pulumi.RegisterOutputType(TableItemMapOutput{})
   332  }