brash-stone-71192
05/07/2025, 9:23 AMlittle-cartoon-10569
05/07/2025, 8:59 PMup, but did run refresh? If that removed the resource from state, then something changed how Pulumi identifies the resource, and it thought that the resource was gone.
The most likely cause is a change of Name, but the same thing might happen for any replacement change. The docs say there are 6 trigger properties for Function: Name, Returns, Schema, Language, Database and Args. Did any of those change?brash-stone-71192
05/08/2025, 7:37 AMpulumi refresh, this removes function from state
• If you directly run pulumi up, without refresh, you get an error that function already exists
In general, pulumi preview, without refresh shows that the following settings will be added:
~ pulumi:providers:postgresql: (update)
[id=REDACTED-PROVIDER]
[urn=urn:REDACTED::REDACTED::pulumi:providers:postgresql::REDACTED-PROVIDER]
~ connectTimeout: 180 => "180"
- sslmode : ""
+ version : "3.15.1"
+-postgresql:index/function:Function: (replace)
[id="tools"."pg_function"(integer)]
[urn=urn:pulumi:REDACTED::REDACTED::postgresql:index/function:Function::REDACTED]
[provider=urn:pulumi:REDACTED::REDACTED::pulumi:providers:postgresql::REDACTED::REDACTED-PROVIDER]
~ body :
...
+ language : "plpgsql"
+ parallel : "UNSAFE"
+ securityDefiner: false
+ strict : false
+ volatility : "VOLATILE"
So, it tries to add those settings you mentioned, which cause replacement (default values - they are already set inside body, but anyways).
And I have added deleteBeforeReplace resource option, so it is removed before, but I still get "resource already exists" error during replacement 😕little-cartoon-10569
05/08/2025, 8:05 AMimport opt. That tells Pulumi that what's in your code and what's in Postgres are actually the same thing. And it will know to delete it, or update it, correctly.brash-stone-71192
05/08/2025, 8:06 AM