https://pulumi.com logo
Title
w

wet-fall-57893

02/01/2023, 3:18 AM
Is it possible to use Stack References without having a pulumi account?
l

little-cartoon-10569

02/01/2023, 3:36 AM
Yes. You need to use the same backend for all projects, so they're all stored in the same location. Then each stack can read all the others.
w

wet-fall-57893

02/01/2023, 3:40 AM
All my current stacks are stored in the same s3 bucket e.g
<s3://david-pulumi-state/>
however, they are not setup following
org/projectName/stackName
format. If I leave out
org
part when creating stackReference object, it throws out an error. Any idea how to resolve that? Thanks
I tried with backend in the position of
org
but got error
stack names may not contain slashe
l

little-cartoon-10569

02/01/2023, 4:25 AM
The backemd URL has to be exactly the same. Character-for-character. You can't use the project name or stack name in the backend, if you want stack references to work.
All the states have to go in the same file.
Orgs don't exist in S3 backends. Project names aren't used. Therefore, the general recommendation is for stack names to include the project name.
w

wet-fall-57893

02/01/2023, 4:27 AM
All the states have to go in the same file.
you mean the same place which in my case the same s3 bucket right?
l

little-cartoon-10569

02/01/2023, 4:27 AM
So you'd have Pulumi.myproj_europe.yml for the europe stack in myproj project.
No, in the same file.
Not just the same backet, the same object in the bucket.
You can use different objects in the bucket, but then you won't be able to use stack references.
w

wet-fall-57893

02/01/2023, 4:29 AM
my current setup is one object per stack. e.g I would have 2 separate objects for
dave-dev
and
dave-staging
stacks in project
dave
.
l

little-cartoon-10569

02/01/2023, 4:30 AM
You will have to merge them.
w

wet-fall-57893

02/01/2023, 4:30 AM
but if I switch to using Pulumi account then i cannot use s3 backend anymore?
l

little-cartoon-10569

02/01/2023, 4:31 AM
You can if you want, but the Pulumi service is better in all ways than a self-managed backend (in my opinion).
I haven't used the S3 backend since it was improved: it now has file locking, which was a big problem for me in the past. But it's quite a way behind app.pulumi.com, in terms of features.
Oh my mistake, it's not technically a single bucket object that the state is stored in: it's a single bucket path. Pulumi manages the objects underneath. But as I understand it, there is a single state file, shared between all projects and stacks. (Happy to be proven wrong on this though!)
w

wet-fall-57893

02/01/2023, 4:40 AM
The reason I am asking about cross-stack ref is I am trying to split up our monolithic EKS state file and that requires us to reference resources from stacks as their outputs
have verified stacks need to point to the same backend path before they start to work
specify the referenced stack like this works
const stackRef = new pulumi.StackReference('stack-ref-test', {
  name: 'stack-ref-child',
});
o

orange-policeman-59119

02/01/2023, 8:03 AM
@little-cartoon-10569 we recently merged support for projects in file backends like S3, which may be in the next release.
@wet-fall-57893 stack references must use the same backend, that's correct. For projects created using the new CLI, you will be able to use stack references like "projectName/stackName".
One more nit: there should be a state file per stack, and there are a few other files. If you explore the backend via console, you should find historical state files as well.
w

wet-fall-57893

02/01/2023, 8:20 AM
@orange-policeman-59119 thanks for confirmation