Use Amazon CloudFormation for Auto Scaling policies
This snippet shows how to create a scheduled action and apply it to an AWS::ElastiCache::ReplicationGroup resource using the AWS::ApplicationAutoScaling::ScalableTarget resource. It uses the
Fn::Join and Ref intrinsic functions to construct the ResourceId
property with the logical name of the
AWS::ElastiCache::ReplicationGroup
resource that is specified in
the same template.
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: 40