-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(dynamodb): add new check dynamodb_table_autoscaling_enabled
#5129
feat(dynamodb): add new check dynamodb_table_autoscaling_enabled
#5129
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5129 +/- ##
==========================================
- Coverage 89.10% 89.10% -0.01%
==========================================
Files 993 995 +2
Lines 30509 30581 +72
==========================================
+ Hits 27186 27249 +63
- Misses 3323 3332 +9 ☔ View full report in Codecov by Sentry. |
…tically-scale-capacity-with-demand'
def _describe_autoscaling(self): | ||
logger.info("DynamoDB - Describing Auto Scaling...") | ||
try: | ||
for table in self.tables.values(): | ||
if table.billing_mode == "PROVISIONED": | ||
application_autoscaling_client = self.session.client( | ||
"application-autoscaling", region_name=table.region | ||
) | ||
read_response = ( | ||
application_autoscaling_client.describe_scalable_targets( | ||
ServiceNamespace="dynamodb", | ||
ResourceIds=[f"table/{table.name}"], | ||
ScalableDimension="dynamodb:table:ReadCapacityUnits", | ||
) | ||
) | ||
if read_response["ScalableTargets"]: | ||
table.read_autoscaling = True | ||
write_response = ( | ||
application_autoscaling_client.describe_scalable_targets( | ||
ServiceNamespace="dynamodb", | ||
ResourceIds=[f"table/{table.name}"], | ||
ScalableDimension="dynamodb:table:WriteCapacityUnits", | ||
) | ||
) | ||
if write_response["ScalableTargets"]: | ||
table.write_autoscaling = True | ||
except Exception as error: | ||
logger.error( | ||
f"{error.__class__.__name__}:{error.__traceback__.tb_lineno} -- {error}" | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, as you are using another client, put this function in the autoscaling
service in a new class.
…tically-scale-capacity-with-demand'
…ically-scale-capacity-with-demand
Context
This new check verifies that Amazon DynamoDB tables are configured to automatically scale their capacity based on demand. The control fails if the table does not use on-demand capacity mode or provisioned mode is used without auto scaling enabled.
Auto scaling helps ensure that DynamoDB tables adjust their read and write capacity dynamically in response to traffic patterns, which prevents throttling exceptions and maintains application availability. Tables in on-demand mode automatically adjust capacity to handle varying workloads, while provisioned mode with auto scaling adjusts based on predefined parameters.
As we can see here, the billing mode of the table set if the capacity is adjust to on-demand or provisioned:
And then, if the table is set as PROVISIONED, you can choose to have or not enabled read/write capacity to auto-scaling. This can be verify using the ApplicationAutoScaling service of AWS.
Description
Added new check
dynamodb_table_autoscaling_enabled
, modified the service and added unit tests.Checklist
License
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.