This message was deleted.
# python
s
This message was deleted.
l
My first thought is to basically move the entire thing into a function that I call with apply… but the function doesn’t necessarily know where the Output objects are (as they could be inside dictionaries that are passed to that function), so there would be a lot of bookkeeping there.
Another thought was to create a new YAML Dumper, but the docs on that are pretty poor, so I’m not sure if that is the best option.
(this is also relevant when using Jinja templates)
b
you have to do it inside an
apply
if you have multiple output objects, use
output.all
what exactly are you dumping to YAML?
l
I’m trying to create a custom userdata file for use with cloudinit
Can I use
Output.format
?
It appears to be in the docs: https://www.pulumi.com/docs/reference/pkg/python/pulumi/#pulumi.Output.format … but I’m getting
AttributeError: type object 'Output' has no attribute 'format'
when I try and use it.
So, I ultimately ended up writing a function to replace everything in a container (dict/dataclass/list/etc) that is a Output object with a uid and then pass the container through the yaml/jinja templating process, and then use apply and .format to re-enter those items.
But this is really awkward.
Putting secrets or computed values into config files (like yaml or jinja templates) I would think is pretty fundamental… but right now it is pretty broken.
b
this is a really common practice, I’m not sure where you think it’s broken. here’s an example of interpolating an output inside a JSON string which should be applicable to your user case: https://github.com/jaxxstorm/pulumi-examples/blob/55a9c8e4c5a058f1a1017b4b74d1a5c26881aee6/python/aws/s3_bucket_cloudflare/__main__.py#L31-L72 We also have the cloudinit package: https://www.pulumi.com/registry/packages/cloudinit/ if you can share exactly what you’re trying to do, I can try repro on Monday
l
I’m sorry, I was wrong. I was just frustrated by the time I had spent on this whole process. Thanks for that link.