re: above thread, something I've been trying to wo...
# python
a
re: above thread, something I've been trying to work my head around today is passing outputs into a jinja2 template
1
r
You will need to do that within the apply!
👀 1
If you have some example code I can maybe help point you in the right direction
a
I'm all set now, I was struggling originally because I was trying to do something like:
Copy code
test = '''{{ some_value }}'''
jinja2.Template(test).render(
  some_value = pulumi_output.apply(lambda x: f"{x}"
))
and similar incantations, which was not working adjusting to treat the apply as the entrypoint e.g.
Copy code
test = '''{{ some_value }}'''
pulumi_output.apply(
  lambda x: jinja2.Template(test).render(some_value=x))
works just fine 🙂
🎉 1
partypus 8bit 1
b
hey Rob, is there any reason you don't want to use
apply
as the entrypoint? you have to do it that way, because
apply
basically means "wait for this value to resolve, then do something"
a
no reason I was just misunderstanding how it worked
mentally it was just like: 1. I put
some_value=pulumi_output
into the render call and my resulting string has the
__repr__
value in it 2. Ok, I'll swap that to
pulumi_output.apply()
,
.concat()
, etc., trying to find one that works 3. Try to search examples repository, don't find anything great immediately, post in slack 🙂
My normal approach to this is to drop into a pdb session and start calling things interactively, but the Output objects are weird in that they just return other Output objects? I couldn't find a place to start debugging at where I could actually resolve them
b
a
will do thanks!
believe it or not I have no problem with promise.then(), for whatever reason the pulumi grammar just breaks my brain 🙂
g
Not only yours mate 🙂 I usually have the same approach when I'm learning a new tool. Just drop into the debugger and see what I can touch. I suspect this happens because Pulumi promises that you can use the language of your choice but after that, you discover that you may be writing the language but Pulumi dictates how you write it. I find it difficult to adjust as well. I also believe if this can be fixed it will unleash the true potential Pulumi has. However it will probably take some time