aws-lambda-data-utils
Common data utils for pulling and pushing data in AWS lambdas
Dependencies
These tools use only node native modules, and the aws-sdk
which is
pre-installed on AWS lambda.
Common Functions
create-hash
Uses the node crypto
library to creaate a SHA-256 hash of a value. Useful for
adding to file names to check for duplicate content.
const createHash = ;; // b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9
get-date-path-for
Creates string path of year / month / day, with prefixed 0
, for the provided
date.
const getDatePathFor = ;; // 2017/06/03
get-date-time-path-for
Creates string path of year / month / day / hour / minute, with prefixed 0
,
for the provided date.
const getDateTimePathFor = ;; // 2017/06/03/15/05
get-from-s3
Gets a file from a specific S3 bucket. Takes bucket name and file path.
const getFromS3 = ;; // returns promise
get-from-web
Get data from a remote HTTPS URL (Note: only works with HTTPS!)
const getFromWeb = ;; // returns promise
get-list-from-s3
Gets a list of files present in a directory of a specific S3 bucket. Takes care of paginating through the list and returning a complete file list if there are more than 1000 files. Takes bucket name and file path.
const getListFromS3 = ;; // returns promise
set-in-s3
Writes a file to S3. Takes searchable prefix, bucket name, file path and file contents.
const setInS3 = ;; // returns promise