Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
    • Yandex Cloud Partner program
  • Blog
  • Pricing
  • Documentation
© 2025 Direct Cursus Technology L.L.C.
Yandex Managed Service for Valkey™
  • Getting started
    • All guides
      • Information about existing clusters
      • Creating a cluster
      • Updating cluster settings
      • Valkey™ version upgrade
      • Stopping and starting a cluster
      • Managing cluster hosts
      • Migrating hosts to a different availability zone
      • Managing backups
      • Deleting a cluster
  • Access management
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Public materials
  • Release notes
  • FAQ

In this article:

  • Creating a cluster
  • Creating a cluster copy
  • Examples
  • Creating a single-host cluster
  • Creating a sharded cluster with a single shard
  • Creating a sharded cluster with three shards
  1. Step-by-step guides
  2. Clusters
  3. Creating a cluster

Creating a Valkey™ cluster

Written by
Yandex Cloud
Updated at May 13, 2025
  • Creating a cluster
  • Creating a cluster copy
  • Examples
    • Creating a single-host cluster
    • Creating a sharded cluster with a single shard
    • Creating a sharded cluster with three shards

A Valkey™ cluster is one or more database hosts between which you can configure replication. Replication is enabled by default in any cluster consisting of more than one host: the master host accepts write requests and asynchronously duplicates changes on replicas.

For more information about Yandex Managed Service for Valkey™ cluster structure, see Resource relationships.

Note

  • The number of hosts you can create together with a Valkey™ cluster depends on the selected disk type and host class as well as on whether sharding is enabled.
  • Available disk types depend on the selected host class.

Creating a cluster

To create a Yandex Managed Service for Valkey™ cluster, you will need the vpc.user and managed-redis.editor roles or higher. For more information on assigning roles, see the Identity and Access Management documentation.

Note

The following restrictions apply when creating sharded clusters:

  • You can create a single-shard cluster using the CLI, Terraform, or API.
  • You cannot create a cluster with two shards, but you can add a shard to an existing single-shard cluster.
  • You can create a cluster with three or more shards using the management console, CLI, Terraform, or API.

There are no restrictions for non-sharded clusters.

Management console
CLI
Terraform
REST API
gRPC API

