This message was deleted.
# general
s
This message was deleted.
l
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
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
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
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
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
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
You will have to merge them.
w
but if I switch to using Pulumi account then i cannot use s3 backend anymore?
l
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.
👍 1
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
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
👍 1
specify the referenced stack like this works
Copy code
const stackRef = new pulumi.StackReference('stack-ref-test', {
  name: 'stack-ref-child',
});
👍 1
o
@little-cartoon-10569 we recently merged support for projects in file backends like S3, which may be in the next release.
👍 1
@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
@orange-policeman-59119 thanks for confirmation