Skip to content
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

User mapping: permission denied in GCP Cloud SQL #327

Closed
cyn-rus opened this issue Jul 28, 2023 · 2 comments · Fixed by #469
Closed

User mapping: permission denied in GCP Cloud SQL #327

cyn-rus opened this issue Jul 28, 2023 · 2 comments · Fixed by #469

Comments

@cyn-rus
Copy link

cyn-rus commented Jul 28, 2023

Terraform Version

1.5.2

Affected Resource(s)

postgresql_user_mapping

Terraform Configuration Files

provider "postgresql" {
  host            = #host
  port            = #port
  database        = "warehouse"
  username        = "postgres"
  password        = #password
  superuser       = false
  connect_timeout = 15
  sslmode         = "disable"

  expected_version = "14.8"
}

resource "postgresql_server" "warehouse_server" {
  server_name  = "server"
  fdw_name     = "postgres_fdw"
  server_owner = "server"
  
  options = {
    host   = #host
    dbname = #db
    port   = #port
  }
}

resource "postgresql_grant_role" "warehouse_postgres_grant_server" {
  role       = "postgres"
  grant_role = "server"
}

resource "postgresql_grant_role" "warehouse_user_grant_server" {
  role       = "dashboard"
  grant_role = "server"
}

resource "postgresql_user_mapping" "warehouse_server_dashboard" {
  server_name = "server"
  user_name   = "dashboard"
  options = {
    user     = #user
    password = #password 
  }
}

Debug Output

Error: Error reading user mapping: pq: permission denied for view _pg_user_mappings

Panic Output

N/A

Expected Behavior

User mapping created successfully and no error occured

Actual Behavior

User mapping created successfully but an error occured, hence the terraform state will assume the resource has not been created

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. Create user mapping on postgres that is hosted in GCP using postgresql_user_mapping
  2. terraform apply

Important Factoids

I've tried querying

SELECT umoptions FROM information_schema._pg_user_mappings WHERE authorization_identifier='dashboard' AND foreign_server_name='server'

and it produces the same error, permission denied for view _pg_user_mappings, I think it may be related to where it select from

References

#274

@cyn-rus cyn-rus changed the title User mapping: permission denied User mapping: permission denied in GCP Cloud SQL Jul 31, 2023
@ademariag
Copy link
Contributor

Also experiencing the same issue.

ademariag pushed a commit to ademariag/terraform-provider-postgresql that referenced this issue Sep 19, 2024
ademariag pushed a commit to ademariag/terraform-provider-postgresql that referenced this issue Sep 19, 2024
@ademariag
Copy link
Contributor

@cyn-rus FYI I sent a PR in an attempt to address the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants