Hello everyone, I am bit stuck with stack referenc...
# automation-api
h
Hello everyone, I am bit stuck with stack reference.. I am trying to refer outputs of a stack using stack reference and am storing my state files in local. Pls note that I am using python automation api to bring up my stack.
Copy code
from pulumi import StackReference

stack_ref = StackReference(name="stack-reference",stack_name = "project.mystack")
s3_name = stack_ref.get_output("s3_bucket")
print(s3_name)
b
Is that stack name correct? Usually its something like, "myorg/projectname/test"
h
Hi, Thank you for the response.. I had previously referred this thread below.. When we have a self-managed backend, the organisation reference does not exist.. there was an example in C# that am trying to replicate in python for local backend
Copy code
var stackReference = new StackReference("shared", new StackReferenceArgs { Name = "demo.dev" });
https://pulumi-community.slack.com/archives/C01PF3E1B8V/p1620250949128400
b
Ah, interesting.
e
@prehistoric-london-9917 or @hallowed-ice-8403 I’m trying to understand the same thing, self-managed backend (S3), how do you reference to another Stack. I’m doing some tests and getting
Copy code
pulumi:pulumi:StackReference (project_name/stack_name):
    error: Preview failed: unknown stack "project_name/stack_name"
b
@early-keyboard-41388 Did you try, org/projectname/stackname ?
e
@bored-activity-40468 Thanks for the reply. How/Where do I get the org name?
b
When you're in the console, if there's more than 1, like your username or an org your a member of,
h
@early-keyboard-41388 can u try without the project name.. This worked for me,
Copy code
reference = StackReference(mystack)
e
@hallowed-ice-8403 I did try this option, but all the project stacks have to be on the same folder and bucket on S3, with some sort of naming convention for stack to avoid collision. But I really don’t like that approach, having all state files on just on folder and forcing a different name on stacks. So trying to separate each project on folders, or going to use something else, Cloud Formation, I was told that could help on this.