-
Notifications
You must be signed in to change notification settings - Fork 79
How to grant permissions on all tables with Terraform? #92
Comments
Hi @velatorio , Thanks for opening this issue and really sorry for response delay :( I'm not sure to get your problem, why this won't give permissions for the tables in |
Hi @cyrilgdn I have a similar problem. Let's say I have users: However I want the In order to achieve this I have something like the following: resource "postgresql_role" "crud_stage_role" {
name = "crud_stage_role"
}
resource "postgresql_role" "admin_user" {
name = var.admin_user
login = true
password = "adminuser"
roles = [postgresql_role.crud_stage_role.name]
}
resource "postgresql_role" "dev_user" {
name = var.dev_user
login = true
password = "devuser"
}
resource "postgresql_role" "app_user" {
name = var.app_user
login = true
password = "appuser"
roles = [postgresql_role.crud_stage_role.name]
}
resource "postgresql_schema" "new_schema" {
name = var.schema_name
owner = "postgres"
policy {
create = true
usage = true
role = postgresql_role.crud_stage_role.name
}
policy {
usage = true
role = postgresql_role.dev_user.name
}
}
resource postgresql_grant "readwrite_tables" {
database = "postgres"
role = postgresql_role.crud_stage_role.name
schema = postgresql_schema.new_schema.name
object_type = "table"
privileges = ["ALL"]
}
resource postgresql_grant "read_tables" {
database = "postgres"
role = postgresql_role.dev_user.name
schema = postgresql_schema.new_schema.name
object_type = "table"
privileges = ["SELECT"]
} Now I log in to However the Also now if I run the following command: SELECT grantee, privilege_type
FROM information_schema.role_table_grants
WHERE table_name='xxx'; I get the following:
So the |
@TamasNeumer I think what you want to set is default privileges which allow to define privileges that will be applied on newly created objects. For that you can use the postgresql_default_privileges resource |
@velatorio I close this issue as I think you are in the same case than @TamasNeumer , but feel free to open it back if it's not the case. |
Let's say I have a database called
db
and an user calledapp
that has full permissions for all the tables in such database (profiles
,city
, etc). Now, using this provider, I create a new user (e.g.app2
) and grant this user permissions so that it can use thedb
database:Unfortunately, this won't give permissions for the tables in
db
and therefore the new user won't be able to work with that.Do you have any suggestion? Could this be related to #85?
The text was updated successfully, but these errors were encountered: