Skip to content
GitHubXDiscord

DynamoDB Table

The Table resource lets you create and manage Amazon DynamoDB tables for NoSQL database storage.

Create a basic table with just a partition key:

import { Table } from "alchemy/aws";
const table = await Table("users", {
tableName: "users",
partitionKey: {
name: "userId",
type: "S",
},
});

Add a sort key to enable range queries and composite keys:

const table = await Table("events", {
tableName: "events",
partitionKey: {
name: "deviceId",
type: "S",
},
sortKey: {
name: "timestamp",
type: "N",
},
});

Configure provisioned read/write capacity for predictable workloads:

const table = await Table("orders", {
tableName: "orders",
partitionKey: {
name: "orderId",
type: "S",
},
billingMode: "PROVISIONED",
readCapacity: 100,
writeCapacity: 50,
tags: {
Environment: "production",
},
});