英文:
Adding autoscaling policy for redis with terraform
问题
I am trying to set the autoscaling policy for redis via terraform. 我正在尝试通过Terraform为Redis设置自动缩放策略。
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: 用于设置集群模式下Redis的模块如下:
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
英文:
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
答案1
得分: 1
资源ID的格式不正确。从下面的示例中,格式应该是replication-group/mycluster
,其中你需要将mycluster
替换为集群ID,而在我的情况下是${module.elasticache_redis.elasticache_replication_group_id}
。
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
参考链接:https://docs.aws.amazon.com/autoscaling/application/userguide/services-that-can-integrate-elasticache.html
英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论