yandex-cloud / terraform-provider-yandex

Terraform Yandex provider
https://www.terraform.io/docs/providers/yandex/
Mozilla Public License 2.0
208 stars 113 forks source link

Error creating yandex_ydb_table with TTL in months #464

Open baznikin opened 1 month ago

baznikin commented 1 month ago
  1. I cant create yandex_ydb_table with TTL in months (P2M).
  2. However, if I change notation to days (P60D) table created.
  3. Subsequent runs of terraform apply tries to change P2M in cloud on P60D as written in manifest.
  4. If I change it to P2M there is no error (until I try to create new table with such manifest)

So, API accept only days notation, but store in internally in full ISO 8601 form.

1)

resource "yandex_ydb_table" "outbound" {
  connection_string = yandex_ydb_database_serverless.this.ydb_full_endpoint
  path              = "${var.name}-table"
  primary_key       = ["event_id"]

  ttl {
    column_name     = "_timestamp"
    expire_interval = "P2M" # ISO 8601
  }

  column {
   # our columns here
  }
  column {
    name = "_timestamp"
    type = "Timestamp"
    not_null = false
  }
  column {
    name = "_partition"
    type = "String"
    not_null = false
  }
  column {
    name = "_offset"
    type = "Uint64"
    not_null = false
  }
  column {
    name = "_idx"
    type = "Uint32"
    not_null = false
  }
}
│ Error: failed to create table
│ 
│   with module.events.yandex_ydb_table.outbound,
│   on ../_modules/events-tracking/main.tf line 24, in resource "yandex_ydb_table" "outbound":
│   24: resource "yandex_ydb_table" "outbound" {
│ 
│ non-retryable error occurred on attempt No.1 (idempotent=false): connError{node_id:0,address:'ru-central1-a.ydb.serverless.yandexcloud.net:2135'}: operation/GENERIC_ERROR (code = 400080, address =
│ ru-central1-a.ydb.serverless.yandexcloud.net:2135, issues = [{16:8 => 'Invalid value "P2M" for type Interval'}]) at `github.com/ydb-platform/ydb-go-sdk/v3/internal/conn.(*conn).Invoke(conn.go:373)`
│ at `github.com/ydb-platform/ydb-go-sdk/v3/internal/balancer.(*Balancer).wrapCall(balancer.go:358)` at
│ `github.com/ydb-platform/ydb-go-sdk/v3/internal/table.(*session).ExecuteSchemeQuery(session.go:841)` at `github.com/ydb-platform/ydb-go-sdk/v3/internal/table.do.func1(retry.go:54)` at
│ `github.com/ydb-platform/ydb-go-sdk/v3/internal/table.retryBackoff.func1(retry.go:85)` at `github.com/ydb-platform/ydb-go-sdk/v3/retry.Retry(retry.go:314)` at
│ `github.com/ydb-platform/ydb-go-sdk/v3/internal/table.(*Client).Do(client.go:658)`

3)

  # module.events.yandex_ydb_table.outbound will be updated in-place
  ~ resource "yandex_ydb_table" "outbound" {
        id                     = "grpcs://ydb.serverless.yandexcloud.net:2135/?database=/ru-central1/xxxxxxxxxx"
        # (6 unchanged attributes hidden)

      - ttl {
          - column_name     = "_timestamp" -> null
          - expire_interval = "P2M" -> null
            # (1 unchanged attribute hidden)
        }
      + ttl {
          + column_name     = "_timestamp"
          + expire_interval = "P60D"
          + unit            = (known after apply)
        }

        # (12 unchanged blocks hidden)
    }