Module dynamodb

This provider is a derived work of the Terraform Provider distributed under MPL 2.0. If you encounter a bug or missing feature, first check the pulumi/pulumi-aws repo; however, if that doesn’t turn up anything, please consult the source terraform-providers/terraform-provider-aws repo.

Resources

Data Sources

Others

Resources

Resource GlobalTable

class GlobalTable extends CustomResource

Provides a resource to manage a DynamoDB Global Table. These are layered on top of existing DynamoDB Tables.

Note: There are many restrictions before you can properly create DynamoDB Global Tables in multiple regions. See the AWS DynamoDB Global Table Requirements for more information.

Example Usage

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

const usEast1 = new aws.Provider("us-east-1", {
    region: "us-east-1",
});
const usWest2 = new aws.Provider("us-west-2", {
    region: "us-west-2",
});
const us_east_1Table = new aws.dynamodb.Table("us-east-1", {
    attributes: [{
        name: "myAttribute",
        type: "S",
    }],
    hashKey: "myAttribute",
    readCapacity: 1,
    streamEnabled: true,
    streamViewType: "NEW_AND_OLD_IMAGES",
    writeCapacity: 1,
}, {provider: us_east_1});
const us_west_2Table = new aws.dynamodb.Table("us-west-2", {
    attributes: [{
        name: "myAttribute",
        type: "S",
    }],
    hashKey: "myAttribute",
    readCapacity: 1,
    streamEnabled: true,
    streamViewType: "NEW_AND_OLD_IMAGES",
    writeCapacity: 1,
}, {provider: us_west_2});
const myTable = new aws.dynamodb.GlobalTable("myTable", {
    replicas: [
        {
            regionName: "us-east-1",
        },
        {
            regionName: "us-west-2",
        },
    ],
}, {provider: us_east_1,dependsOn: [us_east_1Table, us_west_2Table]});

This content is derived from https://github.com/terraform-providers/terraform-provider-aws/blob/master/website/docs/r/dynamodb_global_table.html.markdown.

constructor

new GlobalTable(name: string, args: GlobalTableArgs, opts?: pulumi.CustomResourceOptions)

Create a GlobalTable resource with the given unique name, arguments, and options.

  • name The unique name of the resource.
  • args The arguments to use to populate this resource's properties.
  • opts A bag of options that control this resource's behavior.

method get

public static get(name: string, id: pulumi.Input<pulumi.ID>, state?: GlobalTableState, opts?: pulumi.CustomResourceOptions): GlobalTable

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

method getProvider

getProvider(moduleMember: string): ProviderResource | undefined

method isInstance

public static isInstance(obj: any): boolean

Returns true if the given object is an instance of GlobalTable. This is designed to work even when multiple copies of the Pulumi SDK have been loaded into the same process.

property arn

public arn: pulumi.Output<string>;

The ARN of the DynamoDB Global Table

property id

id: Output<ID>;

id is the provider-assigned unique ID for this managed resource. It is set during deployments and may be missing (undefined) during planning phases.

property name

public name: pulumi.Output<string>;

The name of the global table. Must match underlying DynamoDB Table names in all regions.

property replicas

public replicas: pulumi.Output<outputs.dynamodb.GlobalTableReplica[]>;

Underlying DynamoDB Table. At least 1 replica must be defined. See below.

property urn

urn: Output<URN>;

urn is the stable logical URN used to distinctly address a resource, both before and after deployments.

Resource Table

class Table extends CustomResource

Provides a DynamoDB table resource

Note: It is recommended to use lifecycle ignoreChanges for readCapacity and/or writeCapacity if there’s autoscaling policy attached to the table.

Example Usage

The following dynamodb table description models the table and GSI shown in the AWS SDK example documentation

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

