在使用Terraform创建ElastiCache(Redis)集群时遇到的困难

前提 tí)

    terraform v0.10.3

我希望在这篇文章中传达的信息是

    Redisの複数キャッシュノードのクラスタを作りたいときは、aws_elasticache_clusterではなく、aws_elasticache_replication_groupを使う

我最初迷上的事情

    Redisの複数キャッシュノードのクラスタを作成しようとして、 aws_elasticache_clusterで定義を書いた
resource "aws_elasticache_cluster" "redis" {
  cluster_id           = "cluster-redis"
  engine               = "redis"
  node_type            = "cache.t2.micro"
  port                 = 6379
  num_cache_nodes      = 2
  parameter_group_name = "default.redis3.2"
}
    ところが、、、
* aws_elasticache_cluster.redis: Error creating Elasticache: InvalidParameterValue: Cannot create a Redis cluster with a NumCacheNodes parameter greater than 1.
    status code: 400, request id: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
    え?num_cache_nodesって、1以上指定できないの?

看到terraform的公式文档

公式ページのnum_cache_nodes

(Required) 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.
    Memcacheは1〜20台作れるけど、Redisは1台だけだと・・・・なんだこの制限?

调查的结果 chá de jié guǒ)

    Redisはaws_elasticache_replication_groupで複数キャッシュノードのクラスターが作成できました。
resource "aws_elasticache_replication_group" "redis" {
  replication_group_id          = "tf-rep-group-1"
  replication_group_description = "test description"
  node_type                     = "cache.m1.small"
  number_cache_clusters         = 2
  port                          = 6379
  parameter_group_name          = "default.redis3.2"
  availability_zones            = ["us-west-2a", "us-west-2b"]
  automatic_failover_enabled    = true
}

概述

    • Redisの複数キャッシュノードのクラスタはaws_elasticache_replication_groupで作る

 

    単一キャッシュノードのクラスタなら、aws_elasticache_clusterでも作れる

印象

    AWS上では両方(Memcache/Redis)共にElastiCacheクラスターってなっててわかりにくい!!!
bannerAds