terraform-provider-postgresql
terraform-provider-postgresql copied to clipboard
Add Data Source For Retrieving Schema Names From A Database
Overview
This PR adds the new data source postgresql_schemas
for retrieving schema names from a database.
The intended usage of this data source is so that it will no longer be necessary to type out schema names explicitly when using resources such as postgresql_grant
to iterate over a list of schemas within a database. Instead, one may just loop over the list output from data.postgresql_schemas
.
Example
data "postgresql_schemas" "example_retrieve_schemas" {
database = "example_database"
include_system_schemas = true # Optional argument that determines whether to include reserved system schemas.
like_any_patterns = ["test%","%pg%"] # Optional expressions which will be pattern matched in the query using the LIKE ANY operators.
like_all_patterns = ["test%","%pg%"] # Optional expressions which will be pattern matched in the query using the LIKE ALL operators.
not_like_all_patterns = ["example%"] # Optional expressions which will be pattern matched in the query using the NOT LIKE ALL operators.
regex_pattern = "^test_schema.*$" # Optional expression which will be pattern matched in the query using the ~ (regular expression match) operator.
}
output "example_database_schemas" {
value = data.postgresql_schemas.example_retrieve_schemas.schemas
}
Issues
Closes #142
This issue was created by another member of our organization.
Tests failed the first time due to I believe a different number of temporary pg_ schemas (pg_temp_1, pg_toast_temp_1, etc) than expected from local runs. Changed the acceptance tests to not rely on those 😌
This looks really useful.. any movement on this?
HI @cyrilgdn , could you please take another look at this PR or let us know any concerns you currently have preventing this from being merged?
@SpencerBinXia I'm having a look, sorry for the delay.
I allowed myself to merge master in your PR.
Hi @cyrilgdn, I liked your suggestions and made the appropriate changes to remove the need for pointers.
I opened a new PR https://github.com/cyrilgdn/terraform-provider-postgresql/pull/214 that also has changes for adding sequence and table data sources. It would be preferable if possible to get that PR merged and skip this one entirely, but I understand if you want to start with the smaller PR first!
Hello any progress on this or #214 please?
Closing this one: see https://github.com/cyrilgdn/terraform-provider-postgresql/pull/214