Cloud Defense Logo

Products

Solutions

Company

Book A Live Demo

Rule: DynamoDB Tables Should Automatically Scale Capacity

Ensure that DynamoDB tables automatically adjust capacity based on demand.

RuleDynamoDB tables should automatically scale capacity with demand
FrameworkAWS Foundational Security Best Practices
Severity
Medium

Rule Description

To ensure AWS Foundational Security Best Practices, DynamoDB tables should be configured to automatically scale capacity with demand. This helps to maintain optimal performance and availability for your applications, while minimizing expensive over-provisioning or throttling issues.

Troubleshooting Steps

If you encounter any issues related to automatic capacity scaling in DynamoDB, you can follow these troubleshooting steps:

  1. 1.
    Check Provisioned Capacity: Verify if the DynamoDB table has provisioned capacity enabled. If not, you need to enable it to enable automatic scaling.
  2. 2.
    Review Alarms: Ensure that CloudWatch Alarms for DynamoDB are properly set up to trigger auto scaling actions. Check if there are any alarms in a state of insufficient capacity or high utilization that could indicate scaling issues.
  3. 3.
    Review Scaling Policy: Confirm that the scaling policy for the table is correctly configured. Ensure that it aligns with the desired capacity and utilization thresholds.
  4. 4.
    Review Auto Scaling Configuration: Verify the auto scaling configuration for the table. Ensure that it is properly set up to automatically adjust capacity based on demand.
  5. 5.
    Check CloudFormation Templates: If you are using CloudFormation templates, review them to ensure proper configuration of table capacity, scaling policies, and alarms.

Necessary Code

Depending on the programming language you are using, you can use the following code snippets as a reference for implementing automatic scaling in DynamoDB:

Python:

import boto3

client = boto3.client('dynamodb')

response = client.update_table(
    TableName='your-dynamodb-table-name',
    ProvisionedThroughput={
        'ReadCapacityUnits': desired_read_capacity,
        'WriteCapacityUnits': desired_write_capacity
    },
    BillingMode='PAY_PER_REQUEST'
)

Java:

import com.amazonaws.services.dynamodbv2.AmazonDynamoDB;
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder;
import com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput;
import com.amazonaws.services.dynamodbv2.model.UpdateTableRequest;

AmazonDynamoDB client = AmazonDynamoDBClientBuilder.standard().build();

UpdateTableRequest updateTableRequest = new UpdateTableRequest()
    .withTableName("your-dynamodb-table-name")
    .withProvisionedThroughput(new ProvisionedThroughput()
        .withReadCapacityUnits(desired_read_capacity)
        .withWriteCapacityUnits(desired_write_capacity))
    .withBillingMode("PAY_PER_REQUEST");

client.updateTable(updateTableRequest);

Note: Replace

'your-dynamodb-table-name'
with the actual name of your DynamoDB table, and adjust the
desired_read_capacity
and
desired_write_capacity
with the desired values.

Step-by-Step Guide for Remediation

To enable automatic scaling in DynamoDB, follow these steps:

  1. 1.
    Step 1: Open the AWS Management Console and navigate to the DynamoDB service.
  2. 2.
    Step 2: Select the appropriate region where your DynamoDB table is located.
  3. 3.
    Step 3: Click on the name of the desired DynamoDB table that needs automatic scaling.
  4. 4.
    Step 4: In the navigation pane, click on the "Capacity" tab.
  5. 5.
    Step 5: Under "Auto Scaling", click on the "Manage Auto Scaling" button.
  6. 6.
    Step 6: Click on the "Edit" button next to "Auto Scaling is Disabled".
  7. 7.
    Step 7: Configure the auto scaling policies by setting the desired values for read and write capacity.
  8. 8.
    Step 8: Adjust the "Minimum Units", "Maximum Units", and "Target Tracking" settings based on your requirements.
  9. 9.
    Step 9: Click on the "Save" button to enable automatic scaling for the DynamoDB table.
  10. 10.
    Step 10: Verify if the automatic scaling policy is successfully applied by checking the status in the "Capacity" tab.

By following these steps, you will successfully enable automatic capacity scaling for your DynamoDB table, ensuring optimal performance and availability based on demand.

Is your System Free of Underlying Vulnerabilities?
Find Out Now