const basicDynamodbTable = new aws.dynamodb.Table("basic-dynamodb-table", {
    attributes: [
        {
            name: "UserId",
            type: "S",
        },
        {
            name: "GameTitle",
            type: "S",
        },
        {
            name: "TopScore",
            type: "N",
        },
    ],
    billingMode: "PROVISIONED",
    globalSecondaryIndexes: [{
        hashKey: "GameTitle",
        name: "GameTitleIndex",
        nonKeyAttributes: ["UserId"],
        projectionType: "INCLUDE",
        rangeKey: "TopScore",
        readCapacity: 10,
        writeCapacity: 10,
    }],
    hashKey: "UserId",
    rangeKey: "GameTitle",
    readCapacity: 20,
    tags: {
        Environment: "production",
        Name: "dynamodb-table-1",
    },
    ttl: {
        attributeName: "TimeToExist",
        enabled: false,
    },
    writeCapacity: 20,
});

This content is derived from https://github.com/terraform-providers/terraform-provider-aws/blob/master/website/docs/r/dynamodb_table.html.markdown.

constructor

new Table(name: string, args: TableArgs, opts?: pulumi.CustomResourceOptions)

Create a Table resource with the given unique name, arguments, and options.

  • name The unique name of the resource.
  • args The arguments to use to populate this resource's properties.
  • opts A bag of options that control this resource's behavior.

method get

public static get(name: string, id: pulumi.Input<pulumi.ID>, state?: TableState, opts?: pulumi.CustomResourceOptions): Table

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

method getProvider

getProvider(moduleMember: string): ProviderResource | undefined

method isInstance

public static isInstance(obj: any): boolean

Returns true if the given object is an instance of Table. This is designed to work even when multiple copies of the Pulumi SDK have been loaded into the same process.

method onEvent

onEvent(name: string, handler: TableEventHandler, args: TableEventSubscriptionArgs, opts?: pulumi.ComponentResourceOptions): TableEventSubscription

Creates a new subscription to events fired from this Table to the handler provided, along with options to control the behavior of the subscription.

In order to receive events the [Table] must have been created with the streamEnabled: true value as well as an appropriate streamViewType.

property arn

public arn: pulumi.Output<string>;

The arn of the table

property attributes

public attributes: pulumi.Output<outputs.dynamodb.TableAttribute[]>;

List of nested attribute definitions. Only required for hashKey and rangeKey attributes. Each attribute has two properties:

property billingMode

public billingMode: pulumi.Output<string | undefined>;

Controls how you are charged for read and write throughput and how you manage capacity. The valid values are PROVISIONED and PAY_PER_REQUEST. Defaults to PROVISIONED.

property globalSecondaryIndexes

public globalSecondaryIndexes: pulumi.Output<outputs.dynamodb.TableGlobalSecondaryIndex[] | undefined>;

Describe a GSI for the table; subject to the normal limits on the number of GSIs, projected attributes, etc.

property hashKey

public hashKey: pulumi.Output<string>;

The name of the hash key in the index; must be defined as an attribute in the resource.

property id

id: Output<ID>;

id is the provider-assigned unique ID for this managed resource. It is set during deployments and may be missing (undefined) during planning phases.

property localSecondaryIndexes

public localSecondaryIndexes: pulumi.Output<outputs.dynamodb.TableLocalSecondaryIndex[] | undefined>;

Describe an LSI on the table; these can only be allocated at creation so you cannot change this definition after you have created the resource.

property name

public name: pulumi.Output<string>;

The name of the index

property pointInTimeRecovery

public pointInTimeRecovery: pulumi.Output<outputs.dynamodb.TablePointInTimeRecovery>;

Point-in-time recovery options.

property rangeKey

public rangeKey: pulumi.Output<string | undefined>;

The name of the range key; must be defined

property readCapacity

public readCapacity: pulumi.Output<number | undefined>;

The number of read units for this index. Must be set if billingMode is set to PROVISIONED.

property serverSideEncryption

public serverSideEncryption: pulumi.Output<outputs.dynamodb.TableServerSideEncryption>;

Encryption at rest options. AWS DynamoDB tables are automatically encrypted at rest with an AWS owned Customer Master Key if this argument isn’t specified.

