将 Amazon CloudFormation 用于 Auto Scaling 策略 - ElastiCache 适用于 Redis 的 Amazon
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

将 Amazon CloudFormation 用于 Auto Scaling 策略

此代码段演示如何使用 AWS::ApplicationAutoScaling::ScalableTarget 资源创建目标跟踪策略并将其应用于 AWS::ElastiCache::ReplicationGroup 资源。此示例利用 Fn::JoinRef 内置函数,使用在同一模板中指定的 AWS::ElastiCache::ReplicationGroup 资源的逻辑名称来构建 ResourceId 属性。

ScalingTarget: Type: 'AWS::ApplicationAutoScaling::ScalableTarget' Properties: MaxCapacity: 3 MinCapacity: 1 ResourceId: !Sub replication-group/${logicalName} ScalableDimension: 'elasticache:replication-group:NodeGroups' ServiceNamespace: elasticache RoleARN: !Sub "arn:aws:iam::${AWS::AccountId}:role/aws-service-role/elasticache.application-autoscaling.amazonaws.com/AWSServiceRoleForApplicationAutoScaling_ElastiCacheRG" ScalingPolicy: Type: "AWS::ApplicationAutoScaling::ScalingPolicy" Properties: ScalingTargetId: !Ref ScalingTarget ServiceNamespace: elasticache PolicyName: testpolicy PolicyType: TargetTrackingScaling ScalableDimension: 'elasticache:replication-group:NodeGroups' TargetTrackingScalingPolicyConfiguration: PredefinedMetricSpecification: PredefinedMetricType: ElastiCachePrimaryEngineCPUUtilization TargetValue: 40