interface DynamoTableOptions {
    partitionKey: {
        name: string;
        type: AttributeType;
    };
    sortKey?: {
        name: string;
        type: AttributeType;
    };
    billingMode?: BillingMode;
    readCapacity?: number;
    writeCapacity?: number;
    pointInTimeRecovery?: boolean;
    removalPolicy?: RemovalPolicy;
    writeLambdas?: Function[];
    readLambdas?: Function[];
    props?: Partial<TableProps>;
}

Properties

partitionKey: {
    name: string;
    type: AttributeType;
}

The partition key (hash key) for the DynamoDB table.

This is the primary key attribute that DynamoDB uses to distribute data across multiple partitions.

const partitionKey = {
name: 'id',
type: dynamodb.AttributeType.STRING
};
sortKey?: {
    name: string;
    type: AttributeType;
}

The sort key (range key) for the DynamoDB table.

Optional. Used together with the partition key to create a composite primary key.

const sortKey = {
name: 'timestamp',
type: dynamodb.AttributeType.NUMBER
};
billingMode?: BillingMode

The billing mode for the DynamoDB table.

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

const billingMode = dynamodb.BillingMode.PROVISIONED;
readCapacity?: number

Read capacity units for the table (only applicable when billing mode is PROVISIONED).

5
writeCapacity?: number

Write capacity units for the table (only applicable when billing mode is PROVISIONED).

5
pointInTimeRecovery?: boolean

Whether to enable point-in-time recovery for the table.

false
removalPolicy?: RemovalPolicy

The removal policy for the table when the stack is deleted.

RemovalPolicy.DESTROY
writeLambdas?: Function[]

Lambda functions that should be granted write permissions to this table.

The construct will automatically add the necessary IAM permissions.

const writeLambdas = [myLambdaFunction, anotherLambdaFunction];
readLambdas?: Function[]

Lambda functions that should be granted read permissions to this table.

The construct will automatically add the necessary IAM permissions.

const readLambdas = [myReadLambdaFunction];
props?: Partial<TableProps>

Any other available props to configure your DynamoDB table.