実践Terraform ch13 データストア (2/2)

Terraform勉強メモ

出典: 


[https://github.com/wand2016/terraformch13example_1:embed:cite]

ElastiCache

ElastiCacheパラメータグループ

  • クラスタモード有効/無効を選択する
  • 公式
  • 今回は無効
resource "aws_elasticache_parameter_group" "example" {
  name = "example"
  family = "redis5.0"

  parameter {
    name = "cluster-enabled"
    value = "no"
  }
}

ElastiCacheサブネットグループ

resource "aws_elasticache_subnet_group" "example" {
  name = "example"
  subnet_ids = [aws_subnet.private_0.id, aws_subnet.private_1.id]
}
  • フェイルオーバー設定で使用

ElastiCacheレプリケーショングループ

resource "aws_elasticache_replication_group" "example" {
  replication_group_id = "example"
  replication_group_description = "Cluter Disabled"
  engine = "redis"
  engine_version = "5.0.4"
  number_cache_clusters = 3
  node_type = "cache.m3.medium"
  snapshot_window = "09:10-10:10"
  snapshot_retention_limit = 7
  maintenance_window = "mon:10:40-mon:11:40"
  automatic_failover_enabled = true
  port = var.redis_port
  apply_immediately = false
  security_group_ids = [module.redis_sg.security_group_id]
  parameter_group_name = aws_elasticache_parameter_group.example.name
  subnet_group_name = aws_elasticache_subnet_group.example.name
}

module "redis_sg" {
  source = "./security_group"
  name = "redis-sg"
  vpc_id = aws_vpc.example.id
  port = var.redis_port
  cidr_blocks = [aws_vpc.example.cidr_block]
}
  • automatic_failover_enabled = true

  • apply_immediately = false

    • 公式/
    • trueならば下記属性の変更はすぐに適用される

      • ノードタイプ
      • エンジンバージョン
      • クラスターのノード数
    • falseならば次のメンテナンス期間に適用される

20200324224421