我正在使用 AWS SDK for nodejs 并从代码创建一个 dynamodb 表。一切正常,但我需要为预置的读写容量启用自动缩放。这是我正在尝试的代码
var params = {
TableName : "MyTable",
KeySchema: [
{ AttributeName: "Name", KeyType: "HASH"}, //Partition key
{ AttributeName: "time", KeyType: "RANGE" } //Sort key
],
AttributeDefinitions: [
{ AttributeName: "Name", AttributeType: "S" },
{ AttributeName: "time", AttributeType: "N" }
],
ProvisionedThroughput: {
ReadCapacityUnits: 5,
WriteCapacityUnits: 5
}
]
};
dynamodb.createTable(params, function(err, data) {
if (err) {
console.error("Unable to create table. Error JSON:", JSON.stringify(err, null, 2));
} else {
console.log("Created table. Table description JSON:", JSON.stringify(data, null, 2));
}
});
这将创建一个读写容量为 5 但禁用自动缩放的表。我看到了一个 java 示例,其中自动缩放是从代码处理的,但对于 java 脚本没有任何处理。任何关于如何从 NodeJS 启用自动缩放的建议都会非常有帮助。谢谢