render-oss / terraform-provider-render

Source code for the official Render Terraform provider
40 stars 4 forks source link

`render_postgres` resource does not allow hyphens in database_user #26

Closed pjohnmeyer closed 1 month ago

pjohnmeyer commented 1 month ago

When creating:

resource "render_postgres" "staging_db" {
  # ...
  database_user = "db-user"
  # ...
}

The plan was successful, but "apply" failed with the error:

render_postgres.staging_db: Creating...
╷
│ Error: Unable to create postgres database
│ 
│   with render_postgres.staging_db,
│   on main.tf line 85, in resource "render_postgres" "staging_db":
│   85: resource "render_postgres" "staging_db" {
│ 
│ database username: "db-user" not a valid SQL identifier; must match ^[a-z_][a-z_0-9]*$

The workaround was to use an underscore, but our working standard is to use hyphens.

PostgreSQL database usernames can definitely include hyphens, we use them in non-Render environments. So unless there's a reason Render doesn't allow hyphens in usernames, I would prefer to see them be allowed. (If it's a provider issue I wouldn't mind trying to submit a fix myself.)

lexara-prime-ai commented 1 month ago

Hey @pjohnmeyer, names containing hyphens only work for the instance name but not the database name and database user. Both have been configured to follow a specific pattern, otherwise, names containing hyphens will have to be escaped.

Previews

Database User

db_user

Database Instance and Name

dbname_pattern

instance_name

lexara-prime-ai commented 1 month ago

Having the ability to use hyphens would be nice for consistency though!

pjohnmeyer commented 1 month ago

Thanks @lexara-prime-ai -- so what you're telling me is this is at least consistent with the UI? I'll confess I didn't try the UI.

So, maybe not an issue with the TF provider, but a limitation (intentional or otherwise) of the API.

I'll leave this open until I hear from somebody @render-oss but, point taken.

lexara-prime-ai commented 1 month ago

Yes @pjohnmeyer, I experienced the same issue a lot when I was working on render_cdk, since uses the Render API extensively. We automated name generation and noticed tests kept failing for situations where names contained hyphens.

Hopefully someone from the @render-oss team can help clarify this.

jakemalachowski commented 1 month ago

Thanks for chiming in here @lexara-prime-ai. You're correct that this is a requirement across the board and not specific to the Terraform provider. If you'd like to make the request to add support for hyphens, opening one at https://feedback.render.com would be best the place.