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 Managed Service for YDB
  • Getting started
  • Access management
  • Monitoring metrics
  • Audit Trails events
    • Introduction to YDB via Terraform
    • Getting authentication credentials
    • Installing and configuring Terraform and a provider to connect to YDB
    • Creating configuration files and connecting to YDB
    • Creating and editing parameters of a serverless database
    • Creating and editing parameters of a dedicated database
    • Creating row tables in a database
    • Creating document tables in a database
    • Creating a changefeed for a table
    • Creating secondary indexes in row tables
    • Managing YDB topic configurations
  • FAQ
  • Public materials
  1. Working with YDB via Terraform
  2. Creating a changefeed for a table

Creating a changefeed for a table

Written by
Yandex Cloud
Improved by
Max Z.
Updated at January 20, 2025

Table changefeed, or Change Data Capture (CDC), keeps you informed about changes in a particular table. When you add, update, or delete a table row, the CDC mechanism generates a change record where it specifies the primary key of the row and writes it to the topic partition corresponding to this key. A topic is an entity for storing unstructured messages and delivering them to multiple subscribers. Basically, a topic is a named set of messages.

Description of the yandex_ydb_table_changefeed resourceDescription of the yandex_ydb_table_changefeed resource

You can create a changefeed for a table using the yandex_ydb_table_changefeed resource:

resource "yandex_ydb_table_changefeed" "ydb_changefeed" {
  table_id = yandex_ydb_table.test_table_2.id
  name = "changefeed"
  mode = "NEW_IMAGE"
  format = "JSON"

  consumer {
    name = "test_consumer"
  }
}

We used the following fields to create a table changefeed:

  • table_id: ID of the table you create a changefeed for.
  • name: Changefeed name.
  • mode: Changefeed operating mode. The available changefeed operating modes are presented in the documentation.
  • format: Changefeed format. Only JSON format is available.

Full description of all yandex_ydb_table_changefeed resource fields:

Field name Type Description
table_path string
required
Table path
connection_string string
required
Connection string, conflicts with table_id
database_id string
required
Database ID, conflicts with table_path and connection_string
table_id string
required
Terraform table ID
name string
required
Changefeed name
mode string
required
Changefeed operating mode
format string
required
Changefeed format
virtual_timestamps bool
optional
Using virtual timestamps
retention_period string
optional
Data storage time in a topic in ISO 8601 format
consumer array[consumer]
optional
Consumers (readers) for the changefeed

When initializing the yandex_ydb_table_changefeed resource, you can specify only one connection field: connection_string, table_path, or table_id. If you specify multiple connection fields, they will come into conflict. For example, the table_id field with a relative link in <recourse>.<ID>.<parameter> format: yandex_ydb_table.test_table_2.id.

The consumer section resides inside the changefeed resource. A consumer is a named entity for reading data from the topic. A consumer has several fields of settings. The main field is name, which is the consumer's name. When initializing the yandex_ydb_table_changefeed resource, you can specify multiple readers, or you can create none, but then you cannot read data from the changefeed.

Full list of the consumer section fields:

Field name Type Description
name string
required
Reader name
supported_codecs array[string]
optional
Supported data encodings
starting_message_timestamp_ms integer
optional
The UNIX timestamp the reader will start reading data at.

The consumer name is used in the SDK or CLI to read data from the topic.

Was the article helpful?

Previous
Creating document tables in a database
Next
Creating secondary indexes in row tables
Yandex project
© 2025 Yandex.Cloud LLC