Last active
January 21, 2023 21:14
-
-
Save knil-sama/013a8d2199251dce7036d0dae060b659 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import boto3 | |
| autoscaling_client = boto3.client('application-autoscaling') | |
| percent_of_use_to_aim_for = 50.0 | |
| scale_out_cooldown_in_seconds = 60 | |
| scale_in_cooldown_in_seconds = 60 | |
| autoscaling_client.put_scaling_policy(ServiceNamespace='dynamodb', | |
| ResourceId='table/fake_table', | |
| PolicyType='StepScaling', | |
| StepScalingPolicyConfiguration={ | |
| 'AdjustmentType': 'ExactCapacity', | |
| 'StepAdjustments': [ | |
| { | |
| 'MetricIntervalLowerBound': 0, | |
| 'MetricIntervalUpperBound': 10, | |
| 'ScalingAdjustment': 100 | |
| }, | |
| ], | |
| 'MinAdjustmentMagnitude': 10, | |
| 'Cooldown': 60, | |
| 'MetricAggregationType': 'Maximum' | |
| }, | |
| PolicyName='ScaleDynamoDBReadCapacityUtilization', | |
| ScalableDimension='dynamodb:table:ReadCapacityUnits', | |
| TargetTrackingScalingPolicyConfiguration={ | |
| 'TargetValue': 10, | |
| 'PredefinedMetricSpecification': { | |
| 'PredefinedMetricType': 'DynamoDBReadCapacityUtilization' | |
| }, | |
| 'ScaleOutCooldown': scale_out_cooldown_in_seconds, | |
| 'ScaleInCooldown': scale_in_cooldown_in_seconds | |
| }) | |
| autoscaling_client.put_scaling_policy(ServiceNamespace='dynamodb', | |
| ResourceId='table/fake_table', | |
| PolicyType='StepCaling', | |
| StepScalingPolicyConfiguration={ | |
| 'AdjustmentType': 'ExactCapacity', | |
| 'StepAdjustments': [ | |
| { | |
| 'MetricIntervalLowerBound': 0, | |
| 'MetricIntervalUpperBound': 10, | |
| 'ScalingAdjustment': 100 | |
| }, | |
| ], | |
| 'MinAdjustmentMagnitude': 10, | |
| 'Cooldown': 60, | |
| 'MetricAggregationType': 'Maximum' | |
| }, | |
| PolicyName='ScaleDynamoDBWriteCapacityUtilization', | |
| ScalableDimension='dynamodb:table:WriteCapacityUnits', | |
| TargetTrackingScalingPolicyConfiguration={ | |
| 'TargetValue': 10, | |
| 'PredefinedMetricSpecification': { | |
| 'PredefinedMetricType': 'DynamoDBWriteCapacityUtilization' | |
| }, | |
| 'ScaleOutCooldown': scale_out_cooldown_in_seconds, | |
| 'ScaleInCooldown': scale_in_cooldown_in_seconds | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment