8000
Skip to content

terraform-yacloud-modules/terraform-yandex-redis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

170 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Yandex Cloud Managed Redis Terraform module

Terraform module which creates Yandex Cloud Managed Service for Redis resources.

Usage

See examples directory for working examples to reference:

Redis cluster without persistence

A simple one host Redis cluster with key eviction and no key sync to disk.

module "redis_simple" {
  source  = "terraform-yacloud-modules/redis/yandex"

  name        = "simple_cluster"
  description = "Simple in-memory cluster 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 Redis cluster

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

module "redis_sharded" {
  source  = "terraform-yacloud-modules/redis/yandex"

  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
}

Examples

Examples codified under the examples are intended to give users references for how to use the module(s) as well as testing/validating changes to the source code of the module. If contributing to the project, please be sure to make any appropriate updates to the relevant examples to allow maintainers to test your changes and to keep the examples up to date for users. Thank you!

Requirements

Name Version
terraform >= 1.3
random >= 3.0
yandex >= 0.47.0

Providers

Name Version
random >= 3.0
yandex >= 0.47.0

Modules

No modules.

Resources

Name Type
random_password.user resource
yandex_mdb_redis_cluster.this resource
yandex_mdb_redis_user.this resource

Inputs

Name Description Type Default Required
access Access policy for DataLens and WebSQL
object({
data_lens = optional(bool)
web_sql = optional(bool)
})
null no
allow_data_loss Allows some data to be lost for faster switchover/restart bool false no
announce_hostnames Enable FQDN instead of IP addresses in CLUSTER SLOTS command bool false no
assign_public_ip Sets whether the host should get a public IP address or not bool false no
auth_sentinel Allow ACL based authentication in Redis Sentinel bool false no
backup_window_start Time to start the daily backup, in the UTC timezone. The structure is documented below
object({
hours = number
minutes = optional(number)
})
null 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
cluster_allow_pubsubshard_when_down Permits Pub/Sub shard operations when cluster is down bool false no
cluster_allow_reads_when_down Allows read operations when cluster is down bool false no
cluster_require_full_coverage Controls whether all hash slots must be covered by nodes bool true 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_encryption_key_id ID of the KMS key used for disk encryption string null no
disk_size Volume of the storage available to a host, in gigabytes number 20 no
disk_size_autoscaling Disk size autoscaling configuration
object({
disk_size_limit = number
planned_usage_threshold = optional(number)
emergency_usage_threshold = optional(number)
})
null 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(any) n/a yes
hour Hour of day in UTC time zone (1-24) for maintenance window if window type is weekly number 24 no
io_threads_allowed Enable IO threads for Redis (improves performance for concurrent connections) bool false no
labels A set of key/value label pairs to assign to the Redis cluster map(string) {} no
lfu_decay_time LFU (Least Frequently Used) decay time in minutes - controls how quickly access frequency counters are reduced number 1 no
lfu_log_factor LFU logarithmic counter increment factor - higher values mean less frequent counter increments, affecting eviction sensitivity (range: 0-255) number 10 no
lua_time_limit Maximum time in milliseconds for Lua scripts number 5000 no
maxmemory_percent Redis maxmemory usage in percent number 75 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 "7.2-valkey" no
repl_backlog_size_percent Replication backlog size as a percentage of flavor maxmemory number 25 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.). See https://cloud.yandex.com/en/docs/managed-redis/concepts/instance-types string "b3-c1-m4" 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
timeout Close the connection after a client is idle for N seconds number 0 no
timeouts Timeout configuration for create, update, and delete operations
object({
create = optional(string)
update = optional(string)
delete = optional(string)
})
null no
tls_enabled TLS support mode enabled/disabled bool false no
turn_before_switchover Allows to turn before switchover in RDSync 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
use_luajit Enable LuaJIT engine bool false no
user_name Name of the Redis user string null no
user_password Password for the Redis user. If not set with user_name, will be genereated randomly string null no
user_permissions_categories Redis command categories allowed for the user. Leave empty unless needed string "" no
user_permissions_commands Redis commands allowed for the user (e.g. '+get +set') string "+get +set" no
user_permissions_patterns Key patterns allowed for the user. Must start with , %R, %W~ or %RW~ (e.g. '~*' for all keys) string "~*" no
zset_max_listpack_entries Controls max number of entries in zset before conversion number 128 no

