Hi all. I am relatively new in SST. I have some situation. In my Stack constructor needs to execute some async functions. For example, I am working with MediaConvert and first I need to get media convert api endpoint. That function is promise and I need to use AWAIT in constructor to wait while info is get from the API. Of course Stack constructor cannot be async so I cannot use await.
Is there any approach for this. That is not the only function where I need to use await. The only thing that come up in my mind that I will need to put all in .then(..... and have lot of nested functions on that way, which looks ugly to me. Is there any better solution. Maybe I am missing something
t
thdxr
02/28/2022, 1:00 AM
You can put async code in your main function and pass it into the stack constructor as an argument
thdxr
02/28/2022, 1:00 AM
we are considering reworking how stack definitions work to allow async code
Thank you so much. That is exactly what I needed. I have a few really complex stacks, so my main function become flooded. However, I sorted everything inside separate files, and looks amazing. And working as expected finally 🙂