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

great-sunset-355

10/28/2021, 12:51 PM
Is it possible to sort exported stack JSON in order it should be in case it was reordered?
p

prehistoric-activity-61023

10/28/2021, 12:52 PM
let me find a
jq
one-liner I’ve posted here 😄
g

great-sunset-355

10/28/2021, 12:52 PM
do you think it's possible to reverse the operation though?
p

prehistoric-activity-61023

10/28/2021, 12:53 PM
now I’m confused - you’re the person I replied to 🤔
Copy code
pulumi stack export | jq '.deployment.resources|=sort_by(.urn)'
g

great-sunset-355

10/28/2021, 12:53 PM
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

prehistoric-activity-61023

10/28/2021, 12:53 PM
oh, you mean that the order is actually important for
pulumi import
operation?
g

great-sunset-355

10/28/2021, 12:53 PM
yes
p

prehistoric-activity-61023

10/28/2021, 12:53 PM
damn 😐
g

great-sunset-355

10/28/2021, 12:54 PM
I suspect the order is by parent
I'll give it a try and let you know
p

prehistoric-activity-61023

10/28/2021, 12:54 PM
that might do the trick
but I’m afraid it should probably be a little bit more complicated
g

great-sunset-355

10/28/2021, 12:54 PM
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

prehistoric-activity-61023

10/28/2021, 12:55 PM
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

great-sunset-355

10/28/2021, 12:55 PM
yes, parents must be first
p

prehistoric-activity-61023

10/28/2021, 12:56 PM
so I guess we’re coming back to the topic to add some dedicated support for that
g

great-sunset-355

10/28/2021, 12:58 PM
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

red-match-15116

10/28/2021, 4:59 PM
Ah yeah as you’ve discovered the order in the state file is by dependency
1
2 Views