cyrilgdn / terraform-provider-postgresql

Terraform PostgreSQL provider
https://www.terraform.io/docs/providers/postgresql/
Mozilla Public License 2.0
356 stars 181 forks source link

allow setting configuration_parameter on roles and databases #390

Open joaocc opened 6 months ago

joaocc commented 6 months ago

Hi there,

Thank you for opening an issue. Please provide the following information:

Currently there doesn't seem to be a way to do the following using the provider:

ALTER DATABASE "my_db" SET timezone  TO 'UTC';
ALTER DATABASE "my_db" SET datestyle  TO 'YMD';
ALTER ROLE "my_role" SET timezone  TO 'UTC';
ALTER ROLE "my_role" SET datestyle  TO 'YMD';

From the structure of the resources, it would be useful to add this ability to to postgresql_database and postgresql_role. Since these are only 2 specific examples of configuration parameters, it could be defined as either a map(string) or via configuration_blocks.

Affected Resource(s)

Important Factoids

We were not able to find a any alternative to do this in a terraform way. Then only alternative we are considering is using local-exec to run psql but that would mean running it everytime the plan runs, and would not appear in the plan if things were changed. Alternatively, running only on lifecycle/creation would mean we would not be able to reset it if it ended up changing.