-
Notifications
You must be signed in to change notification settings - Fork 258
Description
When using a managed PostgreSQL service, the Cloud Provider does not provide access rights to the information_schema for security reasons. Because of this limitation, the following error occurs during terraform plan:
ERROR error occurred:
* Failed to execute "terraform plan" in ./.terragrunt-cache/...
╷
│ Error: Error reading user mapping: pq: current transaction is aborted, commands ignored until end of transaction block
│
│ with postgresql_user_mapping.mappings["root/mappings/fdw_mapping"],
│ on main.tf line 55, in resource "postgresql_user_mapping" "mappings":
│ 55: resource "postgresql_user_mapping" "mappings" {
│
╵
exit status 1
The root cause is in this query:
query := "SELECT umoptions FROM information_schema._pg_user_mappings WHERE authorization_identifier = $1 and foreign_server_name = $2"
Since access to information_schema._pg_user_mappings is not permitted, the query fails and the transaction is aborted.
I suggest to add error handling around this query to avoid aborting the transaction when the privileges are insufficient.
Currently I use provider version 1.18, which queries the pg_user_mappings view instead. This view is accessible in managed PostgreSQL environments. Reference