lambda-event-parse
v1.1.1
Published
A parse tool that helps you easily consume any AWS resource event triggering your AWS Lambda.
Downloads
5
Readme
Lambda Event Parser
A simple parse tool to just parses the events triggering your AWS Lambda into a common format, so you don't have to worry.
The standardized event format
{
sourceType: 'api',
sourceEvent: originalEvent,
records: [{
userId: 123
}] // array of events (with parameters as properties)
}
How does it work
API Gateway GET Request Event:
?userId=456&name=someoneUnknown
{
httpMethod: 'GET',
queryStringParameters: {
userId: 456,
name: 'someoneUnknown'
}
}
}
will be translated into ->
{
sourceType: 'api',
sourceEvent: originalEvent, // the complete, unchanged GET request event objet
records: [{
userId: 123,
name: 'someoneUnknown'
}] // array of events (with parameters as properties)
}
Let's take another example, an S3 Event:
S3 Event:
{
Records: [
{
s3: {
object: {
key: "HappyFace.jpg",
size: 1024
}
}
}
]
}
will be translated into:
{
sourceType: 's3',
sourceEvent: originalEvent, // the complete, unchanged S3 event objet
records: [{
key: "HappyFace.jpg",
size: 1024
}] // array of events (with parameters as properties)
}
SNS Event:
{
"Records": [
{
"eventID": "7de3041dd709b024af6f29e4fa13d34c",
"eventName": "INSERT",
"eventVersion": "1.1",
"eventSource": "aws:dynamodb",
"awsRegion": "us-west-2",
"dynamodb": {
"ApproximateCreationDateTime": 1479499740,
"Keys": {
"Timestamp": {
"S": "2016-11-18:12:09:36"
},
"Username": {
"S": "John Doe"
}
},
"NewImage": {
"Timestamp": {
"S": "2016-11-18:12:09:36"
},
"Message": {
"S": "This is a bark from the Woofer social network"
},
"Username": {
"S": "John Doe"
}
},
"SequenceNumber": "13021600000000001596893679",
"SizeBytes": 112,
"StreamViewType": "NEW_IMAGE"
},
"eventSourceARN": "arn:aws:dynamodb:us-east-1:123456789012:table/BarkTable/stream/2016-11-16T20:42:48.104"
}
]
}
will be translated into:
{
sourceType: 's3',
sourceEvent: originalEvent, // the complete, unchanged S3 event objet
records: [{
key: "HappyFace.jpg",
size: 1024
}] // array of events (with parameters as properties)
}
Supported AWS Events (so far)
- [x] SNS
- [x] S3
- [x] API Gateway (GET, POST, PUT, DELETE, PATCH)
- [x] DynamoDB Streams (NEW_IMAGE)
- [ ] SQS
- [ ] Other AWS Lambda
- [ ] CloudWatch
- [ ] Kinesis DataFirehose
- [ ] Kinesis Data Streams
- [ ] SES
License
MIT
Aleksandar Simovic