Outputs

Name Description
config Configuration of the Redis cluster
created_at Creation timestamp of the cluster
deletion_protection Inhibits deletion of the cluster
description Description of the Redis cluster
environment Deployment environment of the Redis cluster
folder_id ID of the folder that the resource belongs to
fqdn FQDN for the Redis cluster
health Aggregated health of the cluster
hosts A list of hosts in the Redis cluster
id ID of the Redis cluster
labels A set of key/value label pairs to assign to the Redis cluster
maintenance_window Maintenance policy of the Redis cluster
name Name of the Redis cluster
network_id ID of the network to which the Redis cluster belongs
persistence_mode Persistence mode of the Redis cluster
resources Resources allocated to hosts of the Redis cluster
security_group_ids A set of ids of security groups assigned to hosts of the cluster
sharded Redis Cluster mode enabled/disabled
tls_enabled TLS support mode enabled/disabled
user_password Password of the Redis user (generated if not provided)

License

Apache-2.0 Licensed. See LICENSE.

Requirements

Name Version
terraform >= 1.3
yandex >= 0.47.0

Providers

Name Version
yandex 0.164.0

Modules

No modules.

Resources

Name Type
yandex_mdb_redis_cluster.this resource

Inputs

Name Description Type Default Required
access Access policy for DataLens and WebSQL
object({
data_lens = optional(bool)
web_sql = optional(bool)
})
null no
announce_hostnames Enable FQDN instead of IP addresses in CLUSTER SLOTS command bool false no
assign_public_ip Sets whether the host should get a public IP address or not bool false no
auth_sentinel Allow ACL based authentication in Redis Sentinel bool false no
backup_window_start Time to start the daily backup, in the UTC timezone. The structure is documented below
object({
hours = number
minutes = optional(number)
})
null 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_encryption_key_id ID of the KMS key used for disk encryption string null no
disk_size Volume of the storage available to a host, in gigabytes number 20 no
disk_size_autoscaling Disk size autoscaling configuration
object({
disk_size_limit = number
planned_usage_threshold = optional(number)
emergency_usage_threshold = optional(number)
})
null 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(any) n/a yes
hour Hour of day in UTC time zone (1-24) for maintenance window if window type is weekly number 24 no
io_threads_allowed Enable IO threads for Redis (improves performance for concurrent connections) bool false no
labels A set of key/value label pairs to assign to the Redis cluster map(string) {} 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 "7.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.). See https://cloud.yandex.com/en/docs/managed-redis/concepts/instance-types string "b3-c1-m4" 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
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
use_luajit Enable LuaJIT engine bool false no

Outputs

Name Description
config Configuration of the Redis cluster
created_at Creation timestamp of the cluster
deletion_protection Inhibits deletion of the cluster
description Description of the Redis cluster
environment Deployment environment of the Redis cluster
folder_id ID of the folder that the resource belongs to
fqdn FQDN for the Redis cluster
health Aggregated health of the cluster
hosts A list of hosts in the Redis cluster
id ID of the Redis cluster
labels A set of key/value label pairs to assign to the Redis cluster
maintenance_window Maintenance policy of the Redis cluster
name Name of the Redis cluster
network_id ID of the network to which the Redis cluster belongs
persistence_mode Persistence mode of the Redis cluster
resources Resources allocated to hosts of the Redis cluster
security_group_ids A set of ids of security groups assigned to hosts of the cluster
sharded Redis Cluster mode enabled/disabled
tls_enabled TLS support mode enabled/disabled
0