AWS Fundamentals Logo
AWS Fundamentals
L2 Construct

TableV2

A DynamoDB Table.

Import

import { TableV2 } from 'aws-cdk-lib/aws-dynamodb';

Or use the module namespace:

import * as dynamodb from 'aws-cdk-lib/aws-dynamodb';
// dynamodb.TableV2

Properties

Configuration passed to the constructor as TablePropsV2.

partitionKeyRequired
Attribute

Partition key attribute definition.

billingOptional
Billing

The billing mode and capacity settings to apply to the table.

Default: Billing.onDemand()

dynamoStreamOptional
StreamViewType

When an item in the table is modified, StreamViewType determines what information is written to the stream.

Default: - streams are disabled if replicas are not configured and this property is not specified. If this property is not specified when replicas are configured, then NEW_AND_OLD_IMAGES will be the StreamViewType for all replicas

encryptionOptional
TableEncryptionV2

The server-side encryption.

Default: TableEncryptionV2.dynamoOwnedKey()

globalSecondaryIndexesOptional
GlobalSecondaryIndexPropsV2[]

Global secondary indexes. Note: You can provide a maximum of 20 global secondary indexes.

Default: - no global secondary indexes

globalTableSettingsReplicationModeOptional
GlobalTableSettingsReplicationMode

Controls whether table settings are synchronized across replicas. When set to ALL, synchronizable settings (billing mode, throughput, TTL, streams view type, GSIs) are automatically replicated across all replicas. When set to NONE, each replica manages its own settings independently (billing mode must be PAY_PER_REQUEST). Note: Some settings are always synchronized (key schema, LSIs) regardless of this setting, and some are never synchronized (table class, SSE, deletion protection, PITR, tags, resource policy).

Default: GlobalTableSettingsReplicationMode.NONE

localSecondaryIndexesOptional
LocalSecondaryIndexProps[]

Local secondary indexes. Note: You can only provide a maximum of 5 local secondary indexes.

Default: - no local secondary indexes

multiRegionConsistencyOptional
MultiRegionConsistency

Specifies the consistency mode for a new global table.

Default: MultiRegionConsistency.EVENTUAL

removalPolicyOptional
RemovalPolicy

The removal policy applied to the table.

Default: RemovalPolicy.RETAIN

replicasOptional
ReplicaTableProps[]

Replica tables to deploy with the primary table. Note: Adding replica tables allows you to use your table as a global table. You cannot specify a replica table in the region that the primary table will be deployed to. Replica tables will only be supported if the stack deployment region is defined.

Default: - no replica tables

sortKeyOptional
Attribute

Sort key attribute definition.

Default: - no sort key

tableNameOptional
string

The name of the table.

Default: - generated by CloudFormation

timeToLiveAttributeOptional
string

The name of the TTL attribute.

Default: - TTL is disabled

warmThroughputOptional
WarmThroughput

The warm throughput configuration for the table.

Default: - no warm throughput is configured

witnessRegionOptional
string

The witness Region for the MRSC global table. A MRSC global table can be configured with either three replicas, or with two replicas and one witness. Note: Witness region cannot be specified for a Multi-Region Eventual Consistency (MREC) Global Table. Witness regions are only supported for Multi-Region Strong Consistency (MRSC) Global Tables.

Default: - no witness region

9 properties inherited from TableOptionsV2
contributorInsightsOptionalDeprecatedinherited from TableOptionsV2
boolean

Whether CloudWatch contributor insights is enabled.

Default: false

Deprecated: use `contributorInsightsSpecification` instead

contributorInsightsSpecificationOptionalinherited from TableOptionsV2
ContributorInsightsSpecification

Whether CloudWatch contributor insights is enabled and what mode is selected.

Default: - contributor insights is not enabled

deletionProtectionOptionalinherited from TableOptionsV2
boolean

Whether deletion protection is enabled.

Default: false

kinesisStreamOptionalinherited from TableOptionsV2
IStream

Kinesis Data Stream to capture item level changes.

Default: - no Kinesis Data Stream

pointInTimeRecoveryOptionalDeprecatedinherited from TableOptionsV2
boolean

Whether point-in-time recovery is enabled.

Default: false - point in time recovery is not enabled.

Deprecated: use `pointInTimeRecoverySpecification` instead

pointInTimeRecoverySpecificationOptionalinherited from TableOptionsV2
PointInTimeRecoverySpecification

Whether point-in-time recovery is enabled and recoveryPeriodInDays is set.

Default: - point in time recovery is not enabled.

resourcePolicyOptionalinherited from TableOptionsV2
PolicyDocument

Resource policy to assign to DynamoDB Table.

Default: - No resource policy statements are added to the created table.

tableClassOptionalinherited from TableOptionsV2
TableClass

The table class.

Default: TableClass.STANDARD

tagsOptionalinherited from TableOptionsV2
CfnTag[]

Tags to be applied to the primary table (default replica table).

Default: - no tags

Get the Amazon DynamoDB Cheat Sheet

Everything you need to know about Amazon DynamoDB on one page. HD quality, print-friendly.

Download Free Infographic