Is there a way to create stack references across p...
# general
r
Is there a way to create stack references across projects when not using the pulumi service? Say I have a project in
<s3://foo/project1|s3://foo/project1>
and an other in
<s3://foo/project2|s3://foo/project2>
b
yep, just references the name of the project:
Copy code
const stackRef = new pulumi.StackReference("vpc.prod")
It's recommended to name your projects and stacks with prefixes like you can see here
l
Doesn't that work only when the two projects have the same backend URL? So you'd need both to have
<s3://foo/allprojects>
, and then you can refer to "vpc.prod" in there, from the prod stack of the app project..
r
I don't get how this works. If I am in project1 and want to reference project2 (stack dev) I just have to use "project2.dev"? How does pulumi know its in
<s3://foo/project2/.pulumi/stacks/|s3://foo/project2/.pulumi/stacks/>
l
Iirc, you can't. You need to have both projects in the same key in the same bucket. And that's what you need the stack name to include the project name: so that they get different keys in the one big json file.
r
Oh damned..
Are there references to filenames and buckets in the files or can I get away by just moving them?
l
Can't answer that. You can definitely create a new stack in the right place, then export the old one and import it to the new place.
r
I see
Well then, let the nightmare begin, thanks a lot! 😭
l
Please note, my responses have been caveated with "iirc".. this is how it was over a year ago, when I used S3 buckets. Lee may well be right, things may have been improved...
Worth double-checking.
r
Where can I double check anyway? The doc just does talk about that, and most github issues are 2y old anyway, this slack is the only source of info AFAIK
l
Just try a stackreference like Lee suggested 🙂
g
@refined-appointment-5884 Check this project, it's quite complex and has many projects and directories https://github.com/mitodl/ol-infrastructure/tree/main/src/ol_infrastructure
b
it's not improved I'm afraid, I didn't realise there were things being stored under different paths. You're correct in saying that won't work @little-cartoon-10569
r
It creates weird things to have all projects use the same s3 key
Like
stack ls
now lists stacks from other projects
I named my stacks project1.prod and project2.prod
And when doing stack ls for project1 is see both project1.prod and project2.prod
Also export/import will not work as stack names are different >_<
Need to stack rename first
p
FWIW, it looks like this is going to get a lot better soon: https://github.com/pulumi/pulumi/issues/4605
(from the Pulumi Roadmap)