cyrilgdn / terraform-provider-postgresql

Terraform PostgreSQL provider
https://www.terraform.io/docs/providers/postgresql/
Mozilla Public License 2.0
359 stars 182 forks source link

Is there a way to use this to change the owner of a schema and/or role? #279

Open ekeric13 opened 1 year ago

ekeric13 commented 1 year ago

I see there are ways to create schemas and update usage: https://registry.terraform.io/providers/cyrilgdn/postgresql/latest/docs/resources/postgresql_schema

Also grants: https://registry.terraform.io/providers/cyrilgdn/postgresql/latest/docs/resources/postgresql_grant

I don't see anything around ownership though

cyrilgdn commented 1 year ago

Hi @ekeric13 ,

There's actually an owner field in postgresql_schema but the documentation is not up-to-date. I'll fix it.

But you can write:


resource "postgresql_schema" "test" {
  name  = "test"
  owner = "test_user"
}
cyrilgdn commented 1 year ago

Actually it's up to date, so I'm not sure I had properly understood your question?

ekeric13 commented 1 year ago

To be honest I forget too! But I think it might have been this:

I think it was if i have a pre-existing user, say "postgres", that made a pre-existing schema, say "test", and I want to change the owner to a new user, say "test_user", would it just be:

resource "postgresql_schema" "test" {
  name  = "test"
  owner = "test_user"
}