【发布时间】:2020-07-01 01:46:13
【问题描述】:
我正在为 dynamodb 使用 aws cdk,想添加一个 dynamodb 表,已经得到此代码,dynamodb 的 TableProps 是什么?我以为是字符串类型的表名,但是好像错了,谁能帮帮我?
import core = require('@aws-cdk/core');
import dynamodb = require('@aws-cdk/aws-dynamodb')
export class HelloCdkStack extends core.Stack {
constructor(scope: core.App, id: string, props?: core.StackProps) {
super(scope, id, props);
new dynamodb.Table(this, 'MyFirstTable', {
tableName: 'myTable'
});
}
}
这是错误
lib/dynamodb.ts:8:46 - error TS2345: Argument of type '{ tableName: string; }' is not assignable to parameter of type 'TableProps'.
Property 'partitionKey' is missing in type '{ tableName: string; }' but required in type 'TableProps'.
8 new dynamodb.Table(this, 'MyFirstTable', {
~
9 tableName: 'myTable'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10 });
~~~~~~~
node_modules/@aws-cdk/aws-dynamodb/lib/table.d.ts:19:14
19 readonly partitionKey: Attribute;
~~~~~~~~~~~~
'partitionKey' is declared here.
【问题讨论】:
标签: amazon-web-services amazon-dynamodb aws-cdk