# automation-api


10/18/2023, 3:55 PM
I'm attempting to use stack references in an inline program, whilst using the Automation API to deploy the stack but I'm coming across this error*.* I was able to reference the stack via the Automation API via retrieving a remote workspace and calling
then passing those to the config of the inline program, but I'd like to clean things up and make the inline program re-useable with the CLI should I need direct pulumi CLI access. Any ideas what the error might be?


10/18/2023, 7:36 PM
I use stack refs with automation-api, not inline. What do you mean by retrieving a remote workspace? In stack B when I want to reference stack A I create a StackReference so not really using any automation-api constructs.


10/19/2023, 7:57 AM
Yeah that's exactly what I'm doing, but no bueno 😞 Initially, I was using the automation API to retrieve the remote (git) workspace and use the outputs from that for the inline program, but I've changed to using the
class (C#)
FYI I've raised an issue for this as I've been able to replicate it with a very basic Pulumi program:


10/20/2023, 4:34 AM
Most likely this error means that your automation api program captures a resource from program A in a variable, a map, or a class, and then when you try to run an and update on stack B and reference that resource, you get an error because it is not from the current operation and thus the current pulumi state knows nothing about it.
Saving resources in variables or data structures and trying to reference them across different updates will cause problems.