Hello. Brand new to Pulumi as of yesterday. I'm tr...
# python
c
Hello. Brand new to Pulumi as of yesterday. I'm trying it out with Python since the Golang support hasn't fully landed yet. Is there a way I can get the value of an Output as a Python primitive? I'm trying to pass one to
base64.b64encode
and it's not working since it's a
pulumi.Output
and not a bytes-like object.
I trying casting it to a string with
str()
and that didn't work.
I also couldn't drop into a pdb debugger to inspect the thing. 😕
n
This is on a single Stack or are you referencing from another Stack?
If it's within a single Stack you need to use the
.apply()
function on the
pulumi.Output
object. For example:
bastion_ip = bastion.private_ip.apply(lambda foo: '%s/32' % foo)
c
Thanks, that worked right away.
The docs suggest that the output of
apply
is another
Output
, which is why I hadn't tried it yet: https://www.pulumi.com/docs/intro/concepts/programming-model/#outputs
The result of the call to apply is a new Output whose value is the value returned from the callback, and which includes the dependencies of the original Output.
n
Yeah, it is not terribly intuitive, but it's an almost direct port from JavaScript
You need to use the Lambda as a callback function in order to access the data you want