Any idea about this issue? We basically want to br...
# general
c
Any idea about this issue? We basically want to break down one of our monolithic stack to micro stacks, without downtime
b
I don't think there's an automated way, moving resources between stacks manually is probably the best bet. I'd probably make a new stack, clone the stack file from your current monolith and try and make a trimmed down 'top layer' then rinse and repeat. Once the top layer previews with no changes, you can remove those resources from the dependent layer and replace any references to them with e.g. StackReference or just normal blah.getResourceX() calls
c
Yeah, it basically the same as I thought, using import maybe better because it checks that the code and resource state is the same and gives a clear message what the difference, show the diff and deleting from the old stack with
pulumi state delete
better, because it only allows when it's safe (there is no dependency, parent/child relationship), so I get some feedback about the process correctness
b
import adopts the resource into the stack though so unless i misunderstand you, if you used that on dependent layers you wouldnt be able to modify them in the higher layers without them fighting each other for who is the source of truth for the state
not sure what the recommended best practice is but i basically created a load of createX and getX methods with identical parameters and return types of Promise<X> and put them in a node package so that we could have a load of layers without worrying about it too much
then we share the configs from higher layers and use get(config.blah) instead of create(config.blah) but the rest of the code can be the same
b
You are correct, there is not an automated way
You could import the resource as part of the new stack
Then use Pulumi export to get the stack - manually remove the resource and then Pulumi import with the new stack details and it will be removed from management
c
thanks, Paul, then we agree šŸ™‚
b
Iā€™d suggest looking in Pulumi/Pulumi for a related issue here and if not then create one - this is going to be something that people will ask more and more :)
c
I did not find a related one, so created a new: https://github.com/pulumi/pulumi/issues/3389
b
šŸ‘