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

orange-byte-86458

10/05/2021, 9:56 PM
Hi, Pulumi team! I’m wondering if there are any tutorials/articles on splitting a large project into multiple subprojects. Right now I have thousands of resources all originating from the same index.ts. Most of them are created implicitly, as children of things like EKS clusters, cofig groups, etc. For various reasons I’d like to split it into 4-5 subprojects and I’m wondering what would be the most efficient way of doing this without disrupting existing infrastructure. I guess, my main challenge is around properly renaming all URNs and ensuring that a new state won’t trigger any unexpected updates. Thanks for any help!
l

little-cartoon-10569

10/05/2021, 10:12 PM
Generally you won't need to worry about URNs. You can bulk import resources to a new stack: https://www.pulumi.com/docs/guides/adopting/import/#bulk-import-operations Then just
pulumi state delete
all those resources. You may also consider moving resources from index.ts to ComponentResources, but that can happen later.
o

orange-byte-86458

10/05/2021, 11:40 PM
Thank you, @little-cartoon-10569!
I think, my problem with import & delete is this 👇 (note the number of lines) It’s not really feasible to move all those things one by one. I wish I could do
state delete
/
import
only on top level resources and expect it to be applied to all children, but pulumi doesn’t work this way for some reason..
l

little-cartoon-10569

10/06/2021, 9:35 PM
Would you be able to do the reverse? Move / rename the stack so that most resources move to the right place, then move the minority back to the original stack?
While bulk importing is easy enough, the only way to do a bulk state delete is to export the stack, remove the relevant resources, and re-import the stack. This is obviously a higher-risk solution.
Of course, you could script the state delete... It'll take longer to write the script them update the state one resource at a time, but it'll be less boring and safer 🙂
o

orange-byte-86458

10/06/2021, 9:55 PM
Yeah, I think scripting the whole process is what I’m going to do… I hope, it will eventually be possible to perform operations like this using the pulumi CLI itself 🙂