Configures a single shard primary with a single read replica and includes lifecycle configuration to manage changes in the number of cache clusters.

Terraform Template

resource "aws_elasticache_cluster" "replica" {
  cluster_id = "tf-rep-group-1-${count.index}"
  count = 1
  replication_group_id = aws_elasticache_replication_group.example.id
}

resource "aws_elasticache_replication_group" "example" {
  automatic_failover_enabled = true
  description = "example description"

  lifecycle {
    ignore_changes = ["num_cache_clusters"]
  }
  node_type = "cache.m4.large"
  num_cache_clusters = 2
  parameter_group_name = "default.redis3.2"
  port = 6379
  preferred_cache_cluster_azs = ["us-west-2a", "us-west-2b"]
  replication_group_id = "tf-rep-group-1"
}