Hello everyone, I am using pulumi postgresql provi...
# general
b
Hello everyone, I am using pulumi postgresql provider 3.6.0 version and tried to update to latest one (3.15.1). I face the following issue: • I deploy a postgresql function with this provider, which is removed from pulumi state during pulumi refresh, after I upgrade to provider 3.15.1. • But function continues to exist inside postgresql itself Anyone faced similar issue? Is there some guide on how to properly upgrade a provider without issues?
l
You upgraded provider, didn't run
up
, 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?
b
• So, if you run
pulumi 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:
Copy code
~ 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 😕
l
That's because Pulumi doesn't know that the resource in Postgres is the resource in its state. The easiest fix at this point is to import the existing resource via the existing code,. adding the
import
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.
b
thanks for your suggestion!