https://pulumi.com logo
#general
Title
# general
h

helpful-continent-74245

11/13/2018, 4:28 AM
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

white-balloon-205

11/13/2018, 4:36 AM
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

helpful-continent-74245

11/13/2018, 4:36 AM
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

white-balloon-205

11/13/2018, 4:43 AM
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

helpful-continent-74245

11/13/2018, 4:44 AM
ok ! I have everything I need now !
Thanks you very much !