本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
用 Amazon CloudFormation 于 Auto Scaling 策略
此片段展示了如何使用AWS:::: ElastiCache ReplicationGroup 资源创建目标跟踪策略并将其应用于AWS::ApplicationAutoScaling: ScalableTarget 资源。此示例利用 Fn::Join 和 Ref 内置函数,使用在同一模板中指定的 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