property streamArn

public streamArn: pulumi.Output<string>;

The ARN of the Table Stream. Only available when streamEnabled = true

property streamEnabled

public streamEnabled: pulumi.Output<boolean | undefined>;

Indicates whether Streams are to be enabled (true) or disabled (false).

property streamLabel

public streamLabel: pulumi.Output<string>;

A timestamp, in ISO 8601 format, for this stream. Note that this timestamp is not a unique identifier for the stream on its own. However, the combination of AWS customer ID, table name and this field is guaranteed to be unique. It can be used for creating CloudWatch Alarms. Only available when streamEnabled = true

property streamViewType

public streamViewType: pulumi.Output<string>;

When an item in the table is modified, StreamViewType determines what information is written to the table’s stream. Valid values are KEYS_ONLY, NEW_IMAGE, OLD_IMAGE, NEW_AND_OLD_IMAGES.

property tags

public tags: pulumi.Output<{[key: string]: any} | undefined>;

A map of tags to populate on the created table.

property ttl

public ttl: pulumi.Output<outputs.dynamodb.TableTtl | undefined>;

Defines ttl, has two properties, and can only be specified once:

property urn

urn: Output<URN>;

urn is the stable logical URN used to distinctly address a resource, both before and after deployments.

property writeCapacity

public writeCapacity: pulumi.Output<number | undefined>;

The number of write units for this index. Must be set if billingMode is set to PROVISIONED.

Resource TableItem

class TableItem extends CustomResource

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", {
    attributes: [{
        name: "exampleHashKey",
        type: "S",
    }],
    hashKey: "exampleHashKey",
    readCapacity: 10,
    writeCapacity: 10,
});
const exampleTableItem = new aws.dynamodb.TableItem("example", {
    hashKey: exampleTable.hashKey,
    item: `{
  "exampleHashKey": {"S": "something"},
  "one": {"N": "11111"},
  "two": {"N": "22222"},
  "three": {"N": "33333"},
  "four": {"N": "44444"}
}
`,
    tableName: exampleTable.name,
});

This content is derived from https://github.com/terraform-providers/terraform-provider-aws/blob/master/website/docs/r/dynamodb_table_item.html.markdown.

constructor

new TableItem(name: string, args: TableItemArgs, opts?: pulumi.CustomResourceOptions)

Create a TableItem resource with the given unique name, arguments, and options.

  • name The unique name of the resource.
  • args The arguments to use to populate this resource's properties.
  • opts A bag of options that control this resource's behavior.

method get

public static get(name: string, id: pulumi.Input<pulumi.ID>, state?: TableItemState, opts?: pulumi.CustomResourceOptions): TableItem

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

method getProvider

getProvider(moduleMember: string): ProviderResource | undefined

method isInstance

public static isInstance(obj: any): boolean

Returns true if the given object is an instance of TableItem. This is designed to work even when multiple copies of the Pulumi SDK have been loaded into the same process.

property hashKey

public hashKey: pulumi.Output<string>;

Hash key to use for lookups and identification of the item

property id

id: Output<ID>;

id is the provider-assigned unique ID for this managed resource. It is set during deployments and may be missing (undefined) during planning phases.

property item

public item: pulumi.Output<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.

property rangeKey

public rangeKey: pulumi.Output<string | undefined>;

Range key to use for lookups and identification of the item. Required if there is range key defined in the table.

property tableName

public tableName: pulumi.Output<string>;

The name of the table to contain the item.

property urn

urn: Output<URN>;

urn is the stable logical URN used to distinctly address a resource, both before and after deployments.

Data Sources

Data Source getTable

getTable(args: GetTableArgs, opts?: pulumi.InvokeOptions): Promise<GetTableResult> & GetTableResult

Provides information about a DynamoDB table.

Example Usage

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

const tableName = aws.dynamodb.getTable({
    name: "tableName",
});

