This message was deleted.
# general
s
This message was deleted.
l
You don't. Input<string> means "string isn't yet available, come back when it is".
You can
apply()
the Input, which will call its callback with the resulting string, when it is available.
v
Another question i have about this. how do i run for loop for example when the data is available? .apply(x => { for (let i = 0; i < x; i++) { // create database instance } })
l
In my opinion, generally: don't. If you don't know how many of a thing to create until after some other thing is created, then it's worth revisiting your design. If you are getting a count from a stack reference or config value, then also revisit. Just because you know you can loop 4 times doesn't mean it's the right thing to do. Calling the function 4 times in a row is sometimes better, and doubly-so for infrastructure.
An additional consideration is: don't create any resources inside an apply. This makes the preview and up actions disagree with each other, since the apply isn't run during a preview. It's the cause of many questions here.
v
Thank you for clearing thing up 🙂
if i am reading from config. how do i set default value?
l
You can call config.get() and if it's undefined, use the default.
👍 1