【发布时间】:2022-12-06 20:55:17
【问题描述】:
我正在使用 aws cdk 配置资源。 在配置 dynamodb 表(名称为“cars”)之前,我想检查是否没有这样的表(参见代码示例)。
我怎样才能做到这一点?
import { RemovalPolicy } from "aws-cdk-lib";
import { AttributeType, BillingMode, StreamViewType, Table} from "aws-cdk-lib/aws-dynamodb";
import { Construct } from "constructs";
export class MyTables extends Construct {
public readonly cars: Table;
constructor(scope: Construct, id: string) {
super(scope, id);
// if dynamo table with the name 'cars' is not exist <----- How can I check this?
this.cars = this.createTable('cars'); // this is my own function that creates a table with the name 'cars'
}
}
【问题讨论】:
标签: typescript amazon-web-services amazon-dynamodb aws-cdk