Skip to content
This repository has been archived by the owner on Nov 20, 2021. It is now read-only.

Add S3 trigger to publish lambda #17

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eventbrite/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const eventsParams = page =>
module.exports = {
buckets: () => ({
producerBucket: "muxer-produced-events-eventbrite",
eventsBucket: "muxer-transformed-events"
eventsBucket: "muxer-events"
}),
getEventsUrl: ({ page }) => `${eventsApi}?${eventsParams(page)}`
};
2 changes: 1 addition & 1 deletion farsetlabs/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const eventsParams = () =>
module.exports = {
buckets: () => ({
producerBucket: "muxer-produced-events-farsetlabs",
eventsBucket: "muxer-transformed-events"
eventsBucket: "muxer-events"
}),
getEventsUrl: () => `${eventsApi}?${eventsParams()}`
};
3 changes: 3 additions & 0 deletions farsetlabs/handlers/transformer.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ const transformEvent = function(
city: "Belfast",
country: "GB"
},
charge: {
is_free: true
},
created_at: new Date(created).toISOString(),
last_updated: new Date(updated).toISOString(),
source_data: {
Expand Down
2 changes: 1 addition & 1 deletion meetupcom/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const eventsParams = convert({
module.exports = {
buckets: () => ({
producerBucket: "muxer-produced-events-meetupcom",
eventsBucket: "muxer-transformed-events"
eventsBucket: "muxer-events"
}),
getGroupsUrl: () => `${groupsApi}?${groupsParams}`,
getEventsUrl: slug => `${eventsApi(slug)}?${eventsParams}`
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
"farsetlabs:transformer:invoke": "cd farsetlabs && serverless invoke -f transform -l --aws-profile muxer",
"farsetlabs:transformer:invoke-local": "cd farsetlabs && serverless invoke local -f transform",
"farsetlabs:transformer:logs": "cd farsetlabs && serverless logs -f transform -l --aws-profile muxer",
"publisher:deploy": "cd publisher && serverless deploy -v --aws-profile muxer",
"publisher:s3deploy": "cd publisher && sls s3deploy --aws-profile=muxer",
"publisher:publish:update": "cd publisher && serverless deploy function -f publish --aws-profile muxer",
"publisher:publish:invoke": "cd publisher && serverless invoke -f publish -l --aws-profile muxer",
"publisher:publish:invoke-local": "cd publisher && serverless invoke local -f publish",
Expand Down
2 changes: 1 addition & 1 deletion publisher/config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
buckets: () => ({
eventsBucket: "muxer-transformed-events"
eventsBucket: "muxer-events"
}),
muxerEventsApi: process.env.MUXER_EVENTS_API
};
115 changes: 60 additions & 55 deletions publisher/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion publisher/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"@muxer/event-schema": "1.0.0",
"aws-lambda-data-utils": "1.0.0",
"jsonschema": "1.2.4",
"request": "2.88.0"
"request": "2.88.0",
"serverless-plugin-existing-s3": "^2.3.0"
}
}
29 changes: 11 additions & 18 deletions publisher/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,20 @@ functions:
handler: handlers/publisher.publish
environment:
TZ: Europe/Belfast
events:
- existingS3:
bucket: ${self:custom.eventsBucket}
events:
- s3:ObjectCreated:*


resources:
Resources:
S3BucketMuxerTransformedEvents:
DependsOn:
- TransformLambdaPermissionS3BucketMuxerTransformedEventsS3
MuxerTransformedEventsS3Bucket:
Type: AWS::S3::Bucket
Properties:
BucketName: ${self:custom.eventsBucket}
NotificationConfiguration:
LambdaConfigurations:
- Event: "s3:ObjectCreated:*"
Function:
"Fn::GetAtt": [ TransformLambdaFunction, Arn ]
TransformLambdaPermissionS3BucketMuxerTransformedEventsS3:
DependsOn:
- TransformLambdaFunction
Type: AWS::Lambda::Permission
Properties:
FunctionName:
"Fn::GetAtt": [ TransformLambdaFunction, Arn ]
Action: "lambda:InvokeFunction"
Principal: "s3.amazonaws.com"
SourceArn: "arn:aws:s3:::${self:custom.eventsBucket}"


plugins:
- serverless-plugin-existing-s3
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`Eventbrite transformer when a new file is added to the bucket which contains complete events uploads transformed events list 1`] = `
Array [
Array [
"muxer-transformed-events",
"muxer-events",
[Function],
Array [
Object {
Expand Down Expand Up @@ -387,7 +387,7 @@ Worst Case Scenario is the second show in the Zombie Science spoof lecture serie
exports[`Eventbrite transformer when a new file is added to the bucket which contains incomplete events uploads transformed events list, without incomplete events 1`] = `
Array [
Array [
"muxer-transformed-events",
"muxer-events",
[Function],
Array [
Object {
Expand Down Expand Up @@ -697,7 +697,7 @@ Worst Case Scenario is the second show in the Zombie Science spoof lecture serie
exports[`Eventbrite transformer when multiple new files are added to the bucket uploads transformed events lists 1`] = `
Array [
Array [
"muxer-transformed-events",
"muxer-events",
[Function],
Array [
Object {
Expand Down Expand Up @@ -1076,7 +1076,7 @@ Worst Case Scenario is the second show in the Zombie Science spoof lecture serie
],
],
Array [
"muxer-transformed-events",
"muxer-events",
[Function],
Array [
Object {
Expand Down
2 changes: 1 addition & 1 deletion tests/eventbrite/handlers/tranformer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe("Eventbrite transformer", function() {
transformer.transform(event, context, function() {
expect(uploadTo).toHaveBeenCalledTimes(1);
expect(uploadTo).toHaveBeenCalledWith(
"muxer-transformed-events",
"muxer-events",
expect.any(Function),
[]
);
Expand Down
Loading