I am trying to set the autoscaling policy for redis via terraform.
I am setting the autoscaling policy as follows:
# Attach the autoscaling policy to the Redis replication group
resource "aws_appautoscaling_target" "redis_autoscaling_target" {
max_capacity = 10
min_capacity = 1
resource_id = "elasticache:${module.elasticache_redis.elasticache_replication_group_id}"
scalable_dimension = "elasticache:replication-group:NodeGroups"
service_namespace = "elasticache"
}
The module to setup redis in cluster mode is as follows:
module "elasticache_redis" {
source = "umotif-public/elasticache-redis/aws"
version = "~> 3.0.0"
name_prefix = "${var.redis_cache_name}-${var.environment}"
num_cache_clusters = var.redis_number_cache_clusters
node_type = var.redis_node_type
cluster_mode_enabled = true
replicas_per_node_group = 1
num_node_groups = 2
//rest of config is not important
}
I keep getting the following error:
creating Application AutoScaling Target (elasticache:test-redis): ValidationException: Unsupported service namespace, resource type or scalable dimension
The format of the resource id was incorrect. From example below the format should be replication-group/mycluster
where you replace mycluster
with the cluster id which is ${module.elasticache_redis.elasticache_replication_group_id}
in my case.
aws application-autoscaling register-scalable-target \
--service-namespace elasticache \
--scalable-dimension elasticache:replication-group:NodeGroups \
--resource-id replication-group/mycluster \
--min-capacity 1 \
--max-capacity 5