I’m trying to use the `getOutput` method to get th...
# general
i
I’m trying to use the
getOutput
method to get the values of slice from another stack. I get this error
error: TypeError: subnetIds is not iterable
. But my outputs from the other stack looks like this:
Copy code
▶ pulumi stack output
warning: A new version of Pulumi is available. To upgrade from version '0.0.0' to '0.16.11', visit <https://pulumi.io/install> for manual instructions and release notes.
Current stack outputs (3):
    OUTPUT     VALUE
    subnetIds  ["subnet-0b7bf0c5d120c55d6","subnet-09f0c4ca405279bfc","subnet-0db5a0bc978a313a6"]
I can get single values without problems (i.e. not lists). Does someone have an example of using
getOutput
on a list?
c
@white-balloon-205 We are blocked on this.
Any help would be appreciated.
w
I have a stack deployed with a stack output
x
whose value is:
Copy code
{
  "active": true,
  "nums": [
    1,
    2,
    3
  ]
}
The following program:
Copy code
const s = new pulumi.StackReference("other", {
    name: "bucketlistobjects",
});
const o = s.getOutput("x");
o.apply(x => console.log(x.nums[1]));
Prints
2
as expected.
In your case, I'm not clear on where you are getting the
error: TypeError: subnetIds is not iterable
error. Which line of code is reporting that?
i
Thanks @white-balloon-205 turns out the issue was on my side - I forgot to change the name of the stack I was referencing. The example of using a
console.log
inside an
apply
really helped me debug it 👍
c
@white-balloon-205 Thank you!