https://pulumi.com logo
#automation-api
Title
# automation-api
h

hallowed-ice-8403

07/12/2021, 2:29 PM
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

bored-activity-40468

07/12/2021, 8:36 PM
Is that stack name correct? Usually its something like, "myorg/projectname/test"
h

hallowed-ice-8403

07/13/2021, 4:31 AM
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

bored-activity-40468

07/13/2021, 1:09 PM
Ah, interesting.
e

early-keyboard-41388

10/18/2021, 6:55 PM
@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

bored-activity-40468

10/18/2021, 8:21 PM
@early-keyboard-41388 Did you try, org/projectname/stackname ?
e

early-keyboard-41388

10/19/2021, 5:33 AM
@bored-activity-40468 Thanks for the reply. How/Where do I get the org name?
b

bored-activity-40468

10/19/2021, 12:52 PM
When you're in the console, if there's more than 1, like your username or an org your a member of,
h

hallowed-ice-8403

10/20/2021, 4:35 AM
@early-keyboard-41388 can u try without the project name.. This worked for me,
Copy code
reference = StackReference(mystack)
e

early-keyboard-41388

10/20/2021, 5:42 AM
@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.