https://pulumi.com logo
#general
Title
# general
j

jolly-lunch-12979

04/06/2021, 1:23 PM
When using
pulumi state delete
is there a way to pass in multiple resources to delete from the state? Doing it one at a time is pretty slow.
b

brave-planet-10645

04/06/2021, 1:45 PM
No there isn't. Editing the state like this is something that you probably don't want to do regularly
j

jolly-lunch-12979

04/06/2021, 1:49 PM
Yeah unfortunately this comes from needing to migrate a lot of resources from Azure -> Azure Native. Which means deleting all the dependencies from the state before reimporting everything.....
And I'd rather avoid having to edit the state file directly
b

brave-planet-10645

04/06/2021, 1:54 PM
Ah of course
But no we don't have a way of removing more than one resource at a time
h

handsome-state-59775

04/06/2021, 2:45 PM
could you loop over it using your shell?
j

jolly-lunch-12979

04/06/2021, 3:08 PM
That's pretty much what I was doing @handsome-state-59775, but it takes maybe a minute or more each time. Not ideal on a couple hundred resources....
h

handsome-state-59775

04/06/2021, 3:14 PM
Copy code
for resource in "${resource_list[@]}"; do
    pulumi state delete "${resource}" -y &  # HOW ABOUT THIS?
done
wondering if concurrent deletes are safe... @brave-planet-10645?
b

brave-planet-10645

04/06/2021, 3:14 PM
That is a question I'm going to have to ask internally... BRB
Official answer is "wouldn't recommend it"
👍 1
j

jolly-lunch-12979

04/06/2021, 4:50 PM
Yeah not surprised with that at all, it shows it as an "Import" action in the webui when you run
pulumi state delete
so I imagine it's exporting the stack, modifying it and reimporting it? Doing that concurrently....nope.
b

brave-planet-10645

04/06/2021, 4:52 PM
Obviously you could run it not concurrently, but yes as you say if you've got a lot of resources it will take a while
j

jolly-lunch-12979

04/06/2021, 4:54 PM
Yeah in the end I exported the stack, edited it in vscode and reimported it. Preview is looking better but not upped it yet (Did find one case of accidentally deleting something that shouldn't have been, but it threw an error about that during import at least. Reinforces why I was trying to avoid manual state edits....)
Added some of these thoughts to the already open github issue about making Azure -> Azure Native migrations easier https://github.com/pulumi/pulumi/issues/6399
36 Views