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

bored-branch-92019

04/27/2023, 2:16 PM
Is there any general guidance (blogs or docs) around strategies for breaking up a monolithic pulumi project into multiple smaller pulumi projects which use stack references? Key things would be I do not want any of the underlying infrastructure from the current monolithic project to be destroyed and really just transfer it over. We have one project for our entire application infra stack which includes some general infra that rarely changes and running into issues around length of deployments being 15-20 minutes long.
r

rough-morning-53309

04/27/2023, 5:52 PM
@bored-branch-92019 Have you checked out the recommended practices blog series by @salmon-account-74572? There are some guides and examples using stack references as well as some best practices around project/stack organization. More posts to come in this area as well. • IaC Recommended Practices: Code Organization and StacksIaC Recommended Practices: Developer Stacks and Git BranchesaC Recommended Practices: Structuring Pulumi Projects <-- check out this one for sure • IaC Recommended Practices: Using Stack References <-- check out this one too
s

salmon-account-74572

04/27/2023, 5:56 PM
Thanks for the mention, @rough-morning-53309! I think the post on structuring projects, along with the stack references post, are probably most applicable here. @bored-branch-92019, feel free to hit us up with any specific questions you have, we’d love to help.
b

bored-branch-92019

04/28/2023, 3:20 AM
Sorry for my delay in response, I have actually been following along that blog series and I love what you all are doing with that series. I am more looking for guidance on how to take an already monolithic project and split it up into multiple projects without deleting and recreating any resources. I think my understanding from these blogs and the docs is that I can do a-lot of this with stack references. So for example we have a single
infra
project which includes all three of the different projects that Zephyr has in the third post (I wish these had come out before we started 😅 ). I would like to break it into a bunch of different projects with exactly the thinking laid out in the blog hoping this will speed up deployments.
s

salmon-account-74572

04/28/2023, 2:22 PM
@bored-branch-92019 Ah, gotcha! Well…there is (at least) one supported way, and (at least) one unsupported way. The supported way would be look something like this: 1. Use
pulumi import
to import resources into a new project. 2. Massage the code generated by
pulumi import
(as needed) and run
pulumi up
to ensure the code matches the resources generated (i.e., it should say no changes). 3. Use
pulumi state delete
to remove the resources imported in step 1 from the original project. Adjust the code accordingly and run
pulumi up
to ensure the code matches the resources (i.e., it should say no changes). 4. Repeat steps 1 through 3 as needed. The unsupported way involves using
pulumi stack export
, manually editing the state file, and then
pulumi state import
with the edited file into a new project. There be dragons here, so be careful!
12 Views