cyrilgdn / terraform-provider-postgresql

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

Add database parameter on function resource #216

Closed LucasBoisserie closed 2 years ago

LucasBoisserie commented 2 years ago

Overview

This allows specifying database when creating a function.

Actual behavior

When creating a function is always created in the provider's database.

LucasBoisserie commented 2 years ago

any update @cyrilgdn ?

afterdesign commented 2 years ago

@cyrilgdn is there option to release this as 1.6.1/1.7.0 ? I just stumbled on this issue while working on pghero permissions.

graham1228 commented 2 years ago

@cyrilgdn I'm also interested in using this. Is it possible to release master with this code?

ghost commented 2 years ago

@cyrilgdn this is also blocking something I'm working on. Obviously it's OSS so no-one has any claim on anyone's time - just wondering what the timeline is on the release for this so I know whether I can go ahead with using this provider.

ghost commented 2 years ago

For anyone else waiting for this to be released, there are two (or maybe three) potential workarounds:

  1. If the database you want to add the function to already exists (i.e. isn't being created elsewhere in the same terraform), you can create an aliased provider instance just for the function so the postgresql_function resource will pick up the aliased provider's default database
  2. If the database you want to add the function to is being created in the same terraform as the function itself, you won't be able to do this because the aliased provider won't initialise properly due to the database not existing yet. If you're in this situation, you can create a separate terraform stack entirely - so you run terraform apply on one stack to deploy your database, and then run terraform apply on a second stack to deploy your function
  3. If you create the aliased provider inside a sub-module it might be possible to solve the problem outlined in option 2 by using terraform apply --target... to do a targeted apply. I haven't tried this though so I don't know whether it'll work in practice.