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

Terraform部署AWS ElastiCache Redis时config-file参数报错问题

AWS ElastiCache Redis 自定义配置的 Terraform 问题解决

我在编写Terraform代码部署AWS ElastiCache Redis实例时,想沿用本地Redis的方式通过redis.conf配置文件来配置实例,于是写了这段代码:

resource "aws_elasticache_parameter_group" "redis_parameter_group" {
  name        = "cache-params"
  family      = "redis5.0"
  description = "custom Redis parameter group to use redis.conf"

  parameter {
    name  = "config-file"
    value = file("${path.module}/config/redis.conf")  # path to custom redis.conf file
  }
}

执行terraform apply时遇到报错:

Could not find parameter with name: config-file


问题原因与解决方法

  • AWS ElastiCache是托管式Redis服务,不支持通过config-file参数直接加载本地的redis.conf文件,这是本地自建Redis的用法,不适用于ElastiCache。
  • 正确操作是把redis.conf里的配置项逐一拆解,在aws_elasticache_parameter_group的parameter块中单独设置每个参数。
  • 示例(假设你的redis.conf包含maxmemory 1gb和maxmemory-policy allkeys-lru两个配置):
resource "aws_elasticache_parameter_group" "redis_parameter_group" {
  name        = "cache-params"
  family      = "redis5.0"
  description = "custom Redis parameter group"

  parameter {
    name  = "maxmemory"
    value = "1gb"
  }

  parameter {
    name  = "maxmemory-policy"
    value = "allkeys-lru"
  }
}
  • 注意:并非所有本地Redis的配置项都能在ElastiCache中配置,具体可查看AWS官方文档中ElastiCache Redis支持的参数清单。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.01 16:59:58