28
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

terraformでElastiCache(Redis)のClusterを作るときにハマったこと

Last updated at Posted at 2017-11-05

前提

  • terraform v0.10.3

この記事で言いたいこと

最初にハマったこと

  • Redisの複数キャッシュノードのクラスタを作成しようとして、 aws_elasticache_clusterで定義を書いた
redis.tf
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公式を見たら

(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台だけだと・・・・なんだこの制限?

調べた結果

redis.tf
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
}

まとめ

感想

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

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
28
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?