Skip to content

Commit

Permalink
test: disable deletion protection before deleting tables
Browse files Browse the repository at this point in the history
  • Loading branch information
dpilch committed Feb 11, 2025
1 parent b1a8450 commit 4b97f7b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/amplify-graphql-api-construct-tests/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
sleep,
updateApiSchema,
} from 'amplify-category-api-e2e-core';
import { DynamoDBClient, DeleteTableCommand, ListTablesCommand } from '@aws-sdk/client-dynamodb';
import { DynamoDBClient, DeleteTableCommand, ListTablesCommand, UpdateTableCommand } from '@aws-sdk/client-dynamodb';

/**
* Retrieve the path to the `npx` executable for interacting with the aws-cdk cli.
Expand Down Expand Up @@ -248,5 +248,9 @@ export const createGen1ProjectForMigration = async (
*/
export const deleteDDBTables = async (tableNames: string[]): Promise<void> => {
const client = new DynamoDBClient({ region: process.env.CLI_REGION || 'us-west-2' });
// disable deletion protection before deleting the tables
await Promise.allSettled(
tableNames.map((tableName) => client.send(new UpdateTableCommand({ TableName: tableName, DeletionProtectionEnabled: false }))),
);
await Promise.allSettled(tableNames.map((tableName) => client.send(new DeleteTableCommand({ TableName: tableName }))));
};

0 comments on commit 4b97f7b

Please sign in to comment.