After running `pulumi up` to deploy a GCP Postgres SQL DB, I ran `pulumi destroy` but got the error:...
b
After running
pulumi up
to deploy a GCP Postgres SQL DB, I ran
pulumi destroy
but got the error:
Copy code
failed to delete instance because deletion_protection is set to true. Set it to false to proceed with instance deletion
I then updated my pulumi typescript code to disable delete protection on the DB and ran
pulumi up
to apply that change. I checked in GCP Console to confirm that delete protection was indeed disabled. I then reran
pulumi destroy
but got the same error again. I then ran
pulumi refresh
and tried
pulumi destroy
once more but still get the same error. I have pulumi v3.177.0, typescript 5.8.3, and node v20.18.3
I found this GitHub Issue and, after reading it, I found that I have to set
deletionProtection
and
deletionProtectionEnabled
as follows:
Copy code
const dbInstance = new gcp.sql.DatabaseInstance(
    "...",
    {
      ...,
      deletionProtection: false,
      settings: {
        ...,
        deletionProtectionEnabled: false,
      },
    },
    {
      ...
    }
  );
I was originally only setting
deletionProtectionEnabled
. With the above change, running
pulumi up
followed by
pulumi destroy
finally worked.
Setting
deletionProtectionEnabled
to
false
is required to affect the actual GCP DB. Setting
deletionProtection
to
false
allows pulumi to delete this resource (but only if
deletionProtectionEnabled
is also
false
).