https://pulumi.com logo
Title
b

bright-truck-37455

06/28/2021, 10:53 AM
Hey, what is the proper way of getting keys from StackReference output which is an object? In my source stack I have
export const dbConfig = config.requireSecretObject<Config>("dbConfig");
And in the "destination" stack
const dbConfig = remoteStack.getOutput("dbConfig");
When I'm using dbConfig var in the 2nd stack it evaluates to the Object I need, however, when I'm trying to get specfic keys, like dbConfig["host"], I get an error saying there is no such property on that Object. P.S. TypeScript is not my main programming language, please don't go hard on me 🙂
b

better-shampoo-48884

06/28/2021, 10:59 AM
that's pretty much what i've done..
but I'm typing the output from the first stack and using that type to ensure I'm interpreting the stack reference correctly
const refStack = new pulumi.StackReference(`${referenceStackName}-reference`, {name: referenceStackName});
    
    refStack.getOutput("stackInfo").apply(async (infra:FullStackOutput) => {
        const regions = Object.keys(infra);
        let providers: ProviderObject = {}
        let primaryVault: VaultParam = {
            resourceGroupName: "",
            vaultName: ""
could also be that you need to wrap it to get the details 😉
b

bright-truck-37455

06/28/2021, 11:01 AM
@better-shampoo-48884 wow, thanks, let me try 🙂
b

better-shampoo-48884

06/28/2021, 11:01 AM
i.e.
.getOutput("dbConfig").apply(dbconf => {
b

billowy-army-68599

06/28/2021, 11:06 AM
thanks for the quick reply Johannes! he's absolutely right, you'll need to use
apply
to retrieve the keys