Skip to content

Validation for postgres database names is wrong #1095

@mkesper

Description

@mkesper

Description

Validation of tf provider rejects valid names for postgres databases.

Steps to reproduce

resource "stackit_postgresflex_database" "a_b_db" {
  project_id  = var.project_id
  instance_id = stackit_postgresflex_instance.postgres-prod.instance_id
  name        = "a_b_db"
  owner = stackit_postgresflex_user.my_user.username
}
  1. Run tofu plan -out plan.out
  2. tofu apply plan.out

Actual behavior

 Error: Error creating database
│ 
│   with stackit_postgresflex_database.a_b_db,
│   on main.tf line 137, in resource "stackit_postgresflex_database" "a_b_db":
│  137: resource "stackit_postgresflex_database" "a_b_db" {
│ 
│ Calling API: 400 Bad Request, status code 400, Body: {"message":"failed to validate
│ body","code":400,"type":"Validation","fields":{"name":["the name field is not valid: a DNS-1035 label must consist of lower case
│ alphanumeric characters or '-', start with an alphabetic character, and end with an alphanumeric character (e.g. 'my-name',  or
│ 'abc-123', regex used for validation is '[a-z]([-a-z0-9]*[a-z0-9])?')"]}}

Expected behavior

The tf provider should create databases if they're valid according to postgres documentation:
https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS

Environment

  • OS: Debian GNU/Linux 13 (trixie) on amd64
  • Terraform version (see terraform --version): OpenTofu v1.11.1
  • Version of the STACKIT Terraform provider: v0.73.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions