-
Notifications
You must be signed in to change notification settings - Fork 212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
postgresql_grant persistent plan drift even without underlying terraform code changed #197
Comments
Hi @bfox1793 , Could you provide example of Terraform resources to reproduce this behavior? |
Hi @cyrilgdn , This happens when using default privileges. when a new table is created, privileges on it will be granted according to defaults and will reflect on information_schema.role_table_grants table. A small example:
postgres=> select*from information_schema.role_table_grants where table_name='test'; (privileges are shown) grantor | grantee | table_catalog | table_schema | table_name | privilege_type | is_grantable | with_hierarchy postgres=> select relacl from pg_class where relname='test'; (relacl is empty)
|
@cyrilgdn - I think @yaronmahat 's details above provides a more concise example of this behavior. Let me know if you need any additional information! |
This simple config granting a role all privileges on a DB schema
regularly detects a drift in the granted privileges and requires a new apply
despite nobody tampered the privileges and the application works just right. This happens from time to time and causes some noise in terraform plans. FWIW: all my DB services are AWS RDS, so I haven't tested this on a bare postgresql. |
bump |
Any updates on this? I am seeing the same thingas @n1ngu , also with AWS RDS postgres instances |
Seems like the same issue as here #303 We're having the same issue and we do experience 1-2 seconds where the user looses access to tables etc. Any updates on this? |
Similar behavior on AWS Aurora and RDS. |
In more recent versions, https://github.com/cyrilgdn/terraform-provider-postgresql/pull/135/files#diff-df65aafa037f8919594f7968b37996a7cb876d3a94de44286f83bd81288fd159L40 will cause recreations, not just updates. |
I also experience the same behavior with version 1.22.0. I have the following resource definition resource postgresql_grant connect_privilege {
for_each = toset(var.database_users_roles)
database = var.database
object_type = "database"
privileges = ["CONNECT"]
role = each.value
} Every time I run apply it wants to change it:
I run Terraform with TF_LOG=INFO and this part seems to be relevant:
|
Is anyone looking into this issue? The Terraform plans have been consistently misleading on |
Terraform Version
1.1.3
Affected Resource(s)
postgresql_grant
Terraform Configuration Files
Debug Output
N/A
Panic Output
N/A
Expected Behavior
Having a postgresql_grant object with privileges
SELECT, UPDATE, INSERT
without any changes reflects as much on subsequentterraform plan
runs.Actual Behavior
terraform plan
detects constant drift betweenINSERT
grants being either removed, and so it attempts to add it, or it says it was added and needs to remove theINSERT
privilege (though I want the insert to be added).These subsequent applies don't appear to affect the underlying resources, just the terraform state detection. The terraform configs are putting grants on the DB as-expected.
Steps to Reproduce
terraform apply
> creates thepostgresql_grant
with SELECT, UPDATE, INSERT accessterraform plan
> expect no drift since underlying TF code wasn't touched, but instead it detects that the grant'sINSERT
either needs to be added or removed from the grant.Important Factoids
N/A
References
N/A
The text was updated successfully, but these errors were encountered: