https://pulumi.com logo
m

modern-eve-91943

06/30/2023, 2:20 PM
This message contains interactive elements.
b

billowy-army-68599

06/30/2023, 3:53 PM
can you share your code?
m

modern-eve-91943

06/30/2023, 4:08 PM
I have 2 services, let's say
one
and
two
In service
two
ts file I use the following code to reference service `one`:
Copy code
import { OneService } from "../../shared/infra/outputs";
import * as pulumi from "@pulumi/pulumi";

const oneStack = new pulumi.StackReference(`company/two/${config.environment}`); //this line throws the error
const oneStackService = oneStack.getOutput("oneService").apply(s => s as OneService);

... //use extracted value to save in app settings of service two
Service
two
doesn't have any stack references at all. If I use the same code in another service, e.g. service
three
, it works fine
b

billowy-army-68599

06/30/2023, 4:13 PM
does
import { OneService}
include a stack reference?
m

modern-eve-91943

06/30/2023, 4:47 PM
it doesn't
../../shared/infra/outputs
is a file with interfaces
a

acceptable-intern-25844

06/30/2023, 5:12 PM
just create a wrapper function to get outputs from stack by stack name and output name. then memoize the
new StackReference
also instead of
oneStack.getOutput("oneService").apply(s => s as OneService);
use
StackReference.getOutputDetails
m

modern-eve-91943

07/03/2023, 9:51 AM
thank you for the answer
2 Views