Creating a changefeed for a table
Table changefeed
Description 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 | stringrequired |
Table path |
| connection_string | stringrequired |
Connection string, conflicts with table_id |
| database_id | stringrequired |
Database ID, conflicts with table_path and connection_string |
| table_id | stringrequired |
Terraform table ID |
| name | stringrequired |
Changefeed name |
| mode | stringrequired |
Changefeed operating mode |
| format | stringrequired |
Changefeed format |
| virtual_timestamps | booloptional |
Using virtual timestamps |
| retention_period | stringoptional |
Data storage time in a topic in ISO 8601 |
| 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 consumername, 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 | stringrequired |
Reader name |
| supported_codecs | array[string]optional |
Supported data encodings |
| starting_message_timestamp_ms | integeroptional |
The UNIX timestamp the reader will start reading data at. |
The consumer name is used in the SDK or CLI to read data