AWS为DynamoDB发布了auto scaling。我想知道如何通过Cloudformation自动缩放创建表。
答案 0 :(得分:6)
以下是DynamoDB表的 ClodFormation自动扩展策略。希望它能让您了解如何构建策略脚本。
{
"Type" : "AWS::ApplicationAutoScaling::ScalingPolicy",
"Properties" : {
"PolicyName" : "MyScalingPolicy",
"PolicyType" : "TargetTrackingScaling",
"ResourceId" : "arn:aws:dynamodb:us-east-1:123456789012:table/books_table",
"ScalableDimension" : "dynamodb:table:WriteCapacityUnits",
"ServiceNamespace" : "dynamodb",
"TargetTrackingScalingPolicyConfiguration" : {
"PredefinedMetricSpecification": {
"PredefinedMetricType": "DynamoDBWriteCapacityUtilization"
},
"ScaleOutCooldown": 60,
"ScaleInCooldown": 60,
"TargetValue": 50.0
}
}
}
<强>参考文献: - 强>
CloudFormaction auto-scaling policy
AWS CLI command for auto scaling
AWS CLI命令: -
aws application-autoscaling put-scaling-policy \
--service-namespace dynamodb \
--resource-id "table/TestTable" \
--scalable-dimension "dynamodb:table:WriteCapacityUnits" \
--policy-name "MyScalingPolicy" \
--policy-type "TargetTrackingScaling" \
--target-tracking-scaling-policy-configuration file://scaling-policy.json
<强>缩放-policy.json: - 强>
{
"PredefinedMetricSpecification": {
"PredefinedMetricType": "DynamoDBWriteCapacityUtilization"
},
"ScaleOutCooldown": 60,
"ScaleInCooldown": 60,
"TargetValue": 50.0
}