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

将 Amazon CloudFormation 用于 Auto Scaling 策略

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

ScalingTarget: Type: 'AWS::ApplicationAutoScaling::ScalableTarget' Properties: MaxCapacity: 0 MinCapacity: 0 ResourceId: !Sub replication-group/{logicalName} ScalableDimension: 'elasticache:replication-group:Replicas' 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:Replicas' TargetTrackingScalingPolicyConfiguration: PredefinedMetricSpecification: PredefinedMetricType: ElastiCacheReplicaEngineCPUUtilization TargetValue: 20