I am very new to pulumi. I came from terraform. Ho...
# general
a
I am very new to pulumi. I came from terraform. How do you handle someone deleting a lambda function and your pulumi command now says
I am using s3 backend. Am I now at a point that I need to just delete everything.
m
I don’t have much experience with the S3 backend, but have you tried running
pulumi refresh
(or passing the
--refresh
option to
pulumi up
) to update your stack’s state before updating?
a
I did, I get that error when I run the command as well.
b
It says what the problem is - you have a child resource that references an urn for a parent that is no longer in your state. This error is specifically a pulumi state issue. You could export your state and fix it manually and then re-import it. It sounds like a resource that has children was removed from your pulumi state and the children were orphaned
Like someone did a “pulumi state delete” command erroneously
a
Some one deleted some lambda functions manually.
b
Modifying cloud resources outside of pulumi is bound to happen and would be easily rectified by doing a refresh before your next up invocation. But that wouldn't cause this issue that you are seeing. Like I said, this is a pulumi state issue. Your state is invalid. If you export your state and examine the JSON you will find one or more resources whose “parent” field is an URN for a resource that is not represented in that same JSON. You can either: 1. Delete the orphaned children from your state. Their cloud counterparts will still exist, so at this point you would import them back into your state after re-creating the parent so that everything is back to normal. 2. Delete both the orphaned children from your state and their cloud counterparts, at which point a refresh and a new up invocation will recreate the parent and the children.
You can use “pulumi stack export” and “pulumi stack import” to retrieve & re-save that JSON respectively. https://www.pulumi.com/docs/reference/cli/pulumi_stack_export/
a
Okay cool. So pulumi is not “reaching out” to “query” the infrastructure then. something is messed up in the state file. that makes more sense. i would have expected pulumi to just recreate the deleted thing
let me try that
b
If you want to delete the orphaned children from your state you can either use “pulumi state delete” to remove them individually, or you can export the JSON and manually remove them before importing. If you don't want to delete the cloud counterparts of those children than you would use this method to import existing resources into your stack: https://www.pulumi.com/docs/guides/adopting/import/
Well during a “pulumi refresh” it does exactly that, it queries the infrastructure and reconciles that with what it has in its state. But if the state is invalid than it isn't able to get that far. Ordinarily yes, it should just recreate the missing infra after doing a refresh. I suspect something else happened that left your state in an invalid position.
a
Oh dang. I am not even able to export. It gives the same error.
Something is not happy.
State delete also has the same error.
b
Well it does give you the URN in the error message, so you could try
pulumi state delete “URN”
with maybe “—disable-integrity-checking” if needed. And then a refresh
a
ahh I will try the flag. I tried to delete that URN.
❤️ thank you for all the help. This is so foreign.
🙌 1
HUZZAH the stack is refreshing now.
b
Great!