This content is derived from https://github.com/terraform-providers/terraform-provider-aws/blob/master/website/docs/d/dynamodb_table.html.markdown.

Others

interface GetTableArgs

interface GetTableArgs

A collection of arguments for invoking getTable.

property name

name: string;

The name of the DynamoDB table.

property serverSideEncryption

serverSideEncryption?: inputs.dynamodb.GetTableServerSideEncryption;

property tags

tags?: undefined | {[key: string]: any};

interface GetTableResult

interface GetTableResult

A collection of values returned by getTable.

property arn

arn: string;

property attributes

attributes: outputs.dynamodb.GetTableAttribute[];

property billingMode

billingMode: string;

property globalSecondaryIndexes

globalSecondaryIndexes: outputs.dynamodb.GetTableGlobalSecondaryIndex[];

property hashKey

hashKey: string;

property id

id: string;

id is the provider-assigned unique ID for this managed resource.

property localSecondaryIndexes

localSecondaryIndexes: outputs.dynamodb.GetTableLocalSecondaryIndex[];

property name

name: string;

property pointInTimeRecovery

pointInTimeRecovery: outputs.dynamodb.GetTablePointInTimeRecovery;

property rangeKey

rangeKey: string;

property readCapacity

readCapacity: number;

property serverSideEncryption

serverSideEncryption: outputs.dynamodb.GetTableServerSideEncryption;

property streamArn

streamArn: string;

property streamEnabled

streamEnabled: boolean;

property streamLabel

streamLabel: string;

property streamViewType

streamViewType: string;

property tags

tags: {[key: string]: any};

property ttl

ttl: outputs.dynamodb.GetTableTtl;

property writeCapacity

writeCapacity: number;

interface GlobalTableArgs

interface GlobalTableArgs

The set of arguments for constructing a GlobalTable resource.

property name

name?: pulumi.Input<string>;

The name of the global table. Must match underlying DynamoDB Table names in all regions.

property replicas

replicas: pulumi.Input<pulumi.Input<inputs.dynamodb.GlobalTableReplica>[]>;

Underlying DynamoDB Table. At least 1 replica must be defined. See below.

interface GlobalTableState

interface GlobalTableState

Input properties used for looking up and filtering GlobalTable resources.

property arn

arn?: pulumi.Input<string>;

The ARN of the DynamoDB Global Table

property name

name?: pulumi.Input<string>;

The name of the global table. Must match underlying DynamoDB Table names in all regions.

property replicas

replicas?: pulumi.Input<pulumi.Input<inputs.dynamodb.GlobalTableReplica>[]>;

Underlying DynamoDB Table. At least 1 replica must be defined. See below.

interface TableArgs

interface TableArgs

The set of arguments for constructing a Table resource.

property attributes

attributes: pulumi.Input<pulumi.Input<inputs.dynamodb.TableAttribute>[]>;

List of nested attribute definitions. Only required for hashKey and rangeKey attributes. Each attribute has two properties:

property billingMode

billingMode?: pulumi.Input<string>;

Controls how you are charged for read and write throughput and how you manage capacity. The valid values are PROVISIONED and PAY_PER_REQUEST. Defaults to PROVISIONED.

property globalSecondaryIndexes

globalSecondaryIndexes?: pulumi.Input<pulumi.Input<inputs.dynamodb.TableGlobalSecondaryIndex>[]>;

Describe a GSI for the table; subject to the normal limits on the number of GSIs, projected attributes, etc.

property hashKey

hashKey: pulumi.Input<string>;

The name of the hash key in the index; must be defined as an attribute in the resource.

property localSecondaryIndexes

localSecondaryIndexes?: pulumi.Input<pulumi.Input<inputs.dynamodb.TableLocalSecondaryIndex>[]>;

Describe an LSI on the table; these can only be allocated at creation so you cannot change this definition after you have created the resource.

property name

name?: pulumi.Input<string>;

The name of the index

property pointInTimeRecovery

