full-artist-27215
05/13/2021, 9:37 PMrole.arn.apply(lambda arn: json.dumps({"foo": arn}))
When you have multiple things that need to be interpolated, things get a little more complicated:
pulumi.Output.all(
foo.arn,
bar.arn,
baz.arn
).apply(
lambda args: json.dumps({
"foo": args[0],
"bar": args[1],
"baz": args[2]
})
)
While that's awkward, it's doable when you have all the `pulumi.Output`s that you need readily at hand.
I'm using `ComponentResource`s to model my domain. In general, I'd like to be able to pass a dictionary of values into my ComponentResource
, and then have it merge that with another dictionary of default values within the ComponentResource
itself. Then, this merged dictionary would need to be converted into a JSON string to pass to the low-level Resource.
env = {
"foo": "my_foo",
"message": "hello world"
}
pulumi.Output.all(
foo.arn,
bar.arn,
baz.arn
).apply(
lambda args: json.dumps({
"foo": args[0],
"bar": args[1],
"baz": args[2],
**env
})
)
If that inner "default values" dictionary is the one that contains the pulumi.Output
values, then I can control things with pulumi.Output.all
, as shown above. If I've got pulumi.Output
values in that dictionary that I'm merging in, though, it's not clear how I can generically manage things.
I'm curious if others have run into similar situations, or if people have some patterns for managing such data (generic, if possible; Python-specific works too). Thanks in advance.little-cartoon-10569
05/13/2021, 9:45 PMfull-artist-27215
05/13/2021, 10:29 PMred-match-15116
05/13/2021, 10:34 PMOutput.all
makes a difference.
If I’ve gotvalues in that dictionary that I’m merging in, though, it’s not clear how I can generically manage things.pulumi.Output
Output.all(**dict).apply(lambda args: json.dumps({**args, **env}))
full-artist-27215
05/14/2021, 1:18 PM