Stripped down example: I have a list of bucket in ...
# general
h
Stripped down example: I have a list of bucket in
buckets
variables, and I want to generate the string:
["arn:aws:s3:::${bucket1.id}", "arn:aws:s3:::${bucket2.id}",...]
w
I believe this should work.
Copy code
pulumi.all(buckets.map(b => b.id.apply(id => `arn:aws:s3:::${id}`)))
The upside is that there is ultimately a lot of flexibility, but you are right that these cases can be subtle. We’re looking into a few ways to simplify many common cases further here.
h
Ha ! I didn't know about
pulumi.all
!
Yes I definitely think some helpers would be useful for typical case like JSON string formatting
For your answer, it will return a list of strings, but I want the full things to be JSON stringify in fact. How can create a generic Pulumi.Output that launch a function of my own upon resolution
?
This
Pulumi.Output
are like promises to be resolved at execution
(I mean execution of the resource deployent)
w
Yes -
Output
is effectively a promise (it is actually a promise along with resource dependency information). Re: launch a function of your own - you can use
.apply(JSON.stringify)
off the previous answer to compute a
Output<string>
.
h
ok ! I have everything I need now !
Thanks you very much !