Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions website/docs/r/postgresql_default_privileges.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ resource "postgresql_default_privileges" "read_only_tables" {
database = "test_db"
schema = "public"

owner = "db_owner"
object_type = "table"
privileges = ["SELECT"]
owner = "db_owner"
object_type = "table"
privileges = ["SELECT"]
with_grant_option = false
}
```

Expand All @@ -34,6 +35,7 @@ resource "postgresql_default_privileges" "read_only_tables" {
* `schema` - (Optional) The database schema to set default privileges for this role.
* `object_type` - (Required) The PostgreSQL object type to set the default privileges on (one of: table, sequence, function, type, schema).
* `privileges` - (Required) List of privileges (e.g., SELECT, INSERT, UPDATE, DELETE) to grant on new objects created by the owner. An empty list could be provided to revoke all default privileges for this role.
* `with_grant_option` - (Optional) Whether the role will be able to grant the specified privileges to others.


## Examples
Expand All @@ -42,15 +44,17 @@ resource "postgresql_default_privileges" "read_only_tables" {

```hcl
resource "postgresql_default_privileges" "grant_table_privileges" {
database = postgresql_database.example_db.name
role = "current_role"
owner = "owner_role"
schema = "public"
object_type = "table"
privileges = ["SELECT", "INSERT", "UPDATE"]
database = postgresql_database.example_db.name
role = "current_role"
owner = "owner_role"

schema = "public"
object_type = "table"
privileges = ["SELECT", "INSERT", "UPDATE"]
with_grant_option = true
}
```
Whenever the `owner_role` creates a new table in the `public` schema, the `current_role` is automatically granted SELECT, INSERT, and UPDATE privileges on that table.
Whenever the `owner_role` creates a new table in the `public` schema, the `current_role` is automatically granted SELECT, INSERT, and UPDATE privileges on that table, and the `current_role` can grant these privileges to other roles.

### Revoke default privileges for functions for "public" role:

Expand Down