https://pulumi.com logo
#dotnet
Title
# dotnet
p

powerful-football-81694

06/14/2021, 7:44 PM
Hi folks! What’s the right way to programmatically get an output value out of a stack from C#, outside the context of Pulumi? I mean, basically what’s the C# equivalent of doing:
pulumi stack output SomeOutput --stack DaRosenberg/OrgFlow/stackName
I’ve tried referencing the
Pulumi
package and using a
StackReference.GetValueAsync()
call, but that only gives me:
System.InvalidOperationException : Trying to acquire Deployment.Instance before 'Run' was called.
What’s the right way? Do I need to use the Automation API for things like this?
b

brave-planet-10645

06/14/2021, 8:22 PM
Yes, automation API is the way to do this
p

powerful-football-81694

06/14/2021, 8:22 PM
I suspected as much…
Any starting pointers?
Think I figured it out by trial and error. This actually seems to work:
The somewhat surprising part is that passing
null
for the
program
parameter actually seems to work.
b

bored-oyster-3147

06/15/2021, 12:38 PM
That's because you're passing
null
to setup the workspace not to setup a specific update action. This is so that you can do subsequent update actions without needing to pass your program everytime. If you were to try to execute an inline update action (preview or up) than I suspect you'd see issues.
The "correct" way to do this since you are not executing any update action and you are just looking to do stack manipulation would be to create your workspace first, and then select the stack from the workspace. Than you wouldn't need to abuse
null!
Ofc your way will work for now
p

powerful-football-81694

06/15/2021, 5:32 PM
Ah, got it @bored-oyster-3147 ! Thanks! 😃
2 Views