Hi folks! What’s the right way to programmatically...
# dotnet
p
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
Yes, automation API is the way to do this
p
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
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
Ah, got it @bored-oyster-3147 ! Thanks! 😃