having a hard time figuring out why I can't retrieve a stacks output value in a custom script (purely for the sake of demonstrating how to read stack outputs)
using
pulumi stack output
in cli, I get the expected result (img attached)
using the ts sdk however, pulumi fails to do so and returns
undefined
. not clear on what I'm missing. Some examples below
• stack.getOutputValue("bucketConfig");
• stack.getOutputValue('bucketConfig').then(val=> console.log(val));
• stack.outputs.apply(bucketConfig=> {console.log(bucketConfig)});
whereas I can successfully print the name of my stack using:
stack.name.apply(_name_
_=>_ { console.log("name is ${_name_}")});
c
clever-sunset-76585
09/27/2024, 12:53 PM
Are you using a
StackReference
to read the outputs or are you using
automation
API code?
l
lively-engine-75588
09/29/2024, 11:13 AM
yeah StackReference
_const_ stack = new pulumi.StackReference('account/project/stack')
I can successfully read the
id
and
name
in my script using the below
Copy code
stack.name.apply(name => { console.log(`name is ${name}`)});
stack.id.apply(id => { console.log(`id is ${id}`)});
lively-engine-75588
09/29/2024, 11:14 AM
however when reading the
outputs
, they remain undefined, which could also mean it's not reaching the correct
stack
. Is there any other method I could use to validate the pulumi instance is indeed my targeted stack?
c
clever-sunset-76585
09/29/2024, 3:26 PM
You should run
pulumi stack ls
and check what stacks you have and if the intended stack (the one with the outputs) is in the correct account, as well as if the stack that you are reading from is in the same account as the source stack.
l
little-cartoon-10569
09/29/2024, 7:21 PM
Are you doing this during a preview? The results of outputs are undefined at that time.
No matter how you like to participate in developer communities, Pulumi wants to meet you there. If you want to meet other Pulumi users to share use-cases and best practices, contribute code or documentation, see us at an event, or just tell a story about something cool you did with Pulumi, you are part of our community.