terraform-provider-postgresql
terraform-provider-postgresql copied to clipboard
Add Data Sources For Retrieving Schema, Sequence and Table Names From A Database
An expanded version of PR https://github.com/cyrilgdn/terraform-provider-postgresql/pull/171 which adds three new data sources for retrieving the names of schemas, sequences and tables respectively from a database.
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.
}
data "postgresql_sequences" "example_retrieve_sequences" {
database = "example_database"
schemas = ["test_schema","test_schema1","test_schema2"] # Optional list of PostgreSQL schema(s) which will be queried for sequence names. Queries all schemas in the database by default.
like_any_patterns = ["test%","%pg%"]
like_all_patterns = ["test%","%pg%"]
not_like_all_patterns = ["example%"]
regex_pattern = "^test_.*$"
}
data "postgresql_tables" "example_retrieve_tables" {
database = "example_database"
schemas = ["test_schema","test_schema1","test_schema2"]
table_types = ["BASE TABLE"] # Optional list of PostgreSQL table types which will be queried for table names. Includes all table types by default (including views and temp tables). Use 'BASE TABLE' for normal tables only.
like_any_patterns = ["test%","%pg%"]
like_all_patterns = ["test%","%pg%"]
not_like_all_patterns = ["example%"]
regex_pattern = "^test_.*$"
}
Issues
Closes #142
Hello, just curious if there is any progress on this?
Hey, Thanks for your awesome work! I'll try to have a look this week or next week-end
Hi @cyrilgdn sorry to poke at you for this. Just hoping to see this merged soon. Thanks for your help! :)
Hello, any news on this ? this will be useful for sure.
@cyrilgdn hi! is there anything that's blocking this? This is something that we could definitely use for schema grants!