Skip to content

Commit d3f2cc4

Browse files
authored
Fix cluster mode elasticache ignore values (#378)
1 parent 833eccd commit d3f2cc4

File tree

4 files changed

+46
-10
lines changed

4 files changed

+46
-10
lines changed

aws/elasticache/README.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ module "elasticache" {
4343
# Compulsory for Cluster Mode
4444
shard_count = 2
4545
replicas_per_node_group = 1 # if set to 0, must disable multi-AZ
46+
47+
# Ignore engine version changes since AWS will auto-update minor version changes
48+
lifecycle {
49+
ignore_changes = [
50+
engine_version,
51+
]
52+
}
4653
}
4754
```
4855

@@ -62,7 +69,30 @@ Sidekiq does not work with cluster mode. The recommended setup is to have:
6269
* ca-central-1
6370
* sa-east-1
6471

65-
As of July 2022. Also, you **must** use Reds `6.2` or later.
72+
As of July 2025. Also, you **must** use following versions of elasticache:
73+
74+
- Redis `7.1` or later
75+
- Valkey `8.0` or later
76+
77+
78+
## Migration from Redis 6.2.6
79+
80+
> 💡 We highly recommned migrating to a desired engine and version right away to save time.
81+
82+
If you're trying to migrate from <7 Redis version to any new version, you'll likely get an error like this:
83+
84+
```
85+
Transit encryption mode is not supported for engine version 6.2.6. Please use engine version 7.0.5 or higher.
86+
```
87+
88+
In order to successfully migrate you'll have to explicitly set this param to `null`:
89+
90+
```
91+
# this will ensure that you'll update engine version successfully
92+
transit_encryption_mode = null
93+
```
94+
95+
Once migrated you can enable `transit_encryption_mode` without replacing resource
6696

6797
## Outputs
6898

aws/elasticache/elasticache.tf

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,6 @@ resource "aws_elasticache_replication_group" "cluster_mode" {
7575
Project = var.project
7676
Environment = var.environment
7777
}
78-
79-
# Ignore engine version changes since AWS will auto-update minor version changes
80-
lifecycle {
81-
ignore_changes = [
82-
engine_version,
83-
]
84-
}
8578
}
8679

8780
locals {

aws/stack/app/elasticache.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ module "elasticache" {
1414
])))
1515

1616
# optional
17+
engine = var.elasticache_engine
1718
name = var.elasticache_name
1819
major_version = var.elasticache_major_version
1920
node_type = var.elasticache_node_type

aws/stack/app/variables.tf

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,24 @@ variable "elasticache_node_type" {
185185
default = "cache.t3.micro"
186186
}
187187

188+
variable "elasticache_engine" {
189+
type = string
190+
default = "redis"
191+
validation {
192+
condition = contains(["redis", "valkey"], var.elasticache_engine)
193+
error_message = "elasticache engine must be either 'redis' or 'valkey'"
194+
}
195+
}
196+
197+
locals {
198+
major_version_bounds = var.elasticache_engine == "valkey" ? [7, 8] : [6, 7]
199+
}
188200
variable "elasticache_major_version" {
189201
type = number
190202
default = 7
191203
validation {
192-
condition = var.elasticache_major_version >= 6 && var.elasticache_major_version <= 7
193-
error_message = "elasticache major_version must be 6 or 7"
204+
condition = var.elasticache_major_version >= local.major_version_bounds[0] && var.elasticache_major_version <= local.major_version_bounds[1]
205+
error_message = "elasticache_major_version must be ${local.major_version_bounds[0]} or ${local.major_version_bounds[1]}"
194206
}
195207
}
196208

0 commit comments

Comments
 (0)