https://pulumi.com logo
Title
l

late-shampoo-62908

05/03/2021, 5:07 PM
Hey guys. Really stupid questions that its getting me crazy. Looked over the whole documentation, but didn't find how to do it. And even in some previous messages the same question was asked, but without getting clear how to solve it... I exported a specific output in some part of my stack, like:
pulumi.export("network.vpc.id",vpc.id)
How do i, in a separate part of the same stack can retrieve that exported property? All within the same stack. I've tried with StackReference, but since i'm within the same stack i want to reference i got a "resource registered twice" error msg
w

witty-candle-66007

05/03/2021, 5:45 PM
If I understand your question, to reference a value in the same stack you can just use the value you have in the export -
vpc.id
l

late-shampoo-62908

05/03/2021, 6:00 PM
Thanks Mitch for the answer. That value is of course lost, so that vpc.id cannot be accessed. I think the a way to solve it could be: having a state object as someone suggested in some previous chats, where i store the name of the property soon to be exported, and its value as the Output promise object; so if that output its still a promise it could be reference still in some other place
b

boundless-angle-56560

05/03/2021, 7:44 PM
@late-shampoo-62908 the real value of the vpc.id is only known after pulumi starts walking down the dependency tree and executing stuff on the cloud. If you want to use that value (the real value) somewhere in the stack, you will have to use the apply callback. This way you are able to inject your code that will be able to use that value anywhere in the stack
w

witty-candle-66007

05/03/2021, 9:18 PM
As per @boundless-angle-56560 this doc page explains how to access that value as part of your stack: https://www.pulumi.com/docs/intro/concepts/inputs-outputs/