TableArgs

data class TableArgs(val attributes: Output<List<TableAttributeArgs>>? = null, val billingMode: Output<String>? = null, val deletionProtectionEnabled: Output<Boolean>? = null, val globalSecondaryIndexes: Output<List<TableGlobalSecondaryIndexArgs>>? = null, val hashKey: Output<String>? = null, val localSecondaryIndexes: Output<List<TableLocalSecondaryIndexArgs>>? = null, val name: Output<String>? = null, val pointInTimeRecovery: Output<TablePointInTimeRecoveryArgs>? = null, val rangeKey: Output<String>? = null, val readCapacity: Output<Int>? = null, val replicas: Output<List<TableReplicaArgs>>? = null, val restoreDateTime: Output<String>? = null, val restoreSourceName: Output<String>? = null, val restoreToLatestTime: Output<Boolean>? = null, val serverSideEncryption: Output<TableServerSideEncryptionArgs>? = null, val streamEnabled: Output<Boolean>? = null, val streamViewType: Output<String>? = null, val tableClass: Output<String>? = null, val tags: Output<Map<String, String>>? = null, val ttl: Output<TableTtlArgs>? = null, val writeCapacity: Output<Int>? = null) : ConvertibleToJava<TableArgs>

Provides a DynamoDB table resource.

Note: It is recommended to use ignoreChanges for read_capacity and/or write_capacity if there's autoscaling policy attached to the table. Note: When using aws.dynamodb.TableReplica with this resource, use lifecycle ignore_changes for replica, e.g., lifecycle { ignore_changes = [replica] }.

DynamoDB Table attributes

Only define attributes on the table object that are going to be used as:

  • Table hash key or range key

  • LSI or GSI hash key or range key The DynamoDB API expects attribute structure (name and type) to be passed along when creating or updating GSI/LSIs or creating the initial table. In these cases it expects the Hash / Range keys to be provided. Because these get re-used in numerous places (i.e the table's range key could be a part of one or more GSIs), they are stored on the table object to prevent duplication and increase consistency. If you add attributes here that are not used in these scenarios it can cause an infinite loop in planning.

Example Usage

Basic Example

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

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.inputs.TableGlobalSecondaryIndexArgs;
import com.pulumi.aws.dynamodb.inputs.TableTtlArgs;
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 basic_dynamodb_table = new Table("basic-dynamodb-table", TableArgs.builder()
.attributes(
TableAttributeArgs.builder()
.name("UserId")
.type("S")
.build(),
TableAttributeArgs.builder()
.name("GameTitle")
.type("S")
.build(),
TableAttributeArgs.builder()
.name("TopScore")
.type("N")
.build())
.billingMode("PROVISIONED")
.globalSecondaryIndexes(TableGlobalSecondaryIndexArgs.builder()
.hashKey("GameTitle")
.name("GameTitleIndex")
.nonKeyAttributes("UserId")
.projectionType("INCLUDE")
.rangeKey("TopScore")
.readCapacity(10)
.writeCapacity(10)
.build())
.hashKey("UserId")
.rangeKey("GameTitle")
.readCapacity(20)
.tags(Map.ofEntries(
Map.entry("Environment", "production"),
Map.entry("Name", "dynamodb-table-1")
))
.ttl(TableTtlArgs.builder()
.attributeName("TimeToExist")
.enabled(false)
.build())
.writeCapacity(20)
.build());
}
}

Global Tables

This resource implements support for DynamoDB Global Tables V2 (version 2019.11.21) via replica configuration blocks. For working with DynamoDB Global Tables V1 (version 2017.11.29), see the aws.dynamodb.GlobalTable resource.

Note: aws.dynamodb.TableReplica is an alternate way of configuring Global Tables. Do not use replica configuration blocks of aws.dynamodb.Table together with aws_dynamodb_table_replica.

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.inputs.TableReplicaArgs;
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 example = new Table("example", TableArgs.builder()
.attributes(TableAttributeArgs.builder()
.name("TestTableHashKey")
.type("S")
.build())
.billingMode("PAY_PER_REQUEST")
.hashKey("TestTableHashKey")
.replicas(
TableReplicaArgs.builder()
.regionName("us-east-2")
.build(),
TableReplicaArgs.builder()
.regionName("us-west-2")
.build())
.streamEnabled(true)
.streamViewType("NEW_AND_OLD_IMAGES")
.build());
}
}