pointInTimeRecovery?: pulumi.Input<inputs.dynamodb.TablePointInTimeRecovery>;

Point-in-time recovery options.

property rangeKey

rangeKey?: pulumi.Input<string>;

The name of the range key; must be defined

property readCapacity

readCapacity?: pulumi.Input<number>;

The number of read units for this index. Must be set if billingMode is set to PROVISIONED.

property serverSideEncryption

serverSideEncryption?: pulumi.Input<inputs.dynamodb.TableServerSideEncryption>;

Encryption at rest options. AWS DynamoDB tables are automatically encrypted at rest with an AWS owned Customer Master Key if this argument isn’t specified.

property streamEnabled

streamEnabled?: pulumi.Input<boolean>;

Indicates whether Streams are to be enabled (true) or disabled (false).

property streamViewType

streamViewType?: pulumi.Input<string>;

When an item in the table is modified, StreamViewType determines what information is written to the table’s stream. Valid values are KEYS_ONLY, NEW_IMAGE, OLD_IMAGE, NEW_AND_OLD_IMAGES.

property tags

tags?: pulumi.Input<{[key: string]: any}>;

A map of tags to populate on the created table.

property ttl

ttl?: pulumi.Input<inputs.dynamodb.TableTtl>;

Defines ttl, has two properties, and can only be specified once:

property writeCapacity

writeCapacity?: pulumi.Input<number>;

The number of write units for this index. Must be set if billingMode is set to PROVISIONED.

interface TableEvent

interface TableEvent

property Records

Records: TableEventRecord[];

type TableEventHandler

type TableEventHandler = lambda.EventHandler<TableEvent, void>;

interface TableEventRecord

interface TableEventRecord

property awsRegion

awsRegion: string;

property dynamodb

dynamodb: {
    ApproximateCreationDateTime: number;
    Keys: Record<string, any>;
    NewImage: Record<string, any>;
    OldImage: Record<string, any>;
    SequenceNumber: string;
    SizeBytes: number;
    StreamViewType: string;
};

property eventID

eventID: string;

property eventName

eventName: "INSERT" | "MODIFY" | "REMOVE";

property eventSource

eventSource: string;

property eventVersion

eventVersion: string;

property userIdentity

userIdentity: {
    PrincipalId: string;
    Type: string;
};

class TableEventSubscription

class TableEventSubscription extends EventSubscription

constructor

new TableEventSubscription(name: string, table: table.Table, handler: TableEventHandler, args: TableEventSubscriptionArgs, opts: pulumi.ComponentResourceOptions)

method getProvider

getProvider(moduleMember: string): ProviderResource | undefined

method isInstance

static isInstance(obj: any): boolean

Returns true if the given object is an instance of CustomResource. This is designed to work even when multiple copies of the Pulumi SDK have been loaded into the same process.

method registerOutputs

protected registerOutputs(outputs?: Inputs | Promise<Inputs> | Output<Inputs>): void

property eventSourceMapping

public eventSourceMapping: lambda.EventSourceMapping;

property func

public func: LambdaFunction;

property permission

public permission: permission.Permission;

property table

public table: table.Table;

property urn

urn: Output<URN>;

urn is the stable logical URN used to distinctly address a resource, both before and after deployments.

interface TableEventSubscriptionArgs

interface TableEventSubscriptionArgs

Arguments to control the event rule subscription. Currently empty, but still defined in case of future need.

property batchSize

batchSize?: undefined | number;

The largest number of records that Lambda will retrieve from your event source at the time of invocation. Defaults to 100 for DynamoDB.

property startingPosition

startingPosition: "TRIM_HORIZON" | "LATEST";

The position in the stream where AWS Lambda should start reading. Must be one of either TRIM_HORIZON or LATEST.

interface TableItemArgs

interface TableItemArgs

The set of arguments for constructing a TableItem resource.

property hashKey

hashKey: pulumi.Input<string>;

Hash key to use for lookups and identification of the item

property item

item: pulumi.Input<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.

property rangeKey

