You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Terraform配置Redis自动扩缩容策略时遇报错求助

解决ElastiCache Redis集群模式自动扩缩容的ValidationException错误

错误原因分析

你遇到的ValidationException是因为自动扩缩容目标的配置参数不符合AWS App Auto Scaling要求,核心问题在于:

  • resource_id格式错误:ElastiCache自动扩缩容的资源ID必须遵循replication-group/<复制组ID>的格式,而非你当前使用的elasticache:<复制组ID>。
  • 额外前置检查:需确保Redis集群满足自动扩缩容基础条件(你当前配置已覆盖):
    • Redis版本≥5.0.6或6.x及以上
    • 集群模式已启用(cluster_mode_enabled = true)
    • 每个节点组副本数≥1(replicas_per_node_group = 1)

修正后的代码

调整aws_appautoscaling_target的resource_id格式即可解决该错误:

# Attach the autoscaling policy to the Redis replication group
resource "aws_appautoscaling_target" "redis_autoscaling_target" {
  max_capacity       = 10
  min_capacity       = 1
  # 修正resource_id格式为replication-group:<复制组ID>
  resource_id        = "replication-group:${module.elasticache_redis.elasticache_replication_group_id}"
  scalable_dimension = "elasticache:replication-group:NodeGroups"
  service_namespace  = "elasticache"
}

额外验证点

  • 确认module.elasticache_redis.elasticache_replication_group_id输出的是正确的ElastiCache复制组ID,可通过terraform plan查看该变量实际取值。
  • 若仍有问题,检查区域是否支持对应Redis版本的自动扩缩容功能(AWS部分区域对旧版本Redis的自动扩缩容有限制)。

内容的提问来源于stack exchange,提问作者user2650277

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.20 20:57:04