Is it possible to sort exported stack JSON in orde...
# general
g
Is it possible to sort exported stack JSON in order it should be in case it was reordered?
p
let me find a
jq
one-liner I’ve posted here 😄
g
do you think it's possible to reverse the operation though?
p
now I’m confused - you’re the person I replied to 🤔
Copy code
pulumi stack export | jq '.deployment.resources|=sort_by(.urn)'
g
yeah now I need to reverse the operation because it broke the state. I
I'll try to sort it by parent and see if it breaks even more
p
oh, you mean that the order is actually important for
pulumi import
operation?
g
yes
p
damn 😐
g
I suspect the order is by parent
I'll give it a try and let you know
p
that might do the trick
but I’m afraid it should probably be a little bit more complicated
g
then it may be needed to move resources without parent but that's not that many
yeah
pulumi import
complains as it loads resources so it may help me. I have only few resources fortunately
p
if changing the order somehow breaks the
pulumi import
, it probably means it expects them in the right order (so dependent resources are declared before the are used etc.)
g
yes, parents must be first
p
so I guess we’re coming back to the topic to add some dedicated support for that
g
hmm now
pulumi import
did not complain but
pulumi up
hangs then kills itself
damn, I wish this was on staging stack not a production 😞
I guess my remote state got irreversibly corrupted
wait there are some checkpoints maybe that will help
ooof I managed to recover thanks to checkpoints!
r
Ah yeah as you’ve discovered the order in the state file is by dependency
1