rangeKey?: pulumi.Input<string>;

Range key to use for lookups and identification of the item. Required if there is range key defined in the table.

property tableName

tableName: pulumi.Input<string>;

The name of the table to contain the item.

interface TableItemState

interface TableItemState

Input properties used for looking up and filtering TableItem resources.

property hashKey

hashKey?: pulumi.Input<string>;

Hash key to use for lookups and identification of the item

property item

item?: pulumi.Input<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.

property rangeKey

rangeKey?: pulumi.Input<string>;

Range key to use for lookups and identification of the item. Required if there is range key defined in the table.

property tableName

tableName?: pulumi.Input<string>;

The name of the table to contain the item.

interface TableState

interface TableState

Input properties used for looking up and filtering Table resources.

property arn

arn?: pulumi.Input<string>;

The arn of the table

property attributes

attributes?: pulumi.Input<pulumi.Input<inputs.dynamodb.TableAttribute>[]>;

List of nested attribute definitions. Only required for hashKey and rangeKey attributes. Each attribute has two properties:

property billingMode

billingMode?: pulumi.Input<string>;

Controls how you are charged for read and write throughput and how you manage capacity. The valid values are PROVISIONED and PAY_PER_REQUEST. Defaults to PROVISIONED.

property globalSecondaryIndexes

globalSecondaryIndexes?: pulumi.Input<pulumi.Input<inputs.dynamodb.TableGlobalSecondaryIndex>[]>;

Describe a GSI for the table; subject to the normal limits on the number of GSIs, projected attributes, etc.

property hashKey

hashKey?: pulumi.Input<string>;

The name of the hash key in the index; must be defined as an attribute in the resource.

property localSecondaryIndexes

localSecondaryIndexes?: pulumi.Input<pulumi.Input<inputs.dynamodb.TableLocalSecondaryIndex>[]>;

Describe an LSI on the table; these can only be allocated at creation so you cannot change this definition after you have created the resource.

property name

name?: pulumi.Input<string>;

The name of the index

property pointInTimeRecovery

pointInTimeRecovery?: pulumi.Input<inputs.dynamodb.TablePointInTimeRecovery>;

Point-in-time recovery options.

property rangeKey

rangeKey?: pulumi.Input<string>;

The name of the range key; must be defined

property readCapacity

readCapacity?: pulumi.Input<number>;

The number of read units for this index. Must be set if billingMode is set to PROVISIONED.

property serverSideEncryption

serverSideEncryption?: pulumi.Input<inputs.dynamodb.TableServerSideEncryption>;

Encryption at rest options. AWS DynamoDB tables are automatically encrypted at rest with an AWS owned Customer Master Key if this argument isn’t specified.

property streamArn

streamArn?: pulumi.Input<string>;

The ARN of the Table Stream. Only available when streamEnabled = true

property streamEnabled

streamEnabled?: pulumi.Input<boolean>;

Indicates whether Streams are to be enabled (true) or disabled (false).

property streamLabel

streamLabel?: pulumi.Input<string>;

A timestamp, in ISO 8601 format, for this stream. Note that this timestamp is not a unique identifier for the stream on its own. However, the combination of AWS customer ID, table name and this field is guaranteed to be unique. It can be used for creating CloudWatch Alarms. Only available when streamEnabled = true

property streamViewType

streamViewType?: pulumi.Input<string>;

When an item in the table is modified, StreamViewType determines what information is written to the table’s stream. Valid values are KEYS_ONLY, NEW_IMAGE, OLD_IMAGE, NEW_AND_OLD_IMAGES.

property tags

tags?: pulumi.Input<{[key: string]: any}>;

A map of tags to populate on the created table.

property ttl

ttl?: pulumi.Input<inputs.dynamodb.TableTtl>;

Defines ttl, has two properties, and can only be specified once:

property writeCapacity

writeCapacity?: pulumi.Input<number>;

The number of write units for this index. Must be set if billingMode is set to PROVISIONED.