Hi, Pulumi team! I’m wondering if there are any tu...
# general
o
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
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
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
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
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 🙂