Managing YDB topic configurations
Written by
Updated at April 29, 2026
For operations with topicsyandex_ydb_topic resource.
Note
We recommend creating a topic in a separate folder. A topic in the database root visually breaks the database structure.
Description of the yandex_ydb_topic resource
Usage example for yandex_ydb_topic:
resource "yandex_ydb_topic" "ydb_topic" {
database_endpoint = yandex_ydb_database_serverless.database1.ydb_full_endpoint # database connection example
name = "test_dir/test_topic"
supported_codecs = ["zstd"]
consumer {
name = "test-consumer1"
starting_message_timestamp_ms = 0
supported_codecs = ["zstd","raw"]
}
consumer {
name = "test-consumer2"
starting_message_timestamp_ms = 2000
supported_codecs = ["zstd"]
}
consumer {
name = "test-consumer3"
starting_message_timestamp_ms = 0
supported_codecs = ["zstd"]
}
}
The following fields are supported:
| Field name | Type | Description |
|---|---|---|
name |
stringrequired |
Topic name. |
database_endpoint |
stringrequired |
Full database path. |
retention_period_ms |
numberoptional |
Data retention period, in ms. The default value is 86400000 (full day). |
partitions_count |
numberoptional |
Number of partitions; the default value is 2. |
supported_codecs |
list(string)optional |
Supported data compression codecs; the default value is "gzip", "raw", "zstd",which can be combined as needed. |
consumer |
consumer |
Topic consumers. |
Note
You can create a consumer using Terraform but you cannot delete it. To delete a consumer, use the management console
Data consumer
| Field name | Type | Description |
|---|---|---|
name |
stringrequired |
Consumer name. |
supported_codecs |
list(string)optional |
Supported data compression codecs; the default value is "gzip", "raw", "zstd", which can be combined as needed. |
starting_message_timestamp_ms |
numberoptional |
UNIX timestamp0, i.e., from the beginning of delivery. |