Hey all, how do you do async tasks for a stack?&gt...
# help
r
Hey all, how do you do async tasks for a stack?> For example its talked about here https://docs.serverless-stack.com/environment-variables#2-fetch-ssm-values-in-cdk-using-the-aws-sdk that you would go get SSM values at stack creation time. however this is in the stack constructor which is not async. What is the recommended way to deal with that?
f
Hey @Ross Gerbasi, I created a sample repo here that fetches SSM inside the index file - https://github.com/fwang/sst-load-ssm/blob/main/stacks/index.js
r
ah interesting so you would put stack creation in the callback. can
main
be async? is there a way we can do all this without callbacks?
a
You can .promise() the call and put the logic in a Promise.then() instead. Not any cleaner though.
r
It does seem to work with setting main to async then you can just use await
@Frank just to be sure i am not getting into any danger, async for main is fine? seems to be working great for us...
f
@Ross Gerbasi yeah I haven’t come across any issue w/ it.