- Create the project from the following template:
$ sls create --template-url https://github.com/danteinc/js-cloud-native-cookbook/tree/master/ch7/event-metrics --path cncb-event-metrics
- Navigate to the cncb-event-metrics directory with cd cncb-event-metrics.
- Review the file named serverless.yml.
- Review the file named handler.js with the following content:
module.exports.listener = (event, context, cb) => { _(event.Records) .map(recordToUow) .tap(count) ... .collect().toCallback(cb);};const count = (uow) => { const tags = [ `account:${process.env.ACCOUNT_NAME}`, `region:${uow.record.awsRegion}`, `stream:${uow.record.eventSourceARN.split('/')[1]}`, `shard:${uow.record.eventID.split('-')[1].split(':')[0]}`, `source:${uow.event.tags ...