https://pulumi.com logo
r

refined-appointment-5884

10/20/2021, 4:16 AM
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

billowy-army-68599

10/20/2021, 4:27 AM
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

little-cartoon-10569

10/20/2021, 4:35 AM
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

refined-appointment-5884

10/20/2021, 4:36 AM
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

little-cartoon-10569

10/20/2021, 4:37 AM
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

refined-appointment-5884

10/20/2021, 4:38 AM
Oh damned..
Are there references to filenames and buckets in the files or can I get away by just moving them?
l

little-cartoon-10569

10/20/2021, 4:39 AM
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

refined-appointment-5884

10/20/2021, 4:39 AM
I see
Well then, let the nightmare begin, thanks a lot! 😭
l

little-cartoon-10569

10/20/2021, 4:41 AM
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

refined-appointment-5884

10/20/2021, 4:42 AM
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

little-cartoon-10569

10/20/2021, 4:42 AM
Just try a stackreference like Lee suggested 🙂
g

great-sunset-355

10/20/2021, 5:00 AM
@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

billowy-army-68599

10/20/2021, 5:22 AM
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

refined-appointment-5884

10/20/2021, 6:38 AM
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

prehistoric-london-9917

10/21/2021, 7:55 PM
FWIW, it looks like this is going to get a lot better soon: https://github.com/pulumi/pulumi/issues/4605
(from the Pulumi Roadmap)
2 Views