How to use Async/Await in NodeJS to save time in Lambda

preview_player
Показать описание
Use async/await to save time in your Lambda functions. Got an AWS question for James? Tweet me @jbesw.
Рекомендации по теме
Комментарии
Автор

Nice video, minor gripe: the resources should be in the description box as links for easy access. Have a nice day!

maijuk
Автор

Could you explain why you are `await`ing each of the mapped records? I thought `await Promise.all()` would already await the entire array of promises.

```
await Promise.all(
event.Records.map(async (record) => {
await processRecord(record) // why await here?
})
)
```
I thought it should be
```
```
await Promise.all(
event.Records.map(async (record) => {
processRecord(record) // no await here
})
)
```
```

laffytaffykidd
Автор

If process has the side-effect of adding a file to S3, would it be less costly to instead publish to an SNS topic that did the same thing? I imagine this lambda’s duration would be less but is that time then added to that subscriber lambda that generates the file in S3? To be short, is it cheaper to do all the processing in this single process or split up each iteration (each promise) to a separate lambda?

rickyisajedi