-
Notifications
You must be signed in to change notification settings - Fork 258
Open
Description
Terraform Version
Terraform v1.2.6
on darwin_arm64
+ provider registry.terraform.io/cyrilgdn/postgresql v1.17.1
Affected Resource(s)
- postgresql_grant
Terraform Configuration Files
# This resource ignores views
resource "postgresql_grant" "all" {
database = "mydb"
role = "myrole"
schema = "public"
object_type = "table"
privileges = ["SELECT"]
}
# This one grants permissions on the listed views
resource "postgresql_grant" "view" {
database = "mydb"
role = "myrole"
schema = "public"
object_type = "table"
objects = ["my_view"]
privileges = ["SELECT"]
}
Debug Output
Not really useful, I can provide it if wanted
Panic Output
None
Expected Behavior
There should be a way to affect all views as well.
Actual Behavior
Granting permissions on views requires explicitly enumerating them.
Steps to Reproduce
- create a database with at least a table and a view
- try to grant a permission on "all views" with
postgresql_grant
Important Factoids
Nothing specific as far as I can tell.
References
None
Design evolution ideas
The provider kind of works as expected, we're on an edge case here.
I can think of several ways to fix this :
- When using
postgresql_grant
withobject_type = "table"
and an emptyobjects
list, apply the privileges to views as well. - Add a
view
object_type
, to be able to specify all tables and all views with 2 resources.
Option 1 has my preference, but it's a breaking change (as existing configurations would suddenly grant more privileges), therefore likely requiring a major version release.
I'm also not familiar enough with postgresql's permission system to know if this design is enough. My current concerns are :
- What happens if you try to give write permissions on a view ? Is it even legal ?
- What permissions are required to refresh materialized views ? Do we need new valid values in
permissions
? If so, do they make sense on a normal table ?
andrewmwilson, om-henners, NRay7882, Solksjaer, bertrandpgn and 6 more
Metadata
Metadata
Assignees
Labels
No labels