1. Packages
  2. AWS
  3. API Docs
  4. dynamodb
  5. TableItem
AWS v6.76.0 published on Tuesday, Apr 8, 2025 by Pulumi

aws.dynamodb.TableItem

Explore with Pulumi AI

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.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const exampleTable = new aws.dynamodb.Table("example", {
    name: "example-name",
    readCapacity: 10,
    writeCapacity: 10,
    hashKey: "exampleHashKey",
    attributes: [{
        name: "exampleHashKey",
        type: "S",
    }],
});
const example = new aws.dynamodb.TableItem("example", {
    tableName: exampleTable.name,
    hashKey: exampleTable.hashKey,
    item: `{
  "exampleHashKey": {"S": "something"},
  "one": {"N": "11111"},
  "two": {"N": "22222"},
  "three": {"N": "33333"},
  "four": {"N": "44444"}
}
`,
});
Copy
import pulumi
import pulumi_aws as aws

example_table = aws.dynamodb.Table("example",
    name="example-name",
    read_capacity=10,
    write_capacity=10,
    hash_key="exampleHashKey",
    attributes=[{
        "name": "exampleHashKey",
        "type": "S",
    }])
example = aws.dynamodb.TableItem("example",
    table_name=example_table.name,
    hash_key=example_table.hash_key,
    item="""{
  "exampleHashKey": {"S": "something"},
  "one": {"N": "11111"},
  "two": {"N": "22222"},
  "three": {"N": "33333"},
  "four": {"N": "44444"}
}
""")
Copy
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
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() => 
{
    var exampleTable = new Aws.DynamoDB.Table("example", new()
    {
        Name = "example-name",
        ReadCapacity = 10,
        WriteCapacity = 10,
        HashKey = "exampleHashKey",
        Attributes = new[]
        {
            new Aws.DynamoDB.Inputs.TableAttributeArgs
            {
                Name = "exampleHashKey",
                Type = "S",
            },
        },
    });

    var example = new Aws.DynamoDB.TableItem("example", new()
    {
        TableName = exampleTable.Name,
        HashKey = exampleTable.HashKey,
        Item = @"{
  ""exampleHashKey"": {""S"": ""something""},
  ""one"": {""N"": ""11111""},
  ""two"": {""N"": ""22222""},
  ""three"": {""N"": ""33333""},
  ""four"": {""N"": ""44444""}
}
",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.dynamodb.Table;
import com.pulumi.aws.dynamodb.TableArgs;
import com.pulumi.aws.dynamodb.inputs.TableAttributeArgs;
import com.pulumi.aws.dynamodb.TableItem;
import com.pulumi.aws.dynamodb.TableItemArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var exampleTable = new Table("exampleTable", TableArgs.builder()
            .name("example-name")
            .readCapacity(10)
            .writeCapacity(10)
            .hashKey("exampleHashKey")
            .attributes(TableAttributeArgs.builder()
                .name("exampleHashKey")
                .type("S")
                .build())
            .build());

        var example = new TableItem("example", TableItemArgs.builder()
            .tableName(exampleTable.name())
            .hashKey(exampleTable.hashKey())
            .item("""
{
  "exampleHashKey": {"S": "something"},
  "one": {"N": "11111"},
  "two": {"N": "22222"},
  "three": {"N": "33333"},
  "four": {"N": "44444"}
}
            """)
            .build());

    }
}
Copy
resources:
  example:
    type: aws:dynamodb:TableItem
    properties:
      tableName: ${exampleTable.name}
      hashKey: ${exampleTable.hashKey}
      item: |
        {
          "exampleHashKey": {"S": "something"},
          "one": {"N": "11111"},
          "two": {"N": "22222"},
          "three": {"N": "33333"},
          "four": {"N": "44444"}
        }        
  exampleTable:
    type: aws:dynamodb:Table
    name: example
    properties:
      name: example-name
      readCapacity: 10
      writeCapacity: 10
      hashKey: exampleHashKey
      attributes:
        - name: exampleHashKey
          type: S
Copy

Create TableItem Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new TableItem(name: string, args: TableItemArgs, opts?: CustomResourceOptions);
@overload
def TableItem(resource_name: str,
              args: TableItemArgs,
              opts: Optional[ResourceOptions] = None)

@overload
def TableItem(resource_name: str,
              opts: Optional[ResourceOptions] = None,
              hash_key: Optional[str] = None,
              item: Optional[str] = None,
              table_name: Optional[str] = None,
              range_key: Optional[str] = None)
func NewTableItem(ctx *Context, name string, args TableItemArgs, opts ...ResourceOption) (*TableItem, error)
public TableItem(string name, TableItemArgs args, CustomResourceOptions? opts = null)
public TableItem(String name, TableItemArgs args)
public TableItem(String name, TableItemArgs args, CustomResourceOptions options)
type: aws:dynamodb:TableItem
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. TableItemArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. TableItemArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. TableItemArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. TableItemArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. TableItemArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var tableItemResource = new Aws.DynamoDB.TableItem("tableItemResource", new()
{
    HashKey = "string",
    Item = "string",
    TableName = "string",
    RangeKey = "string",
});
Copy
example, err := dynamodb.NewTableItem(ctx, "tableItemResource", &dynamodb.TableItemArgs{
	HashKey:   pulumi.String("string"),
	Item:      pulumi.String("string"),
	TableName: pulumi.String("string"),
	RangeKey:  pulumi.String("string"),
})
Copy
var tableItemResource = new TableItem("tableItemResource", TableItemArgs.builder()
    .hashKey("string")
    .item("string")
    .tableName("string")
    .rangeKey("string")
    .build());
Copy
table_item_resource = aws.dynamodb.TableItem("tableItemResource",
    hash_key="string",
    item="string",
    table_name="string",
    range_key="string")
Copy
const tableItemResource = new aws.dynamodb.TableItem("tableItemResource", {
    hashKey: "string",
    item: "string",
    tableName: "string",
    rangeKey: "string",
});
Copy
type: aws:dynamodb:TableItem
properties:
    hashKey: string
    item: string
    rangeKey: string
    tableName: string
Copy

TableItem Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The TableItem resource accepts the following input properties:

HashKey
This property is required.
Changes to this property will trigger replacement.
string
Hash key to use for lookups and identification of the item
Item This property is required. string
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.
TableName
This property is required.
Changes to this property will trigger replacement.
string
Name of the table to contain the item.
RangeKey Changes to this property will trigger replacement. string
Range key to use for lookups and identification of the item. Required if there is range key defined in the table.
HashKey
This property is required.
Changes to this property will trigger replacement.
string
Hash key to use for lookups and identification of the item
Item This property is required. string
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.
TableName
This property is required.
Changes to this property will trigger replacement.
string
Name of the table to contain the item.
RangeKey Changes to this property will trigger replacement. string
Range key to use for lookups and identification of the item. Required if there is range key defined in the table.
hashKey
This property is required.
Changes to this property will trigger replacement.
String
Hash key to use for lookups and identification of the item
item This property is required. String
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.
tableName
This property is required.
Changes to this property will trigger replacement.
String
Name of the table to contain the item.
rangeKey Changes to this property will trigger replacement. String
Range key to use for lookups and identification of the item. Required if there is range key defined in the table.
hashKey
This property is required.
Changes to this property will trigger replacement.
string
Hash key to use for lookups and identification of the item
item This property is required. string
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.
tableName
This property is required.
Changes to this property will trigger replacement.
string
Name of the table to contain the item.
rangeKey Changes to this property will trigger replacement. string
Range key to use for lookups and identification of the item. Required if there is range key defined in the table.
hash_key
This property is required.
Changes to this property will trigger replacement.
str
Hash key to use for lookups and identification of the item
item This property is required. str
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.
table_name
This property is required.
Changes to this property will trigger replacement.
str
Name of the table to contain the item.
range_key Changes to this property will trigger replacement. str
Range key to use for lookups and identification of the item. Required if there is range key defined in the table.
hashKey
This property is required.
Changes to this property will trigger replacement.
String
Hash key to use for lookups and identification of the item
item This property is required. String
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.
tableName
This property is required.
Changes to this property will trigger replacement.
String
Name of the table to contain the item.
rangeKey Changes to this property will trigger replacement. String
Range key to use for lookups and identification of the item. Required if there is range key defined in the table.

Outputs

All input properties are implicitly available as output properties. Additionally, the TableItem resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
Id string
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.
id string
The provider-assigned unique ID for this managed resource.
id str
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.

Look up Existing TableItem Resource

Get an existing TableItem resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: TableItemState, opts?: CustomResourceOptions): TableItem
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        hash_key: Optional[str] = None,
        item: Optional[str] = None,
        range_key: Optional[str] = None,
        table_name: Optional[str] = None) -> TableItem
func GetTableItem(ctx *Context, name string, id IDInput, state *TableItemState, opts ...ResourceOption) (*TableItem, error)
public static TableItem Get(string name, Input<string> id, TableItemState? state, CustomResourceOptions? opts = null)
public static TableItem get(String name, Output<String> id, TableItemState state, CustomResourceOptions options)
resources:  _:    type: aws:dynamodb:TableItem    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
HashKey Changes to this property will trigger replacement. string
Hash key to use for lookups and identification of the item
Item string
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.
RangeKey Changes to this property will trigger replacement. string
Range key to use for lookups and identification of the item. Required if there is range key defined in the table.
TableName Changes to this property will trigger replacement. string
Name of the table to contain the item.
HashKey Changes to this property will trigger replacement. string
Hash key to use for lookups and identification of the item
Item string
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.
RangeKey Changes to this property will trigger replacement. string
Range key to use for lookups and identification of the item. Required if there is range key defined in the table.
TableName Changes to this property will trigger replacement. string
Name of the table to contain the item.
hashKey Changes to this property will trigger replacement. String
Hash key to use for lookups and identification of the item
item String
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.
rangeKey Changes to this property will trigger replacement. String
Range key to use for lookups and identification of the item. Required if there is range key defined in the table.
tableName Changes to this property will trigger replacement. String
Name of the table to contain the item.
hashKey Changes to this property will trigger replacement. string
Hash key to use for lookups and identification of the item
item string
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.
rangeKey Changes to this property will trigger replacement. string
Range key to use for lookups and identification of the item. Required if there is range key defined in the table.
tableName Changes to this property will trigger replacement. string
Name of the table to contain the item.
hash_key Changes to this property will trigger replacement. str
Hash key to use for lookups and identification of the item
item str
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.
range_key Changes to this property will trigger replacement. str
Range key to use for lookups and identification of the item. Required if there is range key defined in the table.
table_name Changes to this property will trigger replacement. str
Name of the table to contain the item.
hashKey Changes to this property will trigger replacement. String
Hash key to use for lookups and identification of the item
item String
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.
rangeKey Changes to this property will trigger replacement. String
Range key to use for lookups and identification of the item. Required if there is range key defined in the table.
tableName Changes to this property will trigger replacement. String
Name of the table to contain the item.

Import

You cannot import DynamoDB table items.

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
AWS Classic pulumi/pulumi-aws
License
Apache-2.0
Notes
This Pulumi package is based on the aws Terraform Provider.