Creating a changefeed for a table
Table changefeed
yandex_ydb_table_changefeed
resource
Description of the 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 for which we create the changefeed.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 descriptioin of all the yandex_ydb_table_changefeed
resource fields:
Field name | Type | Description |
---|---|---|
table_path | string required |
Path to table |
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 ID of the table |
name | string required |
Changefeed name |
mode | string required |
Changefeed mode |
format | string required |
Changefeed format |
virtual_timestamps | bool optional |
Using virtual timestamps |
retention_period | string optional |
Time period of data retention in the topic in ISO 8601 |
consumer | array[consumer] optional |
Changefeed consumers |
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 <resource>.<ID>.<parameter>
: yandex_ydb_table.test_table_2.id
format.
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 set up multiple consumers or none, in which case you will not be able to read data from the changefeed.
Full list of the consumer
section fields:
Field name | Type | Description |
---|---|---|
name | string required |
Consumer name |
supported_codecs | array[string] optional |
Supported data encodings |
starting_message_timestamp_ms | integer optional |
Timestamp in UNIX timestamp format, from which the consumer will start reading data |
The consumer name is used in the SDK or CLI to read data