https://pulumi.com logo
#python
Title
# python
b

bland-lamp-16797

05/11/2020, 2:02 PM
I think get_output is little misleading here. I'm getting Output class even if I put fake name output. I'm still figuring out why I can't print output from another stack 😞
Copy code
deployment_stack = StackReference('infra.deploy')

b81_zone_id = deployment_stack.get_output('THISDOESNOTEXIST_RETURNS_OUTPUT')
I just wonder, why
print(b81_zone_id.apply(lambda c: print(c)))
does not work but when I export it in
pulumi.export
, it works... A know async and apply, but why
apply()
did not work on my output?
n

nutritious-shampoo-16116

05/11/2020, 3:20 PM
weird, the syntax looks okay
maybe it doesn't work cause it doesn't exist and it waits forever for that value to be populated?
b

bland-lamp-16797

05/11/2020, 3:22 PM
I tried... both, with existing and non-existing. the print with lambda(print) is always Output class
n

nutritious-shampoo-16116

05/11/2020, 3:23 PM
what if you print just at the end? without printing within the lambda? print(b81_zone_id.apply(lambda c: c))
you can try this one: def p(x): print(x) deployment_stack.get_output('FOO').apply(lambda c: p(c))
I think the outer print messes things here
w

white-balloon-205

05/11/2020, 3:31 PM
@bland-lamp-16797 could you share a complete snippet of what code you are using that is behaving in an unexpected way? I’d like to try to reproduce what you are seeing.
b

bland-lamp-16797

05/11/2020, 3:35 PM
Copy code
deployment_stack = StackReference('infra.deploy')

example1 = deployment_stack.get_output('b81_zone_name')  # this exist
example2 = deployment_stack.get_output('thisdoesnotexist')

print(example1.apply(lambda c:print(c)))
print(example2.apply(lambda c:print(c)))

pulumi.export('example1', example1)  #returns real value
pulumi.export('example2', example2)  #returns None
the outputs of this is:
Copy code
<pulumi.output.Output object at 0x10e9f2110>
    <pulumi.output.Output object at 0x10e9f2390>
    my_value_from_infra.deploy
    None
The comment code is correct... it returns None indeed but when I try to debug, I can't trust print 😞
I know it's pipe dream, but if I could put here
ipython.embed()
and debug from ipython, it would make my life easier
@nutritious-shampoo-16116 I tried also like a function... it didn't work
s

sparse-state-34229

05/11/2020, 4:52 PM
seems like it would be really helpful to have a bunch of example uses of handling outputs
πŸ‘ 1
b

bland-lamp-16797

05/12/2020, 8:13 AM
it seems this is a bug... even when I run
pulumi_gcp.dns.RecordSet("develop." + example1)
I get string of output object... This what runs in GCP API:
Error creating DNS RecordSet: googleapi: Error 400: Invalid value for 'entity.change.additions[0].name': 'develop.<pulumi.output.Output object at 0x10914aed0>', invalid
ok, I'm using Output.all and it works... but this starlark is not easier then any Declarative languages around... 😞
s

sparse-state-34229

05/12/2020, 5:35 PM
yeah, it’s not obvious