interface TableOptions
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.DynamoDB.TableOptions |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awsdynamodb#TableOptions |
Java | software.amazon.awscdk.services.dynamodb.TableOptions |
Python | aws_cdk.aws_dynamodb.TableOptions |
TypeScript (source) | aws-cdk-lib » aws_dynamodb » TableOptions |
Properties of a DynamoDB Table.
Use TableProps
for all table properties
Example
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';
import { aws_dynamodb as dynamodb } from 'aws-cdk-lib';
import { aws_kms as kms } from 'aws-cdk-lib';
import { aws_s3 as s3 } from 'aws-cdk-lib';
declare const bucket: s3.Bucket;
declare const inputFormat: dynamodb.InputFormat;
declare const key: kms.Key;
const tableOptions: dynamodb.TableOptions = {
partitionKey: {
name: 'name',
type: dynamodb.AttributeType.BINARY,
},
// the properties below are optional
billingMode: dynamodb.BillingMode.PAY_PER_REQUEST,
contributorInsightsEnabled: false,
deletionProtection: false,
encryption: dynamodb.TableEncryption.DEFAULT,
encryptionKey: key,
importSource: {
bucket: bucket,
inputFormat: inputFormat,
// the properties below are optional
bucketOwner: 'bucketOwner',
compressionType: dynamodb.InputCompressionType.GZIP,
keyPrefix: 'keyPrefix',
},
pointInTimeRecovery: false,
readCapacity: 123,
removalPolicy: cdk.RemovalPolicy.DESTROY,
replicationRegions: ['replicationRegions'],
replicationTimeout: cdk.Duration.minutes(30),
sortKey: {
name: 'name',
type: dynamodb.AttributeType.BINARY,
},
stream: dynamodb.StreamViewType.NEW_IMAGE,
tableClass: dynamodb.TableClass.STANDARD,
timeToLiveAttribute: 'timeToLiveAttribute',
waitForReplicationToFinish: false,
writeCapacity: 123,
};
Properties
Name | Type | Description |
---|---|---|
partition | Attribute | Partition key attribute definition. |
billing | Billing | Specify how you are charged for read and write throughput and how you manage capacity. |
contributor | boolean | Whether CloudWatch contributor insights is enabled. |
deletion | boolean | Enables deletion protection for the table. |
encryption? | Table | Whether server-side encryption with an AWS managed customer master key is enabled. |
encryption | IKey | External KMS key to use for table encryption. |
import | Import | The properties of data being imported from the S3 bucket source to the table. |
point | boolean | Whether point-in-time recovery is enabled. |
read | number | The read capacity for the table. |
removal | Removal | The removal policy to apply to the DynamoDB Table. |
replication | string[] | Regions where replica tables will be created. |
replication | Duration | The timeout for a table replication operation in a single region. |
sort | Attribute | Sort key attribute definition. |
stream? | Stream | When an item in the table is modified, StreamViewType determines what information is written to the stream for this table. |
table | Table | Specify the table class. |
time | string | The name of TTL attribute. |
wait | boolean | Indicates whether CloudFormation stack waits for replication to finish. |
write | number | The write capacity for the table. |
partitionKey
Type:
Attribute
Partition key attribute definition.
billingMode?
Type:
Billing
(optional, default: PROVISIONED if replicationRegions
is not specified, PAY_PER_REQUEST otherwise)
Specify how you are charged for read and write throughput and how you manage capacity.
contributorInsightsEnabled?
Type:
boolean
(optional, default: false)
Whether CloudWatch contributor insights is enabled.
deletionProtection?
Type:
boolean
(optional, default: false)
Enables deletion protection for the table.
encryption?
Type:
Table
(optional, default: The table is encrypted with an encryption key managed by DynamoDB, and you are not charged any fee for using it.)
Whether server-side encryption with an AWS managed customer master key is enabled.
This property cannot be set if serverSideEncryption
is set.
NOTE: if you set this to
CUSTOMER_MANAGED
andencryptionKey
is not specified, the key that the Tablet generates for you will be created with default permissions. If you are using CDKv2, these permissions will be sufficient to enable the key for use with DynamoDB tables. If you are using CDKv1, make sure the feature flag@aws-cdk/aws-kms:defaultKeyPolicies
is set totrue
in yourcdk.json
.
encryptionKey?
Type:
IKey
(optional, default: If encryption
is set to TableEncryption.CUSTOMER_MANAGED
and this
property is undefined, a new KMS key will be created and associated with this table.
If encryption
and this property are both undefined, then the table is encrypted with
an encryption key managed by DynamoDB, and you are not charged any fee for using it.)
External KMS key to use for table encryption.
This property can only be set if encryption
is set to TableEncryption.CUSTOMER_MANAGED
.
importSource?
Type:
Import
(optional, default: no data import from the S3 bucket)
The properties of data being imported from the S3 bucket source to the table.
pointInTimeRecovery?
Type:
boolean
(optional, default: point-in-time recovery is disabled)
Whether point-in-time recovery is enabled.
readCapacity?
Type:
number
(optional, default: 5)
The read capacity for the table.
Careful if you add Global Secondary Indexes, as those will share the table's provisioned throughput.
Can only be provided if billingMode is Provisioned.
removalPolicy?
Type:
Removal
(optional, default: RemovalPolicy.RETAIN)
The removal policy to apply to the DynamoDB Table.
replicationRegions?
Type:
string[]
(optional, default: no replica tables are created)
Regions where replica tables will be created.
replicationTimeout?
Type:
Duration
(optional, default: Duration.minutes(30))
The timeout for a table replication operation in a single region.
sortKey?
Type:
Attribute
(optional, default: no sort key)
Sort key attribute definition.
stream?
Type:
Stream
(optional, default: streams are disabled unless replicationRegions
is specified)
When an item in the table is modified, StreamViewType determines what information is written to the stream for this table.
tableClass?
Type:
Table
(optional, default: STANDARD)
Specify the table class.
timeToLiveAttribute?
Type:
string
(optional, default: TTL is disabled)
The name of TTL attribute.
waitForReplicationToFinish?
Type:
boolean
(optional, default: true)
Indicates whether CloudFormation stack waits for replication to finish.
If set to false, the CloudFormation resource will mark the resource as created and replication will be completed asynchronously. This property is ignored if replicationRegions property is not set.
WARNING: DO NOT UNSET this property if adding/removing multiple replicationRegions in one deployment, as CloudFormation only supports one region replication at a time. CDK overcomes this limitation by waiting for replication to finish before starting new replicationRegion.
If the custom resource which handles replication has a physical resource
ID with the format region
instead of tablename-region
(this would happen
if the custom resource hasn't received an event since v1.91.0), DO NOT SET
this property to false without making a change to the table name.
This will cause the existing replicas to be deleted.
writeCapacity?
Type:
number
(optional, default: 5)
The write capacity for the table.
Careful if you add Global Secondary Indexes, as those will share the table's provisioned throughput.
Can only be provided if billingMode is Provisioned.