Yandex Cloud
Search
Discuss with expertTry it for free
  • Customer Stories
  • Documentation
  • Blog
  • All Services
    • Cloud Interconnect
    • Cloud Backup
    • Cloud Registry
    • Yandex AI Studio
    • Compute Cloud
    • Object Storage
    • Managed Service for Kubernetes®
    • Yandex BareMetal
    • Smart Web Security
    • Security Deck
    • Managed Service for PostgreSQL
    • Managed Service for ClickHouse®
    • Monium
    • Cloud CDN
    • Network Load Balancer
    • Virtual Private Cloud
    • Cloud DNS
    • Application Load Balancer
    • Yandex Cloud Video
    • Stackland
    • Yandex Cloud Router
    • Yandex Managed Service for Trino
    • Managed Service for MySQL®
    • Managed Service for Valkey™
    • Managed Service for Apache Spark™
    • Yandex StoreDoc
    • Managed Service for OpenSearch
    • Managed Service for Apache Kafka®
    • Data Transfer
    • Yandex MPP Analytics Engine for PostgreSQL
    • Yandex Managed Service for Apache Airflow®
    • Data Processing
    • Yandex MetaData Hub
    • Managed Service for YDB
    • Managed Service for Sharded PostgreSQL
    • Managed Service for YTsaurus
    • Yandex WebSQL
    • DataLens
    • Yandex Search API
    • SpeechSense
    • SpeechKit
    • DataSphere
    • Vision OCR
    • Translate
    • Yandex Identity Hub
    • Key Management Service
    • Certificate Manager
    • Yandex Lockbox
    • Audit Trails
    • SmartCaptcha
    • Yandex SIEM
    • SourceCraft Code Assistant
    • Container Registry
    • Managed Service for GitLab
    • Managed Service for Prometheus®
    • Cloud Functions
    • API Gateway
    • Yandex Cloud Postbox
    • Message Queue
    • IoT Core
    • Data Streams
    • Serverless Containers
    • Cloud Notification Service
    • Identity and Access Management
    • Yandex Cloud Console
    • Resource Manager
    • Yandex Cloud Billing
    • Yandex Cloud Quota Manager
    • Cloud Apps
  • System Status
  • Marketplace
    • Featured
    • Infrastructure & Network
    • Data Platform
    • AI for business
    • Security
    • DevOps tools
    • Serverless
    • Monitoring & Resources
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Center for Technologies and Society
    • Yandex Cloud Partner program
    • Price calculator
    • Pricing plans
  • Customer Stories
  • Documentation
  • Blog
© 2026 Direct Cursus Technology L.L.C.
Yandex Managed Service for ClickHouse®
  • Getting started
  • Access management
  • Inspections and recommendations
  • Pricing policy
    • Overview
    • Updates to a v2 cluster
    • Migrating a cluster from v1 to v2
  • Yandex Monitoring metrics
  • Audit Trails events
  • Public materials
  • Release notes

In this article:

  • Update the Terraform configuration
  • Save the cluster ID
  • Remove the old resource from state
  • Import the existing resource into the new one
  • Optionally, import databases and users
  • Review the planned changes
  • Apply the changes
  1. Terraform reference
  2. Migrating a cluster from v1 to v2

Migrating a cluster from v1 to v2

Written by
Yandex Cloud
Updated at October 27, 2026
View in Markdown
  • Update the Terraform configuration
  • Save the cluster ID
  • Remove the old resource from state
  • Import the existing resource into the new one
  • Optionally, import databases and users
  • Review the planned changes
  • Apply the changes

Before you get started with the migration, review the changes.

To migrate a cluster from resource v1 (yandex_mdb_clickhouse_cluster) to resource v2 (yandex_mdb_clickhouse_cluster_v2):

  1. Update the Terraform configuration.
  2. Save the cluster ID.
  3. Remove the old resource from state.
  4. Import the existing resource into the new one.
  5. Optionally, import databases and users.
  6. Review the planned changes.
  7. Apply the changes.

Update the Terraform configurationUpdate the Terraform configuration

  1. Apply all syntax changes from the table below:

    v1 (section syntax) v2 (assignment syntax)
    clickhouse { } clickhouse = { }
    zookeeper { } zookeeper = { }
    access { } access = { }
    cloud_storage { } cloud_storage = { }
    backup_window_start { } backup_window_start = { }
    clickhouse.config.kafka { } kafka = { } (inside config)
    clickhouse.config.rabbitmq { } rabbitmq = { } (inside config)
    clickhouse.config.compression { } (repeat section) compression = [{ method = "LZ4", ... }]
    host { } (repeat section) hosts = { "key" = { } }
    shard { } (repeat section) shards = { "shard1" = { } }
  2. Set keys for your hosts.

Save the cluster IDSave the cluster ID

  1. Run this command:

    terraform state show yandex_mdb_clickhouse_cluster.main
    
  2. Copy the id value from the output for later.

Remove the old resource from stateRemove the old resource from state

Run this command:

terraform state rm yandex_mdb_clickhouse_cluster.main

Import the existing resource into the new oneImport the existing resource into the new one

Run this command:

terraform import yandex_mdb_clickhouse_cluster_v2.main <cluster_ID>

Use the id value you got earlier in the command.

After the import, the hosts’ FQDNs will be used as their keys in state, e.g., "rc1a-abc.mdb.yandexcloud.net".

Optionally, import databases and usersOptionally, import databases and users

If database {} or user {} were previously a part of the cluster resource and now are represented by separate resources, import them:

terraform import 'yandex_mdb_clickhouse_database.mydb' "<cluster_ID>:<DB_name>"
terraform import 'yandex_mdb_clickhouse_user.myuser'   "<cluster_ID>:<username>"

Review the planned changesReview the planned changes

Run this command:

terraform plan

You will see a list of resources and their properties. This is a verification step: no resources will be created. Terraform will show any errors detected in the configuration.

In plan, all hosts may appear as + and -. While this may look alarming, it is safe for matching hosts to apply the changes.

The provider matches hosts in three steps:

  1. Same key in plan and state: Host remains as-is, no action required.
  2. Full match by zone, subnet_id, type, shard_name, and assign_public_ip: The state key is renamed to the plan key; the host itself is not affected.
  3. Partial match by zone, FQDN, shard_name, and subnet_id: The state key is renamed to the plan key; an update may be required, e.g., assign_public_ip.

Hosts in plan use short keys, such as "c1", "k1". If zone, subnet, type, and shard match, the second step will start: the keys will be renamed without any actual changes to the hosts.

Warning

Before you run terraform apply, make sure that each host displayed as + and - has the same values for zone, subnet_id, type, shard_name, and assign_public_ip. Changing any of those fields may cause the host to be recreated.

Apply the changesApply the changes

  1. To create resources, run the command:

    terraform apply
    
  2. Confirm creating the resources by typing yes and pressing Enter.

    Terraform will create all the required resources. You can check the new resources and their settings in the management console.

In case of errors, read Migration errors.

Useful linksUseful links

  • Updates in a v2 cluster

Was the article helpful?

Previous
Updates to a v2 cluster
Next
API authentication
© 2026 Direct Cursus Technology L.L.C.