Created a dynamoDB table in my CDK project. this is fine it is used by lambdas created in the project. We needed to delete the stack which is also fine as we have retain resource set to true on the table.
Now when I try a fresh deploy we get table already exists error and stack rolls back. I need code that will create the table only if it does not exist.
Here is basic creation of a table, i cannot find any documentation anywhere on this issue or even an exception that can be caught or where i can see the type of exception that gets thrown to catch as we only see logs in the cloudformation console on AWS console.
const dynamoTable = new Table(this, "my-table", {
tableName: StackConfiguration.tableName,
partitionKey: { name: "id", type: AttributeType.STRING },
});
static fromTableName(scope, id, tableName)
. With those you can bring "external"/ existing tables into the CDK app. – Stefan Freitag