https://pulumi.com logo
Title
b

breezy-lunch-69325

06/27/2021, 12:52 AM
I have a monorepo setup with a core infra package which creates my vpc and ecs cluster that i need to reference in order to create fargate services in other stacks. I can't find any way to reference these resources to create a service, even using stack reference I am only able to access outputs, not resources. Is there any documentation on how to setup pulumi with a mono repo / reuse resources across stacks
e

enough-leather-70274

06/27/2021, 1:48 AM
I have opened an issue at https://github.com/pulumi/pulumi/issues/7360... be great if you could add your thumbsup on that so it gets some traction.
In the meantime, my favoured workaround is demonstrated alongside the issue at https://github.com/followben/pulumi-example. If you check the threads above there are a number of alternate suggestions.
d

damp-school-17708

06/27/2021, 11:12 AM
I am in the same boat, for now I use StackReference and work my way out with vpcId, subnetId, etc exported. It's not too bad tbh
(I do a .get when I need something)
the best advice I've read in this 'forum' is to keep things that have a similar rate of change close together (something that works as well with services)
I need to find an hour to blog about this
🙂
oh sorry I should have read the issue, your problems are mostly around sharing libraries not cloud components
👍 1
b

bored-oyster-3147

06/27/2021, 3:19 PM
@breezy-lunch-69325 This is because you are using crosswalk which has some APIs that require the full resource. If you used the core provider instead you would never have this issue. IMO crosswalk is meant to simplify trivial setups, but when you start getting into complex setups you shouldn’t rely on crosswalk anymore
For instance in
awsx
FargateTaskDefinition is just an extension of
aws.ecs.TaskDefinition
and FargateService is just an extension of
aws.ecs.Service
. These types are meant to simplify the creation of Fargate resources, but they could be configured entirely from
aws.ecs.TaskDefinition
and
aws.ecs.Service
respectively and you wouldn't need to use
awsx
which requires you to provide an entire resource instance in the args.
b

breezy-lunch-69325

06/27/2021, 8:10 PM
yep @bored-oyster-3147 that's exactly what i'm realizing, I could probably just export the necessary ids for vpc and ecs cluster and then instead of using the crosswalk classes just uses the base classes which don't require passing entire resources.
b

bored-oyster-3147

06/27/2021, 8:18 PM
Yes sir. The good thing is since crosswalk code is right there you can make sure you are declaring your resources the same way crosswalk would be, to ease transition
e

enough-leather-70274

06/27/2021, 11:09 PM
Sorry for the confusion there @breezy-lunch-69325. Indeed I thought you were trying to share your own components or resource definitions. To share individual resources between stacks we just use just use stack refs (and it's always export the id of the resource and import it to instantiate the resource in question where required).
awsx
isn't available in python, so we use the underlying
aws
resource types.