``` if "foo" in outputs: TypeError: arg...
# general
l
Copy code
if "foo" in outputs:
    TypeError: argument of type 'Output' is not iterable
b
you are running into the async nature of outputs. Outputs aren't iterable because they haven't resolved yet. You need to do the check inside an `apply`:
Copy code
stack_reference.output.apply(lambda: i if i // do something
l
Ok thanks, can i not extract the list of outputs that are currently there ?
b
can you elaborate what you mean by extract?
l
sure, so this works:
Copy code
outputs = stack_reference.outputs.apply(lambda outputs: [output for output in outputs])
pulumi.export("outputs", outputs)
it displays the list of output keys
I would now like to check, if a key exists in this list.
like would this work ?
Copy code
def stack_contains_output(stack_reference, output_name):
    return outputs.apply(lambda outputs: True if output_name in outputs else False)
b
yes basically, if you're inside the
apply
you can treat the object like a standard object because it's now resolved, so you can check however you'd like
l
Oh nice, yeh it works! thank you!
b
this might help with some additional context: https://leebriggs.co.uk/blog/2021/05/09/pulumi-apply
l
thanks!