/
create-table.js
44 lines (38 loc) · 1.33 KB
/
create-table.js
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import { fileURLToPath } from "url";
// snippet-start:[dynamodb.JavaScript.table.createTableV3]
import { CreateTableCommand, DynamoDBClient } from "@aws-sdk/client-dynamodb";
const client = new DynamoDBClient({});
export const main = async () => {
const command = new CreateTableCommand({
TableName: "EspressoDrinks",
// For more information about data types,
// see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypes and
// https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Programming.LowLevelAPI.html#Programming.LowLevelAPI.DataTypeDescriptors
AttributeDefinitions: [
{
AttributeName: "DrinkName",
AttributeType: "S",
},
],
KeySchema: [
{
AttributeName: "DrinkName",
KeyType: "HASH",
},
],
ProvisionedThroughput: {
ReadCapacityUnits: 1,
WriteCapacityUnits: 1,
},
});
const response = await client.send(command);
console.log(response);
return response;
};
// snippet-end:[dynamodb.JavaScript.table.createTableV3]
// Invoke main function if this file was run directly.
if (process.argv[1] === fileURLToPath(import.meta.url)) {
main();
}