S3 Event Parser
![Coverage Status](https://coveralls.io/repos/github/digitregroup/s3-event-parser/badge.svg?branch=master)
Parse AWS S3/SNS events from your Lambda function.
Notes:
- This only work for single file S3 events. (One event per file).
- Work only in nodeJS v8.10 (because of JOI requirement)
Install
npm i @digitregroup/s3-event-parser
yarn add @digitregroup/s3-event-parser
Usage
In your handler:
const S3EventParser = require('@digitregroup/s3-event-parser')
module.exports.run = (event, context, callback) => {
const parsedS3Event = new S3EventParser(event).parse();
console.log(
parsedS3Event.filePath,
parsedS3Event.key,
parsedS3Event.filePrefix,
parsedS3Event.bucketName,
parsedS3Event.fileSize
parsedS3Event.rawS3Notification
);
};
In you serverless.yml
:
functions:
myFunction:
handler: src/handlers/index.run
events:
- sns:
arn: arn:aws:sns:eu-west-1:0000000000:my-topic
- s3:
bucket: photos
event: s3:ObjectCreated:*
- existingS3:
bucket: photos
event: s3:ObjectCreated:*
plugins:
- serverless-external-s3-event
Unit tests
This project aim to keep 100% code coverage. Tests are performed via Mocha/ChaiJS (Expect version).
yarn lint
Code style
This project should respect the linting configured in @digitregroup/eslint-config.
yarn lint
DevOps
CI pipelines are performed in CircleCI for every single push in any branch.
CI is composed of Linting and Unit Testing with coverage requirement (specified in package.json
)
CD pipeline is perfomed on git tag creation and release in NPM registry if the CI passed.
Note pipelines automaticaly check the package.json
's version to match with the git tag (or release/hotfix branch).
Contributing
PR are welcome! We use gitflow :)