Skip to content

Releases: doctolib/terraform-provider-postgresql

v2.26.2

31 Oct 08:14
0e0ac3b

Choose a tag to compare

v2.26.1

24 Oct 13:10
ab2f4fb

Choose a tag to compare

feat: Allow to set a database to connect to in a script (#43)

## Add database parameter to postgresql_script resource

  ### Summary

Adds an optional `database` parameter to `postgresql_script` to specify
which database to execute commands in. Defaults to the provider's
configured database for backwards compatibility.

  ### Changes

  - Added `database` schema field (optional, computed)
- Updated connection logic to use `getDatabase()` helper and create new
connection if needed
- Refactored to call `ReadImpl()` at end of Create/Update (matches
pattern used by `postgresql_schema`)

  ### Usage

  ```hcl
  resource "postgresql_script" "app_schema" {
    database = "myapp"
    commands = ["CREATE TABLE users (id INT)"]
  }
```
  
  ### Breaking Changes

  None - fully backwards compatible.

 ### FOR REVIEWERS 

I did not close explicitely the connection because tests was failling due  to ` Error: Commands execution failed .... sql: database is closed`
It seems that for a DB the provider need to be able to reuse a connection pool that is cached for further operation. So if we close the connection we have issue for further connections

v2.26.0-beta2

22 Oct 16:02
ab2f4fb

Choose a tag to compare

feat: Allow to set a database to connect to in a script (#43)

## Add database parameter to postgresql_script resource

  ### Summary

Adds an optional `database` parameter to `postgresql_script` to specify
which database to execute commands in. Defaults to the provider's
configured database for backwards compatibility.

  ### Changes

  - Added `database` schema field (optional, computed)
- Updated connection logic to use `getDatabase()` helper and create new
connection if needed
- Refactored to call `ReadImpl()` at end of Create/Update (matches
pattern used by `postgresql_schema`)

  ### Usage

  ```hcl
  resource "postgresql_script" "app_schema" {
    database = "myapp"
    commands = ["CREATE TABLE users (id INT)"]
  }
```
  
  ### Breaking Changes

  None - fully backwards compatible.

 ### FOR REVIEWERS 

I did not close explicitely the connection because tests was failling due  to ` Error: Commands execution failed .... sql: database is closed`
It seems that for a DB the provider need to be able to reuse a connection pool that is cached for further operation. So if we close the connection we have issue for further connections

v2.26.0-beta1

08 Apr 10:05
8c46e7d

Choose a tag to compare

Add support for GCP IAM impersonation (#26)

Back port of PR:
https://github.com/cyrilgdn/terraform-provider-postgresql/pull/448
---
Add support for GCP IAM service account impersonation

### Use cases

The company has a centralized service account that is used for Terraform
automation. However, such GSA should not be used to access the database
directly where each database will have its own IAM DB users.

This added an option to impersonate the database IAM user via the
centralized GSA. As long as the centralized GSA has sufficient
permissions to impersonate as the database IAM DB user, it can be used
to perform database automation in Terraform.

### Testing 

```hcl
resource "google_sql_database_instance" "self" {}
resource "google_sql_user" "admin" {}
resource "google_service_account" "db_iam_admin" {}
resource "google_sql_user" "iam_admin" {
  name     = trimsuffix(google_service_account.db_iam_admin.email, ".gserviceaccount.com")
  instance = google_sql_database_instance.self.name
  type     = "CLOUD_IAM_SERVICE_ACCOUNT"
}
resource "google_project_iam_member" "iam_admin_project_iam_members" {
  for_each = toset(["roles/cloudsql.client", "roles/cloudsql.instanceUser"])
  member   = google_service_account.db_iam_admin.member
  role     = each.key
}

provider "postgresql" {
  scheme                              = "gcppostgres"
  host                                = google_sql_database_instance.self.connection_name
  username                            = trimsuffix(google_service_account.db_iam_admin.email, ".gserviceaccount.com")
  gcp_iam_impersonate_service_account = google_service_account.db_iam_admin.email
  port                                = 5432
  superuser                           = false
  alias                               = "iamAdmin"
}

# it should work and able to apply resources using the IAM db user
resource "postgresql_*" "*" {
  provider = postgresql.iamAdmin

  // *
}
```

Co-authored-by: Michael Lin <[email protected]>

v2.25.0-beta4

24 Mar 12:25
70b714f

Choose a tag to compare

replace exec with execContext (#21)

v2.25.0

24 Mar 13:40
70b714f

Choose a tag to compare

replace exec with execContext (#21)

v2.25.0-beta3

20 Mar 14:05
00bf3c6

Choose a tag to compare

Use exec for resource_postgresql_script

v2.25.0-beta2

20 Mar 11:31
86484bc

Choose a tag to compare

fix cast to string error and refactor casts (#19)

v2.25.0-beta1

19 Mar 09:00
23d0133

Choose a tag to compare

add postgresql_script resource (#18)

Add a `postgresql_script` resource enabling to execute an array of sql
queries.

v2.24.0

04 Feb 08:47
9864481

Choose a tag to compare

fix(PSRE-2088): error when setting owner on publication with "-"s (#17)

It's impossible to set the owner of the publication when this one
contains dashes in the name