-
Notifications
You must be signed in to change notification settings - Fork 192
Expand file tree
/
Copy pathDynamoDBStack.js
More file actions
27 lines (23 loc) · 888 Bytes
/
DynamoDBStack.js
File metadata and controls
27 lines (23 loc) · 888 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { CfnOutput } from "@aws-cdk/core";
import * as dynamodb from "@aws-cdk/aws-dynamodb";
import * as sst from "@serverless-stack/resources";
export default class DynamoDBStack extends sst.Stack {
constructor(scope, id, props) {
super(scope, id, props);
const app = this.node.root;
const table = new dynamodb.Table(this, "Table", {
billingMode: dynamodb.BillingMode.PAY_PER_REQUEST, // Use on-demand billing mode
sortKey: { name: "noteId", type: dynamodb.AttributeType.STRING },
partitionKey: { name: "userId", type: dynamodb.AttributeType.STRING },
});
// Output values
new CfnOutput(this, "TableName", {
value: table.tableName,
exportName: app.logicalPrefixedName("TableName"),
});
new CfnOutput(this, "TableArn", {
value: table.tableArn,
exportName: app.logicalPrefixedName("TableArn"),
});
}
}