I am looking to understand Stack References; in pa...
# google-cloud
b
I am looking to understand Stack References; in particular, ones where the Stack Reference is on a different Google Storage bucket than the stack being used. Scenario: • Stack Account - configures an private artifact registry with charts, docker images, etc, along with a secret key Output. Hosted in, say, gs://bucket/account/ • Stack B - brings up a kubernetes cluster, networking, etc. Hosted in, say, gs://otherbucket/b/. • Problem: In Stack B's code, I want to reference Stack A to bring down the secret key and allow pulling from Stack A's output. Result (go SDK):
pulumi:pulumi:StackReference (<gs://bucket/account>):
error: Preview failed: unknown stack "account"
b
stack references dont work across buckets, you need to store state in the same bucket
b
I was terribly afraid of that. Do you offhand know if there are plans to change that? Because we're having a lot of different stacks and projects, sharing "deeper" refs would be nice.
b
There aren’t any plans to change that I don’t think, I’m not even sure how it would work
b
Query: what about different stacks from different projects in the same bucket?
b
yes that’s totally possible, it’s in the stack ref api
b
Hmmmm. I moved the stack state to
bucket
, but I'm still getting identical errors. Verbosity doesn't seem to help debug the matter either. I'm not sure how to trace the error beyond the "unknown stack" bit.
Copy code
stack, err := pulumi.NewStackReference(ctx,
			"<gs://bucket/integration/>",
			&pulumi.StackReferenceArgs{
				Name: pulumi.String("account"),
			},
		)
b
what is your stack name? are you storing things in different directories? ie
pulumi login <gs://bucket/integration>
and
pulumi login <gs://bucket/foo>
. if so, that won’t work
b
so we don't use
login
, we specify the URL in Pulumi.yaml. And yes, these are different directories.
these are different proejcts.
trying to read output from one project's stack into another project's stack.
b
you need to use the same URL for all projects, and name your stack something like
<http://integration.dev|integration.dev>
b
That ship sailed over a year ago......... sorry. There's no other solution?
b
project support in self managed backends is due to be shipped soon: https://github.com/pulumi/pulumi/issues/2522#issuecomment-1426496284
There’s no other solution?
Nope, if you don’t store state in the same place you won’t be able to use stack references
b
that's.... super frustrating. Anyway. Thanks for the canonical answer.