19

On terraform/cloudformation documentation there are two different resources to create an ElastiCache Redis instance:

  1. aws_elasticache_cluster (https://www.terraform.io/docs/providers/aws/r/elasticache_cluster.html)
  2. aws_elasticache_replication_group (https://www.terraform.io/docs/providers/aws/r/elasticache_replication_group.html)

What is the difference between these two? Which one should I choose?

Pat Myron
  • 4,437
  • 2
  • 20
  • 39
darkcode
  • 868
  • 12
  • 27

2 Answers2

10

Simply, the replication group is for the Redis cluster and the cache cluster is for the Memcache. You cannot apply the command to the others, i.e. cache cluster for Redis cluster and vice versa.

The redis also can use aws_elasticache_cluster but only if when redis has node 1, that is not a cluster mode.

num_cache_nodes – (Required unless replication_group_id is provided) The initial number of cache nodes that the cache cluster will have. For Redis, this value must be 1. For Memcache, this value must be between 1 and 20. If this number is reduced on subsequent runs, the highest numbered nodes will be removed.

Lamanus
  • 12,898
  • 4
  • 21
  • 47
  • 6
    Why is then possible to specify `redis` on the `engine` param for `aws_elasticache_cluster`? https://www.terraform.io/docs/providers/aws/r/elasticache_cluster.html#engine – darkcode Oct 13 '19 at 02:54
  • 1
    When the redis is not a cluster mode with node 1, then it is possible to use the cluster command which is very special. – Lamanus Oct 13 '19 at 03:02
  • 1
    Will choosing `aws_elasticache_replication_group` result in clustered redis with one shard and `choosing aws_elasticache_cluster ` will result in standard redis with default one shard. Can anyone help if this is correct? – Roseau Sep 17 '20 at 09:34
1

A replication group is a collection of cache clusters, where one of the clusters is a primary read-write cluster and the others are read-only replicas.

AWS::ElastiCache::CacheCluster

AWS::ElastiCache::ReplicationGroup

Pat Myron
  • 4,437
  • 2
  • 20
  • 39
  • 2
    I already read the documentation but to be honest I don't fully understand the difference and which one should I choose? – darkcode Oct 13 '19 at 02:56