having a hard time figuring out why I can't retrie...
# getting-started
l
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
Are you using a
StackReference
to read the outputs or are you using
automation
API code?
l
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}`)});
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
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
Are you doing this during a preview? The results of outputs are undefined at that time.