To create a Yandex Managed Service for Valkey™ cluster:

  1. In the management console, go to the folder to create a DB cluster in.

  2. Select Yandex Managed Service for Valkey™.

  3. Click Create cluster.

  4. Under Basic parameters:

    • Enter a name for the cluster in the Cluster name field. It must be unique within the folder.

    • (Optional) Add a cluster description.

    • Select the environment where you want to create the cluster (you cannot change the environment once the cluster is created):

      • PRODUCTION: For stable versions of your apps.
      • PRESTABLE: For testing purposes. The prestable environment is similar to the production environment and likewise covered by the SLA, but it is the first to get new functionalities, improvements, and bug fixes. In the prestable environment, you can test compatibility of new versions with your application.
    • Select the DBMS version.

    • Optionally, add labels.

    • If necessary, enable cluster sharding.

      Warning

      You cannot disable sharding in a cluster where it is already enabled. You can create a non-sharded cluster and enable sharding later, if required.

    • If required, enable support for encrypted TLS connections to the cluster.

      Warning

      You can only enable connection encryption when creating a new cluster. You cannot disable encryption for a cluster that it is enabled for.

    • If required, enable the use of FQDNs instead of IP addresses.

      Note

      Some clients do not support this setting and will fail to connect to the cluster hosts. Such clients expect an IP address and will produce errors if you provide an FQDN instead.

    • Select the data persistence settings.

  5. Under Resources:

    • Select a platform in the Platform field.

    • Specify the Type of the VM to deploy hosts on.

    • Select Host class.

    • Select the disk type:

      • Either the more flexible network SSD (network-ssd) or non-replicated SSD (network-ssd-nonreplicated) storage
      • Or the faster local SSD (local-ssd) storage

      The selected type determines the increments in which you can change your disk size:

      • Network SSD storage: In increments of 1 GB.
      • Local SSD storage:
        • For Intel Broadwell and Intel Cascade Lake: In increments of 100 GB.
        • For Intel Ice Lake: In increments of 368 GB.
      • Non-replicated SSD storage: In increments of 93 GB.
    • Select the storage size. The available storage size is limited by quotas and limits.

  6. Under Network settings, select:

    • Cloud network for the cluster.
    • Security groups for the cluster network traffic. You may need to additionally set up security groups to be able to connect to the cluster.
  7. Under Hosts, configure the hosts:

    • To change the settings of an individual host, click the icon in the line with its name.

      • Availability zone: Select an availability zone.
      • Subnet: Specify a subnet in the selected availability zone.
      • Public access: Enables access to the host from the internet if the cluster is created with TLS support enabled.
      • Master priority: Host priority for assignment as a master if the primary master fails.
      • Shard name: Enables you to change the shard name for the host. The field is available only if the cluster is created with Cluster sharding enabled.
    • To add hosts to the cluster, click Add host.

    If you enabled sharding in the cluster and chose the local-ssd disk type, add at least two hosts per shard.

  8. Under DBMS settings:

    • In the Password field, enter the user password.

      The password must be between 8 and 128 characters long. The password must meet the [a-zA-Z0-9@=+?*.,!&#$^<>_-]* regular expression.

    • Configure the DBMS settings, if required.

  9. Under Service settings, configure the additional cluster settings:

    • Backup start time (UTC): UTC time when you want to start creating a cluster backup (in 24-hour format). If the time is not set, the backup will start at 22:00 UTC.

    • Maintenance window: Maintenance window settings:

      • To enable maintenance at any time, select arbitrary (default).
      • To specify the preferred maintenance start time, select by schedule and specify the desired day of the week and UTC hour. For example, you can choose a time when the cluster is least loaded.

      Maintenance operations are carried out both on enabled and disabled clusters. They may include updating the DBMS, applying patches, and so on.

    • Deletion protection: Manages cluster protection against accidental deletion.

      Even with cluster deletion protection enabled, one can still delete a user or database or connect manually and delete the database contents.

  10. Click Create cluster.

If you do not have the Yandex Cloud (CLI) command line interface yet, install and initialize it.

The folder specified when creating the CLI profile is used by default. To change the default folder, use the yc config set folder-id <folder_ID> command. You can specify a different folder using the --folder-name or --folder-id parameter.

To create a Yandex Managed Service for Valkey™ cluster:

  1. Check whether the folder has any subnets for the cluster hosts:

    yc vpc subnet list
    

    If there are no subnets in the folder, create the required subnets in VPC.

  2. View the description of the CLI command to create a cluster:

    yc managed-redis cluster create --help
    
  3. When you create a cluster from the CLI, you cannot explicitly specify the host type and amount of RAM. Choose the applicable host class instead. To see what host classes are available, run the command:

    yc managed-redis resource-preset list
    
  4. Specify the cluster parameters in the create command (not all flags are shown in the example):

    yc managed-redis cluster create \
      --name <cluster_name> \
      --environment <environment> \
      --network-name <network_name> \
      --host zone-id=<availability_zone>,`
            `subnet-id=<subnet_ID>,`
            `assign-public-ip=<public_access>,`
            `replica-priority=<host_priority> \
      --security-group-ids <list_of_security_group_IDs> \
      --enable-tls \
      --resource-preset <host_class> \
      --disk-size <storage_size_in_GB> \
      --disk-type-id <network-ssd|network-ssd-nonreplicated|local-ssd> \
      --password=<user_password> \
      --backup-window-start <time> \
      --deletion-protection \
      --announce-hostnames <using_FQDNs_instead_of_IP_addresses>
    

    Where:

    • --environment: Environment, prestable or production.

    • --host: Host parameters:

      • zone-id: Availability zone.
      • subnet-id: Subnet ID. Specify if two or more subnets are created in the selected availability zone.
      • assign-public-ip: Internet access to the host via a public IP address, true or false.
      • replica-priority: Host priority for assignment as a master if the primary master fails.
    • --disk-type-id: Disk type.

    • --websql-access: Enables SQL queries against cluster databases from the Yandex Cloud management console using Yandex WebSQL. The default value is false.

    • --backup-window-start: Backup start time in HH:MM:SS format.

    • --deletion-protection: Cluster protection from accidental deletion, true or false.

      Even with deletion protection enabled, one can still connect to the cluster manually and delete the data.

    • --announce-hostnames: Enables or disables using FQDNs instead of IP addresses: true or false.

      Note

      Some clients do not support this setting and will fail to connect to the cluster hosts. Such clients expect an IP address and will produce errors if you provide an FQDN instead.

    You need to specify the subnet-id if the selected availability zone has two or more subnets.

    The password must be between 8 and 128 characters long. The password must meet the [a-zA-Z0-9@=+?*.,!&#$^<>_-]* regular expression.

    If you are creating a sharded cluster with the local-ssd disk type, specify at least two hosts per shard in the command.

    Note

    When creating a cluster, the anytime maintenance mode is set by default. You can set a specific maintenance period when updating the cluster settings.

With Terraform, you can quickly create a cloud infrastructure in Yandex Cloud and manage it using configuration files. These files store the infrastructure description written in HashiCorp Configuration Language (HCL). If you change the configuration files, Terraform automatically detects which part of your configuration is already deployed, and what should be added or removed.

Terraform is distributed under the Business Source License. The Yandex Cloud provider for Terraform is distributed under the MPL-2.0 license.

For more information about the provider resources, see the documentation on the Terraform website or mirror website.

If you do not have Terraform yet, install it and configure its Yandex Cloud provider.

To create a Yandex Managed Service for Valkey™ cluster:

  1. In the configuration file, describe the resources you want to create:

    • Database cluster: Description of the cluster and its hosts. You can also configure DBMS settings here if necessary.

    • Network: Description of the cloud network where the cluster will be hosted. If you already have a suitable network, you do not need to describe it again.

    • Subnets: Subnets to connect the cluster hosts to. If you already have suitable subnets, you do not need to describe them again.

    Sample configuration file structure for creating a non-sharded cluster with SSL support:

    resource "yandex_mdb_redis_cluster" "<cluster_name>" {
      name                = "<cluster_name>"
      environment         = "<environment>"
      network_id          = "<network_ID>"
      security_group_ids  = [ "<list_of_security_group_IDs>" ]
      tls_enabled         = true
      deletion_protection = <cluster_deletion_protection>
      announce_hostnames  = <using_FQDNs_instead_of_IP_addresses>
    
      config {
        password = "<password>"
        version  = "<Valkey™_version>"
      }
    
      resources {
        resource_preset_id = "<host_class>"
        disk_type_id       = "<disk_type>"
        disk_size          = <storage_size_in_GB>
      }
    
      host {
        zone             = "<availability_zone>"
        subnet_id        = "<subnet_ID>"
        assign_public_ip = <public_access>
        replica_priority = <host_priority>
      }
    }
    
    resource "yandex_vpc_network" "<network_name>" { name = "<network_name>" }
    
    resource "yandex_vpc_subnet" "<subnet_name>" {
      name           = "<subnet_name>"
      zone           = "<availability_zone>"
      network_id     = "<network_ID>"
      v4_cidr_blocks = ["<range>"]
    }
    

    Where:

    • environment: Environment, PRESTABLE or PRODUCTION.

    • deletion_protection: Cluster protection from accidental deletion, true or false.

      Even with deletion protection enabled, one can still connect to the cluster manually and delete the data.

    • announce_hostnames: Enables or disables using FQDNs instead of IP addresses: true or false.

      Note

      Some clients do not support this setting and will fail to connect to the cluster hosts. Such clients expect an IP address and will produce errors if you provide an FQDN instead.

    • version: Valkey™ version, 7.2.

    • host: Host parameters:

      • zone_id: Availability zone.
      • subnet_id: ID of a subnet in the selected availability zone.
      • assign_public_ip: Public access to the host, true or false.
      • replica_priority: Host priority for assignment as a master if the primary master fails.

    The password must be between 8 and 128 characters long. The password must meet the [a-zA-Z0-9@=+?*.,!&#$^<>_-]* regular expression.

    If you are creating a sharded cluster with the local-ssd disk type, specify at least two hosts per shard in the configuration file.

    To set up the maintenance window (for example, for disabled clusters), add the maintenance_window section to the cluster description:

    resource "yandex_mdb_redis_cluster" "<cluster_name>" {
      ...
      maintenance_window {
        type = <maintenance_type>
        day  = <day_of_week>
        hour = <hour>
      }
      ...
    }
    

    Where:

    • type: Maintenance type. The possible values include:
      • anytime: Anytime.
      • weekly: By schedule.
    • day: Day of the week for the weekly type in DDD format, e.g., MON.
    • hour: Hour of the day for the weekly type in the HH format, e.g., 21.

    To learn more about the resources you can create with Terraform, see the Terraform documentation.

  2. Make sure the settings are correct.

    1. In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.

    2. Run this command:

      terraform validate
      

      Terraform will show any errors found in your configuration files.

  3. Create a cluster.

    1. Run this command to view the planned changes:

      terraform plan
      

      If you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.

    2. If everything looks correct, apply the changes:

      1. Run this command:

        terraform apply
        
      2. Confirm updating the resources.

      3. Wait for the operation to complete.

    After this, all required resources will be created in the specified folder, and the FQDNs of the cluster hosts will be displayed in the terminal. You can check the new resources and their settings using the management console.

    Time limits

    A Terraform provider sets the timeout for Yandex Managed Service for Valkey™ cluster operations:

    • Creating a cluster, including by restoring one from a backup: 15 minutes.
    • Editing a cluster: 60 minutes.
    • Deleting a cluster: 15 minutes.

    Operations exceeding the set timeout are interrupted.

    How do I change these limits?

    Add the timeouts block to the cluster description, for example:

    resource "yandex_mdb_redis_cluster" "<cluster_name>" {
      ...
      timeouts {
        create = "1h30m" # 1 hour 30 minutes
        update = "2h"    # 2 hours
        delete = "30m"   # 30 minutes
      }
    }
    
  1. Get an IAM token for API authentication and put it into the environment variable:

    export IAM_TOKEN="<IAM_token>"
    
  2. Create a file named body.json and add the following contents to it:

    {
      "folderId": "<folder_ID>",
      "name": "<cluster_name>",
      "environment": "<environment>",
      "configSpec": {
        "version": "<Valkey™_version>",
        "resources": {
          "resourcePresetId": "<host_class>",
          "diskSize": "<storage_size_in_bytes>",
          "diskTypeId": "<disk_type>"
        },
        "access": {
          "webSql": <access_from_WebSQL>
        },
        "redis": {
          "password": "<user_password>"
        }
      },
      "hostSpecs": [
        {
          "zoneId": "<availability_zone>",
          "subnetId": "<subnet_ID>",
          "shardName": "<shard_name>",
          "replicaPriority": "<host_priority>",
          "assignPublicIp": <public_access_to_cluster_host>
        },
        { <similar_configuration_for_host_2> },
        { ... },
        { <similar_configuration_for_host_N> }
      ],
      "networkId": "<network_ID>",
      "sharded": <cluster_sharding>,
      "securityGroupIds": [
        "<security_group_1_ID>",
        "<security_group_2_ID>",
        ...
        "<security_group_N_ID>"
      ],
      "tlsEnabled": <encrypted_TLS_connection_support>,
      "deletionProtection": <cluster_deletion_protection>,
      "announceHostnames": <using_FQDNs_instead_of_IP_addresses>
    }
    

    Where:

    • folderId: Folder ID. You can request it with the list of folders in the cloud.

    • name: Cluster name.

    • environment: Environment, PRESTABLE or PRODUCTION.

    • configSpec: Cluster settings:

      • version: Valkey™ version.

      • resources: Cluster resources:

        • resourcePresetId: Host class.
        • diskSize: Disk size in bytes.
        • diskTypeId: Disk type.
      • access.webSql: Access to cluster databases from the Yandex Cloud management console through Yandex WebSQL, true or false.

      • redis.password: User password.

    • hostSpecs: Host parameters:

      • zoneId: Availability zone.
      • subnetId: Subnet ID. Specify if two or more subnets are created in the selected availability zone.
      • shardName: Shard name for the host. Only used if the sharded parameter is set to true.
      • replicaPriority: Host priority for assignment as a master if the primary master fails.
      • assignPublicIp: Internet access to the host via a public IP address, true or false. You can enable public access only if the tlsEnabled parameter is set to true.
    • networkId: ID of the network the cluster will be in.

    • sharded: Cluster sharding, true or false.

      Warning

      You cannot disable sharding in a cluster where it is already enabled. You can create a non-sharded cluster and enable sharding later, if required.

      If you are creating a sharded cluster with the local-ssd disk type, specify at least two hosts per shard, adding the appropriate number of hostSpecs blocks.

    • securityGroupIds: Security group IDs.

    • tlsEnabled: Support for encrypted TLS connections to the cluster, true or false.

      Warning

      You can only enable connection encryption when creating a new cluster. You cannot disable encryption for a cluster that it is enabled for.

    • deletionProtection: Cluster protection from accidental deletion, true or false.

      Even with deletion protection enabled, one can still connect to the cluster manually and delete the data.

    • announceHostnames: Using FQDNs instead of IP addresses, true or false.

      Note

      Some clients do not support this setting and will fail to connect to the cluster hosts. Such clients expect an IP address and will produce errors if you provide an FQDN instead.

  3. Use the Cluster.Create method and send the following request, e.g., via cURL:

    curl \
        --request POST \
        --header "Authorization: Bearer $IAM_TOKEN" \
        --header "Content-Type: application/json" \
        --url 'https://mdb.api.cloud.yandex.net/managed-redis/v1/clusters' \
        --data "@body.json"
    
  4. View the server response to make sure the request was successful.

  1. Get an IAM token for API authentication and put it into the environment variable:

    export IAM_TOKEN="<IAM_token>"
    
  2. Clone the cloudapi repository:

    cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
    

    Below, we assume the repository contents are stored in the ~/cloudapi/ directory.

  3. Create a file named body.json and add the following contents to it:

    {
      "folder_id": "<folder_ID>",
      "name": "<cluster_name>",
      "environment": "<environment>",
      "config_spec": {
        "version": "<Valkey™_version>",
        "resources": {
          "resource_preset_id": "<host_class>",
          "disk_size": "<storage_size_in_bytes>",
          "disk_type_id": "<disk_type>"
        },
        "access": {
          "web_sql": <access_from_WebSQL>
        },
        "redis": {
          "password": "<user_password>"
        }
      },
      "host_specs": [
        {
          "zone_id": "<availability_zone>",
          "subnet_id": "<subnet_ID>",
          "shard_name": "<shard_name>",
          "replica_priority": "<host_priority>",
          "assign_public_ip": <public_access_to_cluster_host>
        },
        { <similar_configuration_for_host_2> },
        { ... },
        { <similar_configuration_for_host_N> }
      ],
      "network_id": "<network_ID>",
      "sharded": <cluster_sharding>,
      "security_group_ids": [
        "<security_group_1_ID>",
        "<security_group_2_ID>",
        ...
        "<security_group_N_ID>"
      ],
      "tls_enabled": <encrypted_TLS_connection_support>,
      "deletion_protection": <cluster_deletion_protection>,
      "announce_hostnames": <using_FQDNs_instead_of_IP_addresses>
    }
    

    Where:

    • folder_id: Folder ID. You can request it with the list of folders in the cloud.

    • name: Cluster name.

    • environment: Environment, PRESTABLE or PRODUCTION.

    • config_spec: Cluster settings:

      • version: Valkey™ version.

      • resources: Cluster resources:

        • resource_preset_id: Host class.
        • disk_size: Disk size in bytes.
        • disk_type_id: Disk type.
      • access.web_sql: Access to cluster databases from the Yandex Cloud management console through Yandex WebSQL, true or false.

      • redis.password: User password.

    • host_specs: Host parameters:

      • zone_id: Availability zone.
      • subnet_id: Subnet ID. Specify if two or more subnets are created in the selected availability zone.
      • shard_name: Shard name for the host. Only used if the sharded parameter is set to true.
      • replica_priority: Host priority for assignment as a master if the primary master fails.
      • assign_public_ip: Internet access to the host via a public IP address, true or false. You can enable public access only if the tls_enabled parameter is set to true.
    • network_id: ID of the network the cluster will be in.

    • sharded: Cluster sharding, true or false.

      Warning

      You cannot disable sharding in a cluster where it is already enabled. You can create a non-sharded cluster and enable sharding later, if required.

      If you are creating a sharded cluster with the local-ssd disk type, specify at least two hosts per shard, adding the appropriate number of host_specs blocks.

    • security_group_ids: Security group IDs.

    • tls_enabled: Support for encrypted TLS connections to the cluster, true or false.

      Warning

      You can only enable connection encryption when creating a new cluster. You cannot disable encryption for a cluster that it is enabled for.

    • deletion_protection: Cluster protection from accidental deletion, true or false.

      Even with deletion protection enabled, one can still connect to the cluster manually and delete the data.

    • announce_hostnames: Using FQDNs instead of IP addresses, true or false.

      Note

      Some clients do not support this setting and will fail to connect to the cluster hosts. Such clients expect an IP address and will produce errors if you provide an FQDN instead.

  4. Use the ClusterService.Create call and send the following request, e.g., via gRPCurl:

    grpcurl \
        -format json \
        -import-path ~/cloudapi/ \
        -import-path ~/cloudapi/third_party/googleapis/ \
        -proto ~/cloudapi/yandex/cloud/mdb/redis/v1/cluster_service.proto \
        -rpc-header "Authorization: Bearer $IAM_TOKEN" \
        -d @ \
        mdb.api.cloud.yandex.net:443 \
        yandex.cloud.mdb.redis.v1.ClusterService.Create \
        < body.json
    
  5. View the server response to make sure the request was successful.

Warning

If you specified security group IDs when creating a cluster, you may also need to additionally configure security groups to connect to the cluster.

Creating a cluster copy

You can create a Valkey™ cluster using the settings of another one created earlier. To do so, you need to import the configuration of the source Valkey™ cluster to Terraform. This way you can either create an identical copy or use the imported configuration as the baseline and modify it as needed. Importing a configuration is a good idea when the source Valkey™ cluster has a lot of settings and you need to create a similar one.

To create a Valkey™ cluster copy:

Terraform
  1. If you do not have Terraform yet, install it.

  2. Get the authentication credentials. You can add them to environment variables or specify them later in the provider configuration file.

  3. Configure and initialize a provider. There is no need to create a provider configuration file manually, you can download it.

  4. Place the configuration file in a separate working directory and specify the parameter values. If you did not add the authentication credentials to environment variables, specify them in the configuration file.

  5. In the same working directory, place a .tf file with the following contents:

    resource "yandex_mdb_redis_cluster" "old" { }
    
  6. Write the ID of the initial Valkey™ cluster to the environment variable:

    export REDIS_CLUSTER_ID=<cluster_ID>
    

    You can request the ID with the list of clusters in the folder.

  7. Import the settings of the initial Valkey™ cluster into the Terraform configuration:

    terraform import yandex_mdb_redis_cluster.old ${REDIS_CLUSTER_ID}
    
  8. Get the imported configuration:

    terraform show
    
  9. Copy it from the terminal and paste it into the .tf file.

  10. Place the file in the new imported-cluster directory.

  11. Modify the copied configuration so that you can create a new cluster from it:

    • Specify the new cluster name in the resource string and the name parameter.
    • Delete the created_at, health, id, and status parameters.
    • Add the password parameter to the config section.
    • If the config section has notify_keyspace_events = "\"\"", delete this parameter.
    • If sharded = false is specified, delete the shard_name parameters in the host sections.
    • If the maintenance_window section has type = "ANYTIME", delete the hour parameter.
    • Optionally, make further changes if you need to customize the configuration.
  12. Get the authentication credentials in the imported-cluster directory.

  13. In the same directory, configure and initialize a provider. There is no need to create a provider configuration file manually, you can download it.

  14. Place the configuration file in the imported-cluster directory and specify the parameter values. If you did not add the authentication credentials to environment variables, specify them in the configuration file.

  15. Check that the Terraform configuration files are correct:

    terraform validate
    

    If there are any errors in the configuration files, Terraform will point them out.

  16. Create the required infrastructure:

    1. Run this command to view the planned changes:

      terraform plan
      

      If you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.

    2. If everything looks correct, apply the changes:

      1. Run this command:

        terraform apply
        
      2. Confirm updating the resources.

      3. Wait for the operation to complete.

    All the required resources will be created in the specified folder. You can check resource availability and their settings in the management console.

Time limits

A Terraform provider sets the timeout for Yandex Managed Service for Valkey™ cluster operations:

  • Creating a cluster, including by restoring one from a backup: 15 minutes.
  • Editing a cluster: 60 minutes.
  • Deleting a cluster: 15 minutes.

Operations exceeding the set timeout are interrupted.

How do I change these limits?

Add the timeouts block to the cluster description, for example:

resource "yandex_mdb_redis_cluster" "<cluster_name>" {
  ...
  timeouts {
    create = "1h30m" # 1 hour 30 minutes
    update = "2h"    # 2 hours
    delete = "30m"   # 30 minutes
  }
}

Examples

Creating a single-host cluster

CLI
Terraform

To create a cluster with a single host, provide a single --host parameter.

Create a Yandex Managed Service for Valkey™ cluster with the following test specifications:

  • Name: myredis.
  • Version: 7.2.
  • Environment: production.
  • Network: default.
  • A single hm2.nano class host in the b0rcctk2rvtr******** subnet, ru-central1-a availability zone and security group with the enp6saqnq4ie244g67sb ID, with public access and a host priority of 50.
  • SSL support: Enabled.
  • Network SSD storage (network-ssd): 16 GB.
  • Password: user1user1.
  • Deletion protection: Enabled.

Run the following command:

yc managed-redis cluster create \
  --name myredis \
  --redis-version 7.2 \
  --environment production \
  --network-name default \
  --resource-preset hm2.nano \
  --host zone-id=ru-central1-a,subnet-id=b0rcctk2rvtr********,assign-public-ip=true,replica-priority=50 \
  --security-group-ids enp6saqnq4ie244g67sb \
  --enable-tls \
  --disk-type-id network-ssd \
  --disk-size 16 \
  --password=user1user1 \
  --deletion-protection

Create a Yandex Managed Service for Valkey™ cluster and a network for it with the following test specifications:

  • Name: myredis.
  • Version: 7.2.
  • Environment: PRODUCTION.
  • Cloud ID: b1gq90dgh25bebiu75o.
  • Folder ID: b1gia87mbaomkfvsleds.
  • New mynet network.
  • A single hm2.nano class host in the new subnet called mysubnet, ru-central1-a availability zone, with public access and a host priority of 50. Range for mysubnet: 10.5.0.0/24.
  • New redis-sg security group allowing connections through the 6380 port from any addresses in mysubnet.
  • SSL support: Enabled.
  • Network SSD storage (network-ssd): 16 GB.
  • Password: user1user1.
  • Deletion protection: Enabled.

The configuration file for this cluster is as follows:

resource "yandex_mdb_redis_cluster" "myredis" {
  name                = "myredis"
  environment         = "PRODUCTION"
  network_id          = yandex_vpc_network.mynet.id
  security_group_ids  = [ yandex_vpc_security_group.redis-sg.id ]
  tls_enabled         = true
  deletion_protection = true

  config {
    password = "user1user1"
    version  = "7.2"
  }

  resources {
    resource_preset_id = "hm2.nano"
    disk_type_id       = "network-ssd"
    disk_size          = 16
  }

  host {
    zone             = "ru-central1-a"
    subnet_id        = yandex_vpc_subnet.mysubnet.id
    assign_public_ip = true
    replica_priority = 50
  }
}

resource "yandex_vpc_network" "mynet" { name = "mynet" }

resource "yandex_vpc_security_group" "redis-sg" {
  name       = "redis-sg"
  network_id = yandex_vpc_network.mynet.id

  ingress {
    description    = "Valkey™"
    port           = 6380
    protocol       = "TCP"
    v4_cidr_blocks = ["10.5.0.0/24"]
  }
}

resource "yandex_vpc_subnet" "mysubnet" {
  name           = "mysubnet"
  zone           = "ru-central1-a"
  network_id     = yandex_vpc_network.mynet.id
  v4_cidr_blocks = ["10.5.0.0/24"]
}

Creating a sharded cluster with a single shard

CLI
Terraform

Create a sharded Yandex Managed Service for Valkey™ cluster with the following test specifications:

  • Name: myredis.
  • Version: 7.2.
  • Environment: production.
  • Sharding: Enabled.
  • SSL support: Enabled.
  • Deletion protection: Enabled.
  • Network: default.
  • Security group ID: enp6saqnq4ie244g67sb.
  • Host class: hm2.nano.
  • A single host in the shard called shard1, in the b0rcctk2rvtr******** subnet, ru-central1-a availability zone, with public access and a host priority of 50.
  • Network SSD storage (network-ssd): 16 GB.
  • Password: user1user1.

Run the following command:

yc managed-redis cluster create \
  --name myredis \
  --redis-version 7.2 \
  --environment production \
  --sharded \
  --enable-tls \
  --deletion-protection \
  --network-name default \
  --security-group-ids enp6saqnq4ie244g67sb \
  --resource-preset hm2.nano \
  --host shard-name=shard1,subnet-id=b0rcctk2rvtr********,zone-id=ru-central1-a,assign-public-ip=true,replica-priority=50 \
  --disk-type-id network-ssd \
  --disk-size 16 \
  --password user1user1

Create a sharded Yandex Managed Service for Valkey™ cluster and a network for it with the following test characteristics:

  • Name: myredis.
  • Version: 7.2.
  • Environment: PRODUCTION.
  • Sharding: Enabled.
  • SSL support: Enabled.
  • Deletion protection: Enabled.
  • New network named mynet with a single subnet. Range for mysubnet: 10.5.0.0/24.
  • New redis-sg security group allowing connections through the 6380 port from any addresses in mysubnet.
  • Host class: hm2.nano.
  • A single host in the shard called shard1, in the mysubnet subnet, ru-central1-a availability zone, with public access and a host priority of 50.
  • Network SSD storage (network-ssd): 16 GB.
  • Password: user1user1.

The configuration file for this cluster is as follows:

resource "yandex_mdb_redis_cluster" "myredis" {
  name                = "myredis"
  environment         = "PRODUCTION"
  sharded             = true
  tls_enabled         = true
  deletion_protection = true
  network_id          = yandex_vpc_network.mynet.id
  security_group_ids  = [yandex_vpc_security_group.redis-sg.id]

  config {
    version  = "7.2"
    password = "user1user1"
  }

  resources {
    resource_preset_id = "hm2.nano"
    disk_type_id       = "network-ssd"
    disk_size          = 16
  }

  host {
    shard_name = "shard1"
    subnet_id  = yandex_vpc_subnet.mysubnet.id
    zone       = "ru-central1-a"
    assign_public_ip = true
    replica_priority = 50
  }
}

resource "yandex_vpc_network" "mynet" { name = "mynet" }

resource "yandex_vpc_subnet" "mysubnet" {
  name           = "mysubnet"
  zone           = "ru-central1-a"
  network_id     = yandex_vpc_network.mynet.id
  v4_cidr_blocks = ["10.5.0.0/24"]
}

resource "yandex_vpc_security_group" "redis-sg" {
  name       = "redis-sg"
  network_id = yandex_vpc_network.mynet.id

  ingress {
    description    = "Valkey™"
    port           = 6380
    protocol       = "TCP"
    v4_cidr_blocks = ["10.5.0.0/24"]
  }
}

Creating a sharded cluster with three shards

Terraform

Create a sharded Yandex Managed Service for Valkey™ cluster with the following test specifications:

  • Name: myredis.
  • Version: 7.2.
  • Environment: PRODUCTION.
  • Cloud ID: b1gq90dgh25bebiu75o.
  • Folder ID: b1gia87mbaomkfvsleds.
  • New mynet network.
  • Three subnets in the mynet network, one in each availability zone:
    • subnet-a with the 10.1.0.0/24 range
    • subnet-b with the 10.2.0.0/24 range
    • subnet-d with the 10.3.0.0/24 range
  • Three hm2.nano class hosts, one in each subnet.
  • New redis-sg security group allowing connections via ports 6379 and 26379 (Valkey™ Sentinel) from any subnet addresses.
  • Network SSD storage (network-ssd): 16 GB.
  • Password: user1user1.
  • Deletion protection: Enabled.

The configuration file for this cluster is as follows:

resource "yandex_mdb_redis_cluster" "myredis" {
  name                = "myredis"
  environment         = "PRODUCTION"
  network_id          = yandex_vpc_network.mynet.id
  security_group_ids  = [yandex_vpc_security_group.redis-sg.id]
  sharded             = true
  deletion_protection = true

  config {
    password = "user1user1"
    version  = "7.2"
  }

  resources {
    resource_preset_id = "hm2.nano"
    disk_type_id       = "network-ssd"
    disk_size          = 16
  }

  host {
    zone       = "ru-central1-a"
    subnet_id  = yandex_vpc_subnet.subnet-a.id
    shard_name = "shard1"
  }

  host {
    zone       = "ru-central1-b"
    subnet_id  = yandex_vpc_subnet.subnet-b.id
    shard_name = "shard2"
  }

  host {
    zone       = "ru-central1-d"
    subnet_id  = yandex_vpc_subnet.subnet-d.id
    shard_name = "shard3"
  }
}

resource "yandex_vpc_network" "mynet" { name = "mynet" }

resource "yandex_vpc_subnet" "subnet-a" {
  name           = "subnet-a"
  zone           = "ru-central1-a"
  network_id     = yandex_vpc_network.mynet.id
  v4_cidr_blocks = ["10.1.0.0/24"]
}

resource "yandex_vpc_subnet" "subnet-b" {
  name           = "subnet-b"
  zone           = "ru-central1-b"
  network_id     = yandex_vpc_network.mynet.id
  v4_cidr_blocks = ["10.2.0.0/24"]
}

resource "yandex_vpc_subnet" "subnet-d" {
  name           = "subnet-d"
  zone           = "ru-central1-d"
  network_id     = yandex_vpc_network.mynet.id
  v4_cidr_blocks = ["10.3.0.0/24"]
}

resource "yandex_vpc_security_group" "redis-sg" {
  name       = "redis-sg"
  network_id = yandex_vpc_network.mynet.id

  ingress {
    description    = "Valkey™"
    port           = 6379
    protocol       = "TCP"
    v4_cidr_blocks = [
      "10.1.0.0/24",
      "10.2.0.0/24",
      "10.3.0.0/24"
    ]
  }

  ingress {
    description    = "Valkey™ Sentinel"
    port           = 26379
    protocol       = "TCP"
    v4_cidr_blocks = [
      "10.1.0.0/24",
      "10.2.0.0/24",
      "10.3.0.0/24"
    ]
  }
}

Was the article helpful?

Previous
Information about existing clusters
Next
Updating cluster settings
© 2025 Direct Cursus Technology L.L.C.