Identify and remove any unused AWS DynamoDB tables to optimize AWS costs

Efficiently manage AWS costs by identifying and eliminating unused DynamoDB tables, optimizing resources while maintaining streamlined database operations.

Risk Level: High
Cloud Entity: Amazon DynamoDB
CloudGuard Rule ID: D9.AWS.AS.11
Covered by Spectral: No
Category: Database

GSL LOGIC

DynamoDBTable should not have itemCount=0

REMEDIATION

From Portal

  1. Sign in to the AWS Management Console.

  2. Navigate to Amazon DynamoDB Tables Console at https://console.aws.amazon.com/dynamodbv2/home?#tables

  3. Click on the name (link) of the DynamoDB table that you want to examine.

  4. Select the 'Overview' tab (the default tab) to access the general configuration settings available for the selected table.

  5. Scroll down until you reach the 'Items summary' section, and check the Item count parameter value.
    If the Item count parameter value is set to 0 (zero), the selected Amazon DynamoDB table is not in use anymore and can be safely removed from your AWS cloud account.

  6. To delete the unused table scroll up and in the top left corner press the 'Actions' tab, and then click on the 'Delete Table' button.

  7. Repeat these steps for every DynamoDB Table you have, and don't forget to check other DynamoDB Tables in your other regions.

From TF

After finding a table that is unused, run the following command to delete it:

terraform destroy --target aws_dynamodb_table.EXAMPLE_TABLE_ID

From Command Line

  1. Run the following command to list all of your DynamoDB Tables in a specific region:
aws DynamoDB list-tables --region REGION_NAME --output table --query 'TableNames'
  1. To check whether a specific table is unused, run the following command on a table name (returned from the last command):
aws DynamoDB describe-table --region REGION_NAME --table-name TABLE_NAME --query 'Table.ItemCount'
  1. If the returned value is 0, the table is unused. To delete the unused table, run the following command:
aws DynamoDB delete-table --region REGION_NAME --table-name TABLE_NAME
  1. Repeat these steps for every DynamoDB Table you have, and don't forget to check other DynamoDB Tables in your other regions.

References

  1. https://awscli.amazonaws.com/v2/documentation/api/latest/reference/dynamodb/list-tables.html
  2. https://awscli.amazonaws.com/v2/documentation/api/latest/reference/dynamodb/describe-table.html
  3. https://awscli.amazonaws.com/v2/documentation/api/latest/reference/dynamodb/delete-table.html

Amazon DynamoDB

Amazon DynamoDB is a fast and flexible nonrelational database service for all applications that need consistent, single-digit millisecond latency at any scale. It is a fully managed cloud database and supports both document and key-value store models. Its flexible data model, reliable performance, and automatic scaling of throughput capacity make it a great fit for mobile, web, gaming, ad tech, IoT, and many other applications

Compliance Frameworks

  • CloudGuard AWS All Rules Ruleset