Manage PostgreSQL roles with postgresql_role
mainThe postgresql_role resource creates and manages a role on a PostgreSQL server.
Important Lifecycle Note: When a postgresql_role is removed, the provider automatically attempts to run REASSIGN OWNED and DROP OWNED to the CURRENT_USER.
If a role owns objects across multiple databases in the same cluster, you must create one provider per database. For all but the final postgresql_role being removed, you must set skip_drop_role = true to allow the role to be dropped from the catalog after ownership cleanup in other databases.
resource "postgresql_role" "my_role" {
name = "my_role"
login = true
password = "mypass"
}