Open pimperator opened 2 years ago
In case it isn't obvious, I would like to make sure the aws_elasticache_replication_group
resource is included in this request.
hey, any updates on this issue? and if not can AWS auto scaling be used in case of Redis cluster mode on to auto scale the cluster? does terraform support that somehow?
You can attach an autoscalingpolicy via the App Autoscaling resources.
example code:
locals {
redis_cluster = "redis-cluster-name"
}
resource "aws_appautoscaling_target" "redis_cluster_target" {
# replication-group is constant and the unique identifier is the replication group name
resource_id = "replication-group/${local.redis_cluster}"
service_namespace = "elasticache"
# this scales the number of shards
scalable_dimension = "elasticache:replication-group:NodeGroups"
# alternate scaling to add read replicas to each shard of a clustered mode redis cluster
#scalable_dimension = "elasticache:replication-group:Replicas"
max_capacity = 4
min_capacity = 1
}
resource "aws_appautoscaling_policy" "redis_shards" {
name = "redis-shard-scaling"
service_namespace = aws_appautoscaling_target.redis_cluster_target.service_namespace
scalable_dimension = aws_appautoscaling_target.redis_cluster_target.scalable_dimension
resource_id = aws_appautoscaling_target.redis_cluster_target.resource_id
policy_type = "TargetTrackingScaling"
target_tracking_scaling_policy_configuration {
predefined_metric_specification {
# see https://docs.aws.amazon.com/autoscaling/application/userguide/monitor-cloudwatch-metrics.html#predefined-metrics
predefined_metric_type = "ElastiCacheDatabaseMemoryUsageCountedForEvictPercentage"
}
disable_scale_in = false
target_value = 75 #percentage
scale_in_cooldown = 900 #secs
scale_out_cooldown = 60 #secs
}
}
Community Note
Description
Since AWS announced autoscaling on elasticache-redis instances here on Aug 20, 2021 it would be awesome if we could profit from in on terraform
New or Affected Resource(s)
Potential Terraform Configuration
References