Report this

What is the reason for this report?

How to provide access to a public scheme in PostgreSQL 15 or 16 using terraform?

Posted on June 3, 2024

PostgreSQL has brought the changes related to a public scheme.

  • Remove PUBLIC creation permission on the public schema (Noah Misch)
  • Change the owner of the public schema to be the new pg_database_owner role (Noah Misch)

The question is how to create a user using resource digitalocean_database_user to be belong to the new role?

I have tested on 16 and have not found such role.

luckyroot=> \du
                                                                List of roles
      Role name      |                         Attributes                         |                         Member of
---------------------+------------------------------------------------------------+-----------------------------------------------------------
 _doadmin_managed    | Cannot login                                               | {pg_read_all_stats,pg_stat_scan_tables,pg_signal_backend}
 _doadmin_monitor    |                                                            | {pg_monitor}
 _dodb               | Superuser, Replication                                     | {}
 doadmin             | Create role, Create DB, Replication, Bypass RLS            | {_doadmin_managed,luckyroot-develop-3}
 luckyroot-develop-3 |                                                            | {}
 postgres            | Superuser, Create role, Create DB, Replication, Bypass RLS | {}


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
0

Hey!

Any new users created with digitalocean_database_user resource or manually via the DigitalOcean Control Panel, will always have normal role, only the default user that comes with database cluster creation has primary role.

Additional permissions must be managed manually.

You can either do it manually as described here:

https://docs.digitalocean.com/products/databases/postgresql/how-to/modify-user-privileges/

Or you could use the Postgres Terraform provider instead:

https://registry.terraform.io/providers/cyrilgdn/postgresql/latest/docs

Hope that this helps!

- Bobby

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.