Last active
October 15, 2019 17:18
-
-
Save amcginlay/eeebef2eff3105d69f880b746a42a1b3 to your computer and use it in GitHub Desktop.
Kinesis Firehose demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# assumes a kinesis firehose delivery system is in place (e.g. demo-firehose-stream) | |
# NodeJS Lambda function to append CRs as follows with a timeout > 1 min | |
# Configure this to deposit results in S3 | |
console.log('Loading function'); | |
exports.handler = async (event, context) => { | |
/* Process the list of records and transform them */ | |
const output = event.records.map((record) => { | |
let entry = (new Buffer(record.data, 'base64')).toString('utf8'); | |
let result = entry + '\n'; | |
const payload = (new Buffer(result, 'utf8')).toString('base64'); | |
return { | |
recordId: record.recordId, | |
result: 'Ok', | |
data: payload | |
} | |
}); | |
console.log(`Processing completed. Successful records ${output.length}.`); | |
return { records: output }; | |
}; | |
# Use the following CLI commands to put records into the firehose | |
aws firehose put-record --delivery-stream-name demo-forehose-stream --record Data=100 | |
aws firehose put-record --delivery-stream-name demo-forehose-stream --record Data=101 | |
aws firehose put-record --delivery-stream-name demo-forehose-stream --record Data=102 | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment