terraform-provider-postgresql icon indicating copy to clipboard operation
terraform-provider-postgresql copied to clipboard

Support for `postgresql_databases` data source

Open igor-nikiforov opened this issue 2 years ago • 1 comments

Hello,

I have a requirement where I'm need to get a list of all databases from current PG instance and use it to create another non-PG related resources for each of database.

In PG it could be done with simple SQL query:

SELECT datname FROM pg_catalog.pg_database;

Example of data resource:

data "postgresql_databases" "this" {}

Result:

[db1, db2, db3]

Additionally, nice to have in-build regex filter to omit default databases like postgres, template0 and template1.

igor-nikiforov avatar Nov 17 '23 04:11 igor-nikiforov

This would indeed be great. This was one of the few points we found lacking when looking at this fine provider. In order to be able to use terraform to things like "ensuring PUBLIC is not granted connect on any existing database" or other such scenarios. Do you know if there is any sponsor program for this provider? Thx

joaocc avatar Dec 11 '23 18:12 joaocc