https://pulumi.com logo
c

clean-eve-27532

04/01/2020, 8:15 AM
Can't tell if I'm being silly but is there anyway to iterate a pulumi.Output<string[]> and create resources using each iterated value?
s

stocky-island-3676

04/01/2020, 8:19 AM
@clean-eve-27532 You can access the inner string-array with
.apply()
(see doc). Then I think it’s obvious, or?
c

clean-eve-27532

04/01/2020, 8:21 AM
Yeah I thought about that but I thought creating resources in .apply() was a bad practice
Every other type gets lifted fine but string[] doesnt seem to lift correctly 😕
Copy code
Type 'Output<string[]>' must have a '[Symbol.iterator]()' method that returns an iterator
s

stocky-island-3676

04/01/2020, 8:27 AM
I thought creating resources in .apply() was a bad practice
Good point. I think it should work to just return the string-array inside the
apply()
and save it in a variable. Then you could iterate on this afterwards. Hmm, but then it doesn’t work on preview-time, AFAIU.
c

clean-eve-27532

04/01/2020, 8:30 AM
Yeah that's my backup plan but just feels like I'm misusing the type, might try a different approach. Thanks for your help 👍
s

stocky-island-3676

04/01/2020, 8:34 AM
You’re welcome 🙂