File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
22
33# desc: zips up lambda function resources and uploads to aws
4- # docs: http://docs.aws.amazon.com/cli /latest/reference/lambda/upload-function .html
4+ # docs: http://docs.aws.amazon.com/lambda /latest/dg/API_UpdateFunctionCode .html
55
66zip -r function.zip package.json node_modules/* lib/* index.js
77
8- aws lambda upload-function \
9- --function-name pgexport \
10- --function-zip function.zip \
11- --runtime nodejs \
12- --role arn:aws:iam::674223647607:role/pgexport_lambda_exec_role \
13- --handler index.handler \
14- --mode event \
15- --timeout 60 \
16- --memory-size 256 \
17- --region us-east-1
18-
19- # aws lambda update-function-code \
20- # --function-name pgexport \
21- # --zip-file fileb://function.zip
8+ aws lambda update-function-code \
9+ --function-name pgexport \
10+ --zip-file fileb://function.zip
2211
2312rm function.zip
Original file line number Diff line number Diff line change 11'use strict' ;
2- var aws = require ( 'aws-sdk' ) ;
3- var pgp = require ( 'pg-promise' ) ( ) ;
4- var admZip = require ( 'adm-zip' ) ;
5- var Q = require ( 'q' ) ;
6- var _ = require ( 'underscore' ) ;
72var PGExport = require ( './lib/pg-export' ) ;
8- var RDSIngress = require ( './lib/rds-ingress' ) ;
93
10- exports . handler = function ( event , context ) {
4+ exports . handler = function ( event , context , callback ) {
115
126 var options = {
137 bucket : 'pgexport-awslambda' ,
@@ -34,7 +28,7 @@ exports.handler = function (event, context) {
3428 actions [ event . action ] ( event )
3529 . then ( function ( result ) {
3630 console . log ( event . action + ' succeeded ' ) ;
37- context . done ( null , result ) ;
31+ callback ( null , result ) ;
3832 } )
39- . fail ( context . done ) ;
33+ . fail ( callback ) ;
4034} ;
Original file line number Diff line number Diff line change @@ -98,8 +98,10 @@ PGExport.prototype.exportData = function (queries) {
9898 return self . put ( { Key : self . root + '/meta.json' , Body : JSON . stringify ( self . meta ) , ContentType : 'application/json' } ) ;
9999 } )
100100 . then ( function ( ) {
101- console . log ( fileUrl ) ;
102- return fileUrl ;
101+ console . log ( 'saved archive to: ' + self . key ) ;
102+ return {
103+ key : self . key
104+ } ;
103105 } )
104106 . fail ( function ( e ) {
105107 console . log ( 'error in chain: ' , e ) ;
Original file line number Diff line number Diff line change 55 "main" : " index.js" ,
66 "dependencies" : {
77 "archiver" : " ^0.14.4" ,
8+ "aws-sdk" : " ^2.18.0" ,
89 "csv-stringify" : " 0.0.8" ,
910 "pg-promise" : " ^1.0.7" ,
1011 "q" : " ^1.3.0" ,
1112 "request" : " ^2.55.0" ,
12- "underscore" : " ^1.8.3" ,
13- "underscore.string" : " ^3.0.3"
13+ "underscore" : " ^1.8.3"
1414 },
1515 "scripts" : {
1616 "test" : " test.js"
Original file line number Diff line number Diff line change @@ -27,11 +27,9 @@ var evt = {
2727// "key": "yves.richard@tesera.com/reports/66f41e6a-d2e6-4f74-94b9-88d7888ece2d/strata.zip"
2828// };
2929
30- var context = {
31- done : function ( err , data ) {
32- if ( err ) console . log ( 'lambda exited with errors: ' , err )
33- else console . log ( 'lambda exited without errors ' , data )
34- }
30+ var callback = function ( err , data ) {
31+ if ( err ) console . log ( 'lambda exited with errors: ' , err )
32+ else console . log ( 'lambda exited without errors ' , data )
3533} ;
3634
37- lambda . handler ( evt , context ) ;
35+ lambda . handler ( evt , { } , callback ) ;
You can’t perform that action at this time.
0 commit comments