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 you are creating 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 |
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 <resource>.<ID>.<parameter>
format: yandex_ydb_table.test_table_2.id
.
Inside the changefeed resource resides the consumer
section. A consumername
, which is the consumer's name. When initializing the yandex_ydb_table_changefeed
resource, you can specify multiple consumers, or you can create none, but then 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 |
UNIX timestamp the consumer will start reading data from. |
The consumer name is used in the SDK or CLI to read data