From 0ff9f2b8cb946e058367874cf0cea3117bb1af13 Mon Sep 17 00:00:00 2001 From: cao dang tinh Date: Thu, 7 Nov 2024 12:41:32 +0100 Subject: [PATCH] Update document for postgresql_default_privileges resource (#468) --- ...ostgresql_default_privileges.html.markdown | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/website/docs/r/postgresql_default_privileges.html.markdown b/website/docs/r/postgresql_default_privileges.html.markdown index 8c995370..9bd36828 100644 --- a/website/docs/r/postgresql_default_privileges.html.markdown +++ b/website/docs/r/postgresql_default_privileges.html.markdown @@ -28,17 +28,31 @@ resource "postgresql_default_privileges" "read_only_tables" { ## Argument Reference -* `role` - (Required) The name of the role to which grant default privileges on. +* `role` - (Required) The role that will automatically be granted the specified privileges on new objects created by the owner. * `database` - (Required) The database to grant default privileges for this role. -* `owner` - (Required) Role for which apply default privileges (You can change default privileges only for objects that will be created by yourself or by roles that you are a member of). +* `owner` - (Required) Specifies the role that creates objects for which the default privileges will be applied. * `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) The list of privileges to apply as default privileges. An empty list could be provided to revoke all default privileges for this role. +* `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. ## Examples -Revoke default privileges for functions for "public" role: +### Grant default privileges for tables to "current_role" role: + +```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"] +} +``` +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. + +### Revoke default privileges for functions for "public" role: ```hcl resource "postgresql_default_privileges" "revoke_public" {