Ensure that DynamoDB tables automatically adjust capacity based on demand.
Rule | DynamoDB tables should automatically scale capacity with demand |
Framework | AWS 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:
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:
By following these steps, you will successfully enable automatic capacity scaling for your DynamoDB table, ensuring optimal performance and availability based on demand.