https://pulumi.com logo
Title
r

rough-window-15889

05/12/2021, 11:21 PM
What’s a recommended recourse for manual deletion of parent resource from cloud provider? I manually deleted a resource and removed it from the code, but it has children resources that need to be deleted as well. When I try to run Pulumi up it tried to delete the children but fails saying the resource refers to a missing parents. Is there an easy workaround for this? Should I manually edit the stack and replace the parent resource with the stack as the parent? The end result I would like is to completely delete the resource and children from the cloud provider and stack.
l

little-cartoon-10569

05/12/2021, 11:30 PM
To delete resources from the provider, remove them from code (or comment them out for a while) then run
pulumi up
.
c

colossal-australia-65039

05/13/2021, 12:05 AM
I'd suggest adding that parent resource back in the state and attempting another
pulumi up
. I haven't been in this situation though so I'm not positive it will work
l

little-cartoon-10569

05/13/2021, 12:07 AM
Likely, you can import it fairly easily using the existing code, and adding the
import
opt.
r

rough-window-15889

05/13/2021, 12:09 AM
I see so create it in azure and use the import option?
c

colossal-australia-65039

05/13/2021, 12:10 AM
not sure if the children will be properly configured to be "attached" to the parent if you create it manually and import it though
l

little-cartoon-10569

05/13/2021, 12:11 AM
Is it not already in Azure?
If it is gone from Azure and state, then I think the easiest thing is likely to be to resolve everything manually. Remove the code, delete the resources from state manually, and delete them from Azure manually.
Depending on how many child resources there are, of course.
r

rough-window-15889

05/13/2021, 12:29 AM
Yeah so the parent resource is deleted. It has some sql users that are children that I wanted to avoid manually deleting but looks like that’s the route I’ll need to likely take
r

red-match-15116

05/13/2021, 12:41 AM
have you tried
pulumi refresh
?
r

rough-window-15889

05/13/2021, 2:45 AM
Yeah refresh ended up detecting the parent was deleted, but then the children were left in a state where they reference the parent but the parent doesn’t exist.
If anyone was curious what we ended up doing, the child was a sql user and the parent was deleted in azure so we exported the stack to a Json file and changed the parent in the json file to be the database then imported the stack json file back in and ended up nuking the database by removing it from the Index file so it cleanly deleted everything and updated the stack properly then added it back in to regenerate all the resources cleanly. Thanks for all the help, everyone.