Skip to content

Terraform module witch creates a Redis cluster within the Yandex.Cloud

License

Notifications You must be signed in to change notification settings

glavk/terraform-yandex-redis

Repository files navigation

Yandex.Cloud Redis cluster module

Terraform module which creates managed Redis cluster on Yandex.Cloud.

Examples

Cache without persistence

A simple Redis cluster for cache with key eviction and no key sync to disk.

locals {
  zone   = "ru-central1-a"
  folder = "your_folder_id"

  network_name = "private"
  subnet_name  = "private-a"
}

data "yandex_vpc_network" "private" {
  folder_id = local.folder
  name      = local.network_name
}

data "yandex_vpc_subnet" "private" {
  name = local.subnet_name
}

module "cache" {
  source  = "glavk/redis/yandex"
  version = "0.1.6"

  name        = "cache"
  description = "Cache in-memory without sync to disk"

  network_id = data.yandex_vpc_network.private.id

  persistence_mode = "OFF"
  password         = "secretpassword"
  # default policy is NOEVICTION
  maxmemory_policy = "ALLKEYS_LRU"

  hosts = {
    host1 = {
      zone      = local.zone
      subnet_id = data.yandex_vpc_subnet.private.id
    }
  }

  zone = local.zone
}

Sharded one zone cluster

A simple sharded Redis cluster with key eviction and key sync to disk in one zone.

locals {
  zone   = "ru-central1-a"
  folder = "your_folder_id"

  network_name = "private"
  subnet_name  = "private-a"
}

data "yandex_vpc_network" "private" {
  folder_id = local.folder
  name      = local.network_name
}

data "yandex_vpc_subnet" "private" {
  name = local.subnet_name
}

module "sharded_zone" {
  source  = "glavk/redis/yandex"
  version = "0.1.6"

  name        = "sharded_cluster"
  description = "Sharded zonal cluster"

  network_id = data.yandex_vpc_network.private.id

  sharded          = true
  password         = "secretpassword"
  # default policy is NOEVICTION
  maxmemory_policy = "ALLKEYS_LRU"


  hosts = {
    host1 = {
      zone      = local.zone
      subnet_id = data.yandex_vpc_subnet.private.id
    }
    host2 = {
      zone      = local.zone
      subnet_id = data.yandex_vpc_subnet.private.id
    }
    host3 = {
      zone      = local.zone
      subnet_id = data.yandex_vpc_subnet.private.id
    }
  }

  zone = local.zone
}

Requirements

Name Version
terraform >= 0.13
yandex >= 0.47.0

Providers

Name Version
yandex >= 0.47.0

Modules

No modules.

Resources

Name Type
yandex_mdb_redis_cluster.this resource

Inputs

Name Description Type Default Required
assign_public_ip Sets whether the host should get a public IP address or not bool false no
client_output_buffer_limit_normal Normal clients output buffer limits (bytes) string "1073741824 536870912 60" no
client_output_buffer_limit_pubsub Pubsub clients output buffer limits (bytes) string "1073741824 536870912 60" no
databases Number of databases (changing requires redis-server restart) number 16 no
day Day of week for maintenance window if window type is weekly string "MON" no
deletion_protection Inhibits deletion of the cluster bool false no
description Description of the Redis cluster string "Redis cluster" no
disk_size Volume of the storage available to a host, in gigabytes number 16 no
disk_type_id Type of the storage of Redis hosts - environment default is used if missing string "network-ssd" no
environment Deployment environment of the Redis cluster. Can be either PRESTABLE or PRODUCTION string "PRODUCTION" no
folder_id The ID of the folder that the resource belongs to. If it is not provided, the default provider folder is used string null no
hosts Redis hosts definition
map(object({
zone = string
subnet_id = string
}))
{
"host1": {
"subnet_id": "",
"zone": "ru-central1-a"
},
"host2": {
"subnet_id": "",
"zone": "ru-central1-a"
}
}
no
hour Hour of day in UTC time zone (1-24) for maintenance window if window type is weekly number 24 no
maxmemory_policy Redis key eviction policy for a dataset that reaches maximum memory. See https://docs.redis.com/latest/rs/databases/memory-performance/eviction-policy/ string "NOEVICTION" no
name Name of the Redis cluster string n/a yes
network_id ID of the network, to which the Redis cluster belongs string n/a yes
notify_keyspace_events Select the events that Redis will notify among a set of classes string "" no
password Password for the Redis cluster string n/a yes
persistence_mode Persistence mode. Must be one of OFF or ON string "ON" no
redis_version Version of Redis string "6.2" no
replica_priority Replica priority of a current replica (usable for non-sharded only) any null no
resource_preset_id The ID of the preset for computational resources available to a host (CPU, memory etc.) string "hm3-c2-m8" no
security_group_ids A set of ids of security groups assigned to hosts of the cluster list(string) [] no
sharded Redis Cluster mode enabled/disabled bool false no
slowlog_log_slower_than Log slow queries below this number in microseconds number 10000 no
slowlog_max_len Slow queries log length number 1000 no
subnet_id The ID of the subnet, to which the host belongs. The subnet must be a part of the network to which the cluster belongs string null no
timeout Close the connection after a client is idle for N seconds number 0 no
tls_enabled TLS support mode enabled/disabled bool false no
type Type of maintenance window. Can be either ANYTIME or WEEKLY. A day and hour of window need to be specified with weekly window string "ANYTIME" no
zone The availability zone where the Redis host will be created. See https://cloud.yandex.com/en/docs/overview/concepts/geo-scope string n/a yes

Outputs

Name Description
fqdn The fully qualified domain name of the host
health Aggregated health of the cluster. Can be either ALIVE, DEGRADED, DEAD or HEALTH_UNKNOWN
shard_name The name of the shard to which the host belongs
status Status of the cluster. Can be either CREATING, STARTING, RUNNING, UPDATING, STOPPING, STOPPED, ERROR or STATUS_UNKNOWN

About

Terraform module witch creates a Redis cluster within the Yandex.Cloud

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages