This message was deleted.
# general
s
This message was deleted.
l
You need to
up
first, to apply the change, then remove it from your code to delete it.
w
up
is what is failing
l
Is it failing because it's trying to delete it?
w
I think
up
failed when I first set
protect=True
and now if I run
up
again it tries to delete it and fails. If I set
protect=False
and run
up
it also fails.
l
The error message may be helpful.
w
Copy code
pulumi-python:dynamic:Resource (WriteSSHAuthorizedKeys):
    error: Preview failed: refusing to delete protected resource 'urn:pulumi:prod::tlayen-infrastructure::pulumi-python:dynamic:Resource::WriteSSHAuthorizedKeys'

  pulumi:pulumi:Stack (tlayen-infrastructure-prod):
    error: preview failed
perhaps that
preview failed
(whatever that means) is relevant.
l
Your protect=true worked. Your code is trying to delete the resource. You can't do that until after you have changed the protect opt to false. You can't do that at the same time as destroying it.
You have to change your code so that it's not trying to destroy the resource. Undo your recent changes. When it's working again, you can change the protect to false, and run
up
. After that works, you can then delete the code and up again: this will destroy the resource.
w
Damn ok. That is not very obvious. I had a bug in the previous version of my provider which means that this second time I run it it thinks it is different and wants to replace it. I'm going to have to put the bug back in just so I can remove the protected flag. There really ought to be a way to override that.
l
You can delete it manually and delete if from your state file...
w
Can I do that when using the Pulumi service backend?
l
Yes, you can use
pulumi state unprotect
and
pulumi state delete
to make Pulumi forget about the resource, and then you can delete it at your leisure. Then you can
up
again to create the new version.
Or you can use
pulumi stack export --file state.json
and
pulumi stack import --file state.json
to achieve the same thing, manually.
Have to be more careful with that, could damage the state. Keep backups.