使用Cloudformation进行DynamoDB自动扩展

时间:2017-07-06 20:29:19

标签: amazon-web-services amazon-dynamodb amazon-cloudformation

AWS为DynamoDB发布了auto scaling。我想知道如何通过Cloudformation自动缩放创建表。

1 个答案:

答案 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
}