any recommendations on splitting an existing stack...
# general
e
any recommendations on splitting an existing stack into two separate ones ?
a
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
Great, thank you
a
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
nice