使用aws cdk时dynamodb的TableProps是什么
what's the TableProps for dynamodb when using aws cdk
我正在为 dynamodb 使用 aws cdk,想添加一个 dynamodb table,已经有了这个代码,dynamodb 的 TableProps 是什么?我以为是字符串类型的 table 名称,但似乎不对,有人可以帮我吗?
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.
尝试
import { AttributeType } from '@aws-cdk/aws-dynamodb';
new dynamodb.Table(this, 'MyFirstTable', {
tableName: "myTable",
partitionKey: {
name: "MyPartitionkey,
type: AttributeType.STRING
}
});
TableProps 扩展了 TableOptions 并且“partionKey”是必需的 属性 以使用 dynamodb.Table
创建 table。我认为 aws CDK 文档可以更清楚地说明“TableProps”如何使用“TableOptions”。
export interface TableProps extends TableOptions
在“partionKey”部分的 TableOptions 下,它说:
readonly partitionKey: Attribute;
没有“?”在“partionKey”和“:”之间做标记,这意味着需要 属性。
我正在为 dynamodb 使用 aws cdk,想添加一个 dynamodb table,已经有了这个代码,dynamodb 的 TableProps 是什么?我以为是字符串类型的 table 名称,但似乎不对,有人可以帮我吗?
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.
尝试
import { AttributeType } from '@aws-cdk/aws-dynamodb';
new dynamodb.Table(this, 'MyFirstTable', {
tableName: "myTable",
partitionKey: {
name: "MyPartitionkey,
type: AttributeType.STRING
}
});
TableProps 扩展了 TableOptions 并且“partionKey”是必需的 属性 以使用 dynamodb.Table
创建 table。我认为 aws CDK 文档可以更清楚地说明“TableProps”如何使用“TableOptions”。
export interface TableProps extends TableOptions
在“partionKey”部分的 TableOptions 下,它说:
readonly partitionKey: Attribute;
没有“?”在“partionKey”和“:”之间做标记,这意味着需要 属性。