-
Notifications
You must be signed in to change notification settings - Fork 79
postgres_grant privileges always being created at planning #188
Comments
We've encountered this at @TakeScoop with RDS Postgres. I created the following isolated test and ran it against a local Postgres server to verify that there's no perpetual diff: provider "postgresql" {
sslmode = "disable"
}
resource "postgresql_database" "foo" {
name = "foo"
}
resource "postgresql_role" "foo" {
name = "foo"
}
resource "postgresql_grant" "foo" {
database = postgresql_database.foo.name
schema = "public"
role = postgresql_role.foo.name
object_type = "table"
privileges = ["SELECT"]
} Launching a fresh RDS instance now to try to see if its immediately reproducible there. |
Hmm, definitely not reproducible on an RDS Postgres instance running PG 12. Debug logs, generated with Namely, if the privileges returned don't match what the configuration has, the state is set to Will go try to generate those now. |
I found this:
Googling reminded me that's a PostGIS thing: https://postgis.net/docs/using_postgis_dbmanagement.html#spatial_ref_sys |
Went to the live DB where we observed this.
That doesn't seem to be entirely consistent with AWS's own PostGIS recommendations: That calls for an ownership change to the |
Thanks a lot, changing the table owner to rds_superuser solved the problem. The postgres provider using the master user it's now able to set the privileges for all tables in the public schema, so the plan is not showing changes every time anymore 🥇 |
Awesome! Per above:
This is because each table might have an entirely different set of permissions, so there's truly no way to represent the diff. I'm guessing there's some way to exclude tables the user can't access in the query I linked, but at least for now this can serve as a reference for anyone hitting this with RDS + PostGIS. |
Hi, I'm having problems with postgres_grant always planning changes.
Terraform Version
0.12.26
Postgresql provider version
both 1.6.0. and 1.7.0
Postgres Database
both AWS RDS aurora 10.11 and RDS postgres 10.2
Affected Resource(s)
Terraform Configuration Files
I'm using terraform modules, so it could be difficult to understand. However I included in the Debug Ouput section an example of what is happening to me in the plan phase.
Debug Output
Expected Behavior
No changes should appear to be applied every time I run terraform. I checked the DB and the privileges are there configured.
Actual Behavior
The priviledge list is always presented as new in terraform plan, so the postgresql_grant is always marked as a resource to be changed.
Steps to Reproduce
I just created a readonly user with postgresql_role, postgresql_grant and postgresql_default_privileges for public schema
Thanks
The text was updated successfully, but these errors were encountered: