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

elegant-laptop-80400

05/22/2023, 6:57 PM
any recommendations on splitting an existing stack into two separate ones ?
a

ambitious-father-68746

05/22/2023, 8:07 PM
The way I've done it before is: 1. Create the new stack 2. Export the first stack and import it into the second stack 3. For each stack, get a list of URNs that you want to delete 4. Run
pulumi state delete <URN>
for each URN in each stack 5. Done Your mileage may vary, but I find this to be the easiest. Building a new stack from scratch and importing resources is just way too time consuming. The old stack already has all the information
To get the URNs,
jq
or a carefully crafted
grep
do the job.
Or even just output to a file and edit by hand, doesn't really matter as long as you feel comfortable with it.
e

elegant-laptop-80400

05/22/2023, 8:09 PM
Great, thank you
a

ambitious-father-68746

05/22/2023, 8:10 PM
Save a copy of the old stack just in case 🙂
The interesting bit is that you don't need to touch any resource during this operation. After you split the stacks and do
pulumi up
on both of them, nothing should change. If that's the case, success! If you think you screwed up, load the backup and try again.
e

elegant-laptop-80400

05/22/2023, 8:12 PM
nice
2 Views