Creating a changefeed for a table
Table changefeed
To create a changefeed for a table, use 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 parameters 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.
This table describes all the "yandex_ydb_table_changefeed"
resource parameters:
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 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 of data retention in the topic, ISO 8601 |
consumer | array[consumer] optional |
Changefeed consumers |
When initializing the "yandex_ydb_table_changefeed"
resource, you can specify a single connection parameter: connection_string
, table_path
, or table_id
. If you specify multiple connection parameters, they will come into conflict. For this reason, specify a single connection parameter. For example, table_id
with a relative link in the format: <resource>.<ID>.<parameter>
: yandex_ydb_table.test_table_2.id
.
Inside the changefeed resource resides the consumer
section. Consumername
. When initializing the "yandex_ydb_table_changefeed"
resource, you can set up multiple consumers or create none, in which case you will not be able to read data from the changefeed.
Here is the full list of consumer
parameters:
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