Import

DynamoDB tables can be imported using the name, e.g.,

$ pulumi import aws:dynamodb/table:Table basic-dynamodb-table GameScores

Constructors

Link copied to clipboard
constructor(attributes: Output<List<TableAttributeArgs>>? = null, billingMode: Output<String>? = null, deletionProtectionEnabled: Output<Boolean>? = null, globalSecondaryIndexes: Output<List<TableGlobalSecondaryIndexArgs>>? = null, hashKey: Output<String>? = null, localSecondaryIndexes: Output<List<TableLocalSecondaryIndexArgs>>? = null, name: Output<String>? = null, pointInTimeRecovery: Output<TablePointInTimeRecoveryArgs>? = null, rangeKey: Output<String>? = null, readCapacity: Output<Int>? = null, replicas: Output<List<TableReplicaArgs>>? = null, restoreDateTime: Output<String>? = null, restoreSourceName: Output<String>? = null, restoreToLatestTime: Output<Boolean>? = null, serverSideEncryption: Output<TableServerSideEncryptionArgs>? = null, streamEnabled: Output<Boolean>? = null, streamViewType: Output<String>? = null, tableClass: Output<String>? = null, tags: Output<Map<String, String>>? = null, ttl: Output<TableTtlArgs>? = null, writeCapacity: Output<Int>? = null)

Properties

Link copied to clipboard
val attributes: Output<List<TableAttributeArgs>>? = null

Set of nested attribute definitions. Only required for hash_key and range_key attributes. See below.

Link copied to clipboard
val billingMode: Output<String>? = null

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.

Link copied to clipboard
val deletionProtectionEnabled: Output<Boolean>? = null

Enables deletion protection for table. Defaults to false.

Link copied to clipboard

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

Link copied to clipboard
val hashKey: Output<String>? = null

Attribute to use as the hash (partition) key. Must also be defined as an attribute. See below.

Link copied to clipboard

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. See below.

Link copied to clipboard
val name: Output<String>? = null

Unique within a region name of the table. Optional arguments:

Link copied to clipboard

Enable point-in-time recovery options. See below.

Link copied to clipboard
val rangeKey: Output<String>? = null

Attribute to use as the range (sort) key. Must also be defined as an attribute, see below.

Link copied to clipboard
val readCapacity: Output<Int>? = null

Number of read units for this table. If the billing_mode is PROVISIONED, this field is required.

Link copied to clipboard
val replicas: Output<List<TableReplicaArgs>>? = null

Configuration block(s) with DynamoDB Global Tables V2 (version 2019.11.21) replication configurations. See below.

Link copied to clipboard
val restoreDateTime: Output<String>? = null

Time of the point-in-time recovery point to restore.

Link copied to clipboard
val restoreSourceName: Output<String>? = null

Name of the table to restore. Must match the name of an existing table.

Link copied to clipboard
val restoreToLatestTime: Output<Boolean>? = null

If set, restores table to the most recent point-in-time recovery point.

Link copied to clipboard

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. See below.

Link copied to clipboard
val streamEnabled: Output<Boolean>? = null

Whether Streams are enabled.

Link copied to clipboard
val streamViewType: Output<String>? = null

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.

Link copied to clipboard
val tableClass: Output<String>? = null

Storage class of the table. Valid values are STANDARD and STANDARD_INFREQUENT_ACCESS. Default value is STANDARD.

Link copied to clipboard
val tags: Output<Map<String, String>>? = null

A map of tags to populate on the created table. If configured with a provider default_tags configuration block present, tags with matching keys will overwrite those defined at the provider-level.

Link copied to clipboard
val ttl: Output<TableTtlArgs>? = null

Configuration block for TTL. See below.

Link copied to clipboard
val writeCapacity: Output<Int>? = null

Number of write units for this table. If the billing_mode is PROVISIONED, this field is required.

Functions

Link copied to clipboard
open override fun toJava(): TableArgs