echoing-battery-92169
07/21/2025, 6:02 PMcustom backend (s3)
, i am trying to reference a stack that is owned by the infrastructure team. Here is the backend for the infra team:
url: <s3://pulumi-state-us-west-2/development-us-west-2>
The project is development, while their stack is "us-west-2". They use stacks per region.
The application team, maintains their own project/stack and uses the same s3 bucket but in a different folder:
url: <s3://pulumi-state-us-west-2/apps/us-west-2/shared>
Project is "shared" or app name, while the stack is "development-us-west-2" or "<env>-<region>.
I am trying to reference the infrastructure stack in code like so:
export function getInfrastructureStackReference(
environment?: string,
region: string = 'us-west-2',
): string {
const env = getEnvironment(environment);
return organization/${env}/${region};
}
export function getInfrastructureStackReferenceObject(
environment?: string,
region: string = 'us-west-2',
): pulumi.StackReference {
const env = getEnvironment(environment);
const cacheKey = ${env}-${region};
if (!infrastructureStackCache[cacheKey]) {
const stackRef = getInfrastructureStackReference(env, region);
infrastructureStackCache[cacheKey] = new pulumi.StackReference(stackRef);
}
return infrastructureStackCache[cacheKey];
}
However, I get this error on pulumi preview
.
Diagnostics:
pulumi:pulumi:StackReference (organization/development/us-west-2):
error: Preview failed: unknown stack "organization/development/us-west-2"
Anyone know if I am getting this error because the s3 bucket has a different folder than the infrastructure team?
The docs seem to indicate you can here:
https://www.pulumi.com/docs/iac/concepts/state-and-backends/
The bucket-name value can include multiple folders, such as my-bucket/app/project1. This is useful when storing multiple projects' state in the same bucket.
echoing-dinner-19531
07/22/2025, 6:51 AMTLDR: Can i reference a different pulumi project/stack with stack-references when using a DIY backend (s3) where there a multiple folders?Not currently, I thought there was an issue for this but currently not seeing it in the search list.
The bucket-name value can include multiple folders, such as my-bucket/app/project1. This is useful when storing multiple projects' state in the same bucket.We should probably remove that from the docs. The CLI has had support for managing project folders natively for the last couple of years, there's no need for a path per-project for the backend url.
echoing-battery-92169
07/22/2025, 7:29 PMNo matter how you like to participate in developer communities, Pulumi wants to meet you there. If you want to meet other Pulumi users to share use-cases and best practices, contribute code or documentation, see us at an event, or just tell a story about something cool you did with Pulumi, you are part of our community.
Powered by