/** * # Elasticache * * Deploy a test redis replication group and then in-place migrate to Valkey * * ## Migration steps (takes around 17m): * 1. Backup existing instance. Note the version and parameter group * 2. In the example resource below, change apply-immediately, engine, engine-version, and parameter group. * * ## When redis was initially deployed: * primary_endpoint = "lab-cache001.rw4ynm.ng.0001.ape1.cache.amazonaws.com" * reader_endpoint = "lab-cache001-ro.rw4ynm.ng.0001.ape1.cache.amazonaws.com" * * ## After in-place migration to Valkey: * primary_endpoint = "lab-cache001.rw4ynm.ng.0001.ape1.cache.amazonaws.com" * reader_endpoint = "lab-cache001-ro.rw4ynm.ng.0001.ape1.cache.amazonaws.com" * * ## Fallback * Simply reverting the code below will result in a replacement of the replication group. Meaning * fallback is not supported. One will need to deploy a new instance and restore from backup */ resource "aws_elasticache_replication_group" "example" { automatic_failover_enabled = true preferred_cache_cluster_azs = ["ap-east-1a", "ap-east-1b"] replication_group_id = "lab-cache001" description = "Redis to be migrated to Valkey" node_type = "cache.t4g.micro" num_cache_clusters = 2 cluster_mode = "enabled" # -------- in-place migration to valkey -------- # # engine_version = "7.1" # engine = "redis" # parameter_group_name = "default.redis7.cluster.on" apply_immediately = true engine = "valkey" engine_version = "8.2" parameter_group_name = "default.valkey8.cluster.on" # -------- in-place migration to valkey -------- # port = 6379 subnet_group_name = aws_elasticache_subnet_group.subnets.name } resource "aws_elasticache_subnet_group" "subnets" { description = "Lab subnet group" name = "lab-subnetgroup001" subnet_ids = ["subnet-0927ba1b06ccfe6c5", "subnet-0551e96ffd016192a"] } output "cluster_endpoint" { value = aws_elasticache_replication_group.example.configuration_endpoint_address } output "primary_endpoint" { value = aws_elasticache_replication_group.example.primary_endpoint_address } output "reader_endpoint" { value = aws_elasticache_replication_group.example.reader_endpoint_address }