Is it possible to use an output from a stack in an...
# general
a
Is it possible to use an output from a stack in another stack and/or another project ?
b
Most people use a combination of stack exports plus configuration to do this. For instance, say you provisioned a VPC in one stack and want to use it inside another. In the lower level stack, you'd say
Copy code
let vpc = new aws.ec2.VPC(...);
...
export let vpcID = vpc.id;
and then in a higher level stack, you'd accept the VPC as config
Copy code
let config = new pulumi.Config(pulumi.getProject());
let vpcID = config.require("vpcID");
We've tried to make this easy to write tools to automate. For instance, once you've stood up that lower level stack, you can easily grab the resulting VPC ID, e.g. by running
export MY_VPC_ID=$(pulumi stack output vpcID)
. And then for that higher level stack, you can just say
pulumi config set vpcID $MY_VPC_ID
. We do have a work item to make this flow more first class, because it is so common. See https://github.com/pulumi/pulumi/issues/109, and please feel free to weigh in if you have ideas. Things we'd like to do here include tracking inter-stack dependencies in a first class way (so you know if a change at the lower layer affects a downstream consumer), and potentially even orchestrating the cross-stack updates for you.
a
I'm really not fond of having static linking through
pulumi config
, that's pretty dangerous and may lead to errors if what's statically referenced don't exist anymore of have changed in the meantime. I answer the issue, let's talk about it there