-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ingestion): react to S3 events - EUBFR-20 (#5)
* feat(ingestion): react to S3 events - no issue * Separate storage and ingestion * Upgrade node-docker version (including Yarn v1.0.1) * Update docs and config * Publish message to SNS topic * Deploy first ETL * Make the region dynamic too * Make ETL great again * Add DB service * Avoid using the same port everywhere * Load the file and puts its content into the sns message * Parse CSV * One line -> one SMS message * Update dependencies * Update dependencies and remove serverless-offline * Don't embed aws-sdk (already provided) * Manually exclude externals
- Loading branch information
Showing
38 changed files
with
899 additions
and
675 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
.webpack | ||
node_modules | ||
*.log | ||
config.json |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
8 | ||
8.5 |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"region": "eu-central-1", | ||
"stage": "dev-username-uid" | ||
} |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"lerna": "2.1.2", | ||
"lerna": "2.2.0", | ||
"version": "0.0.1", | ||
"npmClient": "yarn", | ||
"useWorkspaces": true | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/sh | ||
|
||
# Exit the script on any command with non 0 return code | ||
set -e | ||
|
||
# Go to project root | ||
cd "$(dirname "$0")" | ||
cd .. | ||
|
||
# Deploy storage first | ||
cd ./services/storage | ||
./node_modules/.bin/serverless deploy -v | ||
|
||
# Go to project root | ||
cd ../.. | ||
|
||
# Deploy manager | ||
cd ./services/ingestion/manager | ||
./node_modules/.bin/serverless deploy -v | ||
|
||
# Go to project root | ||
cd ../../.. | ||
|
||
# Deploy ETL | ||
cd ./services/ingestion/etl/budg/csv | ||
./node_modules/.bin/serverless deploy -v | ||
|
||
# Go to project root | ||
cd ../../../../.. | ||
|
||
# Deploy DB service | ||
cd ./services/db | ||
./node_modules/.bin/serverless deploy -v |
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Ingestion DB |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"private": true, | ||
"name": "db", | ||
"version": "0.0.1", | ||
"scripts": { | ||
"deploy": "sls deploy -v", | ||
"test:unit": "jest --testPathPattern=unit" | ||
}, | ||
"devDependencies": { | ||
"babel-core": "6.26.0", | ||
"babel-loader": "7.1.2", | ||
"babel-plugin-transform-runtime": "6.23.0", | ||
"babel-preset-es2015": "6.24.1", | ||
"babel-preset-stage-3": "6.24.1", | ||
"jest": "21.1.0", | ||
"serverless": "1.22.0", | ||
"serverless-webpack": "3.0.0", | ||
"webpack": "3.6.0" | ||
}, | ||
"dependencies": { | ||
"aws-sdk": "2.117.0", | ||
"babel-runtime": "6.26.0" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
service: db | ||
|
||
plugins: | ||
- serverless-webpack | ||
|
||
custom: | ||
webpackIncludeModules: true | ||
eubfrEnvironment: ${env:EUBFR_ENV, 'dev'} | ||
|
||
package: | ||
individually: true | ||
|
||
provider: | ||
name: aws | ||
runtime: nodejs6.10 | ||
stage: ${opt:stage, file(../../config.json):stage, 'dev'} | ||
region: ${opt:region, file(../../config.json):region, 'eu-central-1'} | ||
deploymentBucket: | ||
name: eubfr-${self:custom.eubfrEnvironment}-deploy | ||
stackTags: | ||
ENV: ${self:custom.eubfrEnvironment} | ||
|
||
functions: | ||
save: | ||
handler: src/handler.save | ||
events: | ||
- sns: | ||
arn: | ||
Fn::Join: | ||
- "" | ||
- - "arn:aws:sns:" | ||
- Ref: "AWS::Region" | ||
- ":" | ||
- Ref: "AWS::AccountId" | ||
- ":${self:provider.stage}-db" | ||
topicName: ${self:provider.stage}-db | ||
|
||
resources: | ||
Resources: | ||
SNSTopicDB: | ||
Type: AWS::SNS::Topic | ||
Properties: | ||
TopicName: ${self:provider.stage}-db | ||
DisplayName: Save to DB | ||
SNSTopicDBPolicy: | ||
Type: AWS::SNS::TopicPolicy | ||
Properties: | ||
PolicyDocument: | ||
Version: '2012-10-17' | ||
Statement: | ||
- | ||
Sid: AllowAllToPushNotificationEffect | ||
Action: | ||
- sns:Publish | ||
Effect: Allow | ||
Resource: "*" | ||
Principal: "*" | ||
Topics: | ||
- | ||
Ref: SNSTopicDB |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* eslint-disable import/prefer-default-export, no-console */ | ||
export const save = (event, context, callback) => { | ||
/* | ||
* Some checks here before going any further | ||
*/ | ||
|
||
// Only work on the first record | ||
const snsRecord = event.Records[0]; | ||
|
||
// Was the lambda triggered correctly? Is the file extension supported? etc. | ||
if (!snsRecord || snsRecord.EventSource !== 'aws:sns') { | ||
return callback('Bad record'); | ||
} | ||
|
||
// Save to DB | ||
|
||
return callback(null, 'All fine'); | ||
}; |
3 changes: 1 addition & 2 deletions
3
services/example01/webpack.config.js → services/db/webpack.config.js
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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.