https://pulumi.com logo
Title
r

rich-branch-48115

01/03/2023, 2:21 PM
Hey all 🙂 I'm transitioning into pulumi (pretty new to it), I'm trying to create two different programs that one references the other. I want to separate it into two different programs in order to split our huge project into small building blocks with dependencies and order. In my case I want to share a
k8s.Cluster
object from the first program into the second program that creates several virtual clusters inside the cluster from the first program. My questions are: • Is it possible to share the object as it is? • Is it possible to share my own custom
ResourceComponents
? • To implement that I need to have multiple stacks?
b

billowy-army-68599

01/03/2023, 2:40 PM
Is it possible to share the object as it is?
Yes, just export the type. In typescript this would be
export const cluster = k8s.Cluster(...
Is it possible to share my own custom ResourceComponents
You can easily reshare ComponentResources using whatever abstraction mechanism your chosen language uses
To implement that I need to have multiple stacks?
Can you elaborate on this question?
r

rich-branch-48115

01/03/2023, 2:54 PM
What do you mean by exporting the type? You mean exporting the object? (I'm using python but it does not really matter) When you say "reshare" Do you mean like calling the same type (my custom ResourceComponent type) with the same resource name and then just get it? Regarding the multiple stacks, I'm not sure that I have understood pulumi's architecture fully. I meant that if I want to have multiple pulumi programs (let's say 2) that shares
ResourceComponents
between them do I need to have multiple stacks as well? I'm trying to avoid calling the same ResourceComponent Type with the same resource name in order to share it. @billowy-army-68599
b

billowy-army-68599

01/03/2023, 2:57 PM
You mean exporting the object?
Yes that works too
cluster = k8s.Cluster

pulumi.export("cluster", cluster)
I meant that if I want to have multiple pulumi programs (let’s say 2) that shares ResourceComponents between them do I need to have multiple stacks as well?
Yes, each Pulumi program has
n
stacks. So in this case you’d have perhaps two projects: • cluster • app and each one of those projects would have a stack each, maybe called
dev
that shares ResourceComponents between them
Can you explain what you mean by “sharing” ? referencing the results of one project from another?
r

rich-branch-48115

01/03/2023, 4:19 PM
@billowy-army-68599 My meaning of "Sharing" is exactly what you've said. If cluster project is doing the following:
b

billowy-army-68599

01/03/2023, 4:39 PM
Yea that’s a very common pattern, are you having issues with it?
r

rich-branch-48115

01/04/2023, 9:21 AM
The things is that I'm getting an error when trying to access:
myCustomCluster = cluster_stack.get_output("sharedCluster")

def create_vcluster():
when I'm getting a warning
b

billowy-army-68599

01/04/2023, 3:57 PM
instead of exporting the entire cluster object, if you only need the provider, just export that. That’ll simplify things a lot.