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
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
  • Blog
  • Pricing
  • Documentation
Yandex project
© 2025 Yandex.Cloud LLC
Yandex Data Transfer
  • Available transfers
  • Getting started
    • All tutorials
      • MySQL® to Apache Kafka®
      • MySQL® to YDS
      • PostgreSQL to Apache Kafka®
      • PostgreSQL to YDS
      • YDB to Apache Kafka®
      • YDB and delivery to YDS
  • Troubleshooting
  • Access management
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Public materials

In this article:

  • Required paid resources
  • Getting started
  • Prepare the Managed Service for YDB source database
  • Create a stream for the Data Streams target
  • Set up and activate the transfer
  • Test your transfer
  • Delete the resources you created
  1. Tutorials
  2. Change data capture and delivery to the queue
  3. YDB and delivery to YDS

YDB change data capture and delivery to YDS

Written by
Yandex Cloud
Updated at May 5, 2025
  • Required paid resources
  • Getting started
  • Prepare the Managed Service for YDB source database
  • Create a stream for the Data Streams target
  • Set up and activate the transfer
  • Test your transfer
  • Delete the resources you created

A Data Streams stream can get data from Managed Service for YDB databases in real time using the Change Data Capture (CDC) technology.

Note

In YDB, CDC mode is supported starting from version 22.5.

To set up CDC using Data Transfer:

  1. Prepare the Managed Service for YDB source database.
  2. Create a stream for the Data Streams target.
  3. Set up and activate your transfer.
  4. Test your transfer.

If you no longer need the resources you created, delete them.

Required paid resourcesRequired paid resources

The support cost includes:

  • Fee for each Managed Service for YDB database. The charge depends on the usage mode:

    • For the serverless mode, you pay for data operations and the amount of stored data.
    • For the dedicated instance mode, you pay for the use of computing resources, dedicated DBs, and disk space.

    Learn more about the Managed Service for YDB pricing plans.

  • Fee for Data Streams. The fee depends on the pricing mode:

    • By allocated resources: You pay for the number of units of written data and resources allocated for streaming data.
    • By actual use:
      • If the DB operates in serverless mode, the data stream is charged under the YDB serverless mode pricing policy.

      • If the DB operates in dedicated instance mode, the data stream is not charged separately (only the DB is charged, see pricing policy).

    Learn more about the Data Streams pricing plans.

Getting startedGetting started

Set up your infrastructure:

Manually
Terraform
  1. Create a Managed Service for YDB source database in any suitable configuration.

  2. If you selected Dedicated DB mode for the source, create and configure a security group in the network hosting the DB.

  3. Create a Managed Service for YDB database in any suitable configuration for the Data Streams target stream.

  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. Download the data-transfer-ydb-yds.tf configuration file to the same working directory.

    This file describes:

    • Network.
    • Subnet.
    • Security group and the rule required to connect to the Managed Service for YDB database.
    • Managed Service for YDB source database.
    • Managed Service for YDB database for the target stream.
    • Transfer.
  6. In the data-transfer-ydb-yds.tf file, specify these variables:

    • source_db_name: Managed Service for YDB source database name.
    • target_db_name: Name of the Managed Service for YDB database for the target data stream.
    • transfer_enabled: 0 to ensure that no transfer is created before you create the endpoints.
  7. Make sure the Terraform configuration files are correct using this command:

    terraform validate
    

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

  8. 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.

Prepare the Managed Service for YDB source databasePrepare the Managed Service for YDB source database

  1. Get ready for running SQL queries in the Managed Service for YDB source database:

    Management console
    YDB CLI
    1. In the management console, select the folder with the DB you need.
    2. From the list of services, select Managed Service for YDB.
    3. Select the database from the list and go to the Navigation tab.
    4. Click New SQL query.
    1. Set up a connection to the Managed Service for YDB database.

    2. Make sure you can run queries using the YDB CLI with the selected authentication mode. For example, for an OAuth token, run the following query:

      ydb \
        --endpoint <endpoint> \
        --database <DB_name> \
        --yc-token-file <path_to_OAuth_token> \
        yql -s "SELECT 1;"
      

      Result:

      ┌─────────┐
      | column0 |
      ├─────────┤
      | 1       |
      └─────────┘
      
  2. Create a table for test data:

    CREATE TABLE test
    (
        id Uint64,
        text Utf8,
        PRIMARY KEY (id)
    );
    

Create a stream for the Data Streams targetCreate a stream for the Data Streams target

Create a stream for the Data Streams.

Set up and activate the transferSet up and activate the transfer

  1. Create an endpoint for the YDB source:

    • Connection settings:

      • Database: Select the Managed Service for YDB database from the list.
      • Service account ID: Select or create a service account with the ydb.editor role.
    • Included paths list:

      • Path 1: test.
  2. Create an endpoint for the Yandex Data Streams target:

    • Connection settings:

      • Database: Select the Managed Service for YDB database for the target stream from the list.
      • Stream: Specify the name of the Data Streams-enabled stream.
      • Service account: Select or create a service account with the yds.editor role.
    • Serializing settings: Auto.

  3. Create a transfer:

    Manually
    Terraform
    1. Create a transfer of the Replication type that will use the endpoints you created.
    2. Activate your transfer.
    1. In the data-transfer-ydb-yds.tf file, specify these variables:

      • source_endpoint_id: ID of the source endpoint.
      • target_endpoint_id: Target endpoint ID.
      • transfer_enabled: 1 to create a transfer.
    2. Make sure the Terraform configuration files are correct using this command:

      terraform validate
      

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

    3. 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.

      Once created, your transfer will be activated automatically.

Test your transferTest your transfer

  1. Wait until the transfer status switches to Replicating.

  2. Add the test data to the test table in the Managed Service for YDB source database:

    INSERT INTO test
    (
        id,
        text
    )
    VALUES
    (
        1,
        'text 1'
    ),
    (
        2,
        'text 2'
    ),
    (
        3,
        'text 3'
    );
    

Make sure the data from the source has been moved to the Data Streams stream:

Management console
AWS CLI
  1. In the management console, select Data Streams.
  2. Select the target stream from the list and navigate to  Data viewer.
  3. Make sure shard-000000 now contains messages with the source table rows. For a closer look at the messages, click .
  1. Install the AWS CLI.

  2. Configure the environment for Data Streams.

  3. Read the stream data using:

    • AWS CLI.
    • AWS SDK.

Delete the resources you createdDelete the resources you created

Note

Before deleting the created resources, deactivate the transfer.

Some resources are not free of charge. To avoid paying for them, delete the resources you no longer need:

  1. Delete the transfer.
  2. Delete the endpoints for both the source and target.
  3. If you created service accounts together with the endpoints, delete them.

Delete the other resources depending on how they were created:

Manually
Terraform
  1. Delete the Managed Service for YDB source database.
  2. Delete the Managed Service for YDB database used for the target stream.
  1. In the terminal window, go to the directory containing the infrastructure plan.

    Warning

    Make sure the directory has no Terraform manifests with the resources you want to keep. Terraform deletes all resources that were created using the manifests in the current directory.

  2. Delete resources:

    1. Run this command:

      terraform destroy
      
    2. Confirm deleting the resources and wait for the operation to complete.

    All the resources described in the Terraform manifests will be deleted.

Was the article helpful?

Previous
YDB to Apache Kafka®
Next
Apache Kafka® to ClickHouse®
Yandex project
© 2025 Yandex.Cloud LLC