添加用于Redis的Terraform自动缩放策略

huangapple go评论70阅读模式
英文:

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.

添加用于Redis的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

Reference: https://docs.aws.amazon.com/autoscaling/application/userguide/services-that-can-integrate-elasticache.html

huangapple
  • 本文由 发表于 2023年5月25日 17:01:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/76330545.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定