Review the ElastiCache engine choice

Check that the cache engine and its protections meet the application’s actual requirements.

Description

Choose Redis OSS, Valkey or Memcached to match your application’s protocol, data structures, authentication and encryption requirements. Set engine = "redis" when the application needs Redis OSS.

Potential impact

Changing engines can break existing clients or discard cached data. Changing the engine setting alone does not migrate the data.

Remediation

For a live migration, define the destination as a separate Terraform resource with a distinct cluster ID. Configure its network, parameter group and required backups. Migrate or rebuild the cache, then test clients against the new endpoint before switching.

Examples

The Memcached example uses var.memcached_engine_version and port 6379. Supply a supported version. The Redis OSS example uses one node and port 11211. Match client and security group settings to the ports actually configured.

Before

hcl
resource "aws_elasticache_cluster" "example" {
  cluster_id      = "cluster-example"
  engine          = "memcached"
  node_type       = "cache.m4.large"
  num_cache_nodes = 1
  engine_version  = var.memcached_engine_version
  port            = 6379
}

After

hcl
resource "aws_elasticache_cluster" "example" {
  cluster_id      = "cluster-example"
  engine          = "redis"
  node_type       = "cache.m4.large"
  num_cache_nodes = 1
  port            = 11211
}

Both excerpts use cluster-example. The single-node Redis OSS example has no replica. For node-based Redis OSS with TLS or client authentication, use a supported aws_elasticache_replication_group.

References