dynamodb-backup-restore
Advanced tools
Comparing version 0.0.9 to 0.0.10
@@ -69,12 +69,21 @@ 'use strict'; | ||
let config = { | ||
S3Bucket: 'jobsheet.backup.us-east-1', | ||
S3Region: 'us-east-1', | ||
S3Prefix: 'test', | ||
DbTable: 'ImpoLite-dev', | ||
DbRegion: 'us-west-2', | ||
LambdaName: 'test1', | ||
LambdaRegion: 'us-west-2', | ||
LambdaAlias: 'dev', | ||
LambdaRoleName: 'backup-role', | ||
LambdaSourcePath: 'D:\ddbbackup' | ||
S3Bucket: argv.s3bucket, | ||
S3Prefix: argv.s3prefix, | ||
S3Region: argv.s3region, | ||
DbTable: argv.dbtable, | ||
DbRegion: argv.dbregion, | ||
LambdaName: argv.LambdaName, | ||
LambdaRegion: argv.LambdaRegion, | ||
LambdaAlias: argv.LambdaAlias, | ||
LambdaRoleName: argv.LambdaRoleName | ||
// S3Bucket: 'jobsheet.backup.us-east-1', | ||
// S3Region: 'us-east-1', | ||
// S3Prefix: 'test', | ||
// DbTable: 'ImpoLite-dev', | ||
// DbRegion: 'us-west-2', | ||
// LambdaName: 'test1', | ||
// LambdaRegion: 'us-west-2', | ||
// LambdaAlias: 'dev', | ||
// LambdaRoleName: 'backup-role' | ||
}; | ||
@@ -81,0 +90,0 @@ |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -6,4 +6,4 @@ { | ||
"dependencies": { | ||
"dynamodb-backup-restore ": "0.0.8" | ||
"dynamodb-backup-restore ": "0.0.10" | ||
} | ||
} |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
'use strict'; | ||
const AWS = require('aws-sdk'); | ||
const gulp = require('gulp'); | ||
//const lambda = require('gulp-awslambda'); | ||
//const zip = require('gulp-zip'); | ||
const util = require('util'); | ||
@@ -25,6 +22,5 @@ const exec = require('child_process').exec; | ||
this.DbRegion = config.DbRegion; | ||
this.LambdaSourcePath = config.LambdaSourcePath; | ||
} | ||
configureLambdaRole() { | ||
configureRole() { | ||
return this.getRole() | ||
@@ -139,32 +135,18 @@ .then(role => { | ||
// deployLambda(roleArn) { | ||
// return new Promise((resolve, reject) => { | ||
// let lambda_params = { | ||
// FunctionName: this.LambdaName, | ||
// Description: 'Backup Lambda', | ||
// Role: roleArn, | ||
// Handler: 'index.handler', | ||
// Timeout: 6, | ||
// MemorySize: 128 | ||
// }; | ||
// return gulp.src(['./lambda/*', './lambda/**/*', '!./lambda/handler.zip'], | ||
// { 'base': './lambda' }) | ||
// .pipe(zip('./lambda/handler.zip', { compress: false })) | ||
// .pipe(lambda(lambda_params, { region: this.LambdaRegion })) | ||
// .pipe(gulp.dest('.')); | ||
// }); | ||
// } | ||
deployLambda(roleArn) { | ||
deploy(roleArn) { | ||
return this.getArchive() | ||
.then(zip => { | ||
return this.updateLambdaConfiguration(roleArn) | ||
.then(() => { | ||
console.log(zip); | ||
return this.updateLambdaCode(zip); | ||
}) | ||
.then(() => { | ||
return this.isFunctionExists(); | ||
}) | ||
.then(isExists => { | ||
if (isExists) { | ||
return this.updateConfiguration(roleArn) | ||
.then(() => { | ||
return this.updateCode(); | ||
}) | ||
} | ||
else { | ||
return this.create(roleArn); | ||
} | ||
}) | ||
.catch(err => { | ||
@@ -175,3 +157,2 @@ throw err; | ||
getArchive() { | ||
@@ -182,5 +163,4 @@ let _this = this; | ||
fse.walk('./lambda') | ||
.on('data', function (item) { | ||
.on('data', item => { | ||
let symbolicLink = item.stats.isSymbolicLink() && fs.existsSync(item.path); | ||
if (item.stats.isFile() || symbolicLink) { | ||
@@ -194,7 +174,7 @@ let name = path.relative('./lambda', item.path); | ||
}) | ||
.on('end', function () { | ||
.on('end', () => { | ||
resolve(); | ||
}) | ||
}) | ||
.then(function () { | ||
.then(() => { | ||
_this.zipName = `${_this.LambdaName}_${_this.LambdaAlias}_${_this.LambdaRegion}.zip`; | ||
@@ -211,13 +191,23 @@ _this.zipBuffer = zip.generate({ | ||
fs.writeFileSync(_this.pathCompressed, _this.zipBuffer); | ||
}); | ||
} | ||
isFunctionExists() { | ||
return new Promise(resolve => { | ||
let lambda = new AWS.Lambda({ region: this.LambdaRegion }); | ||
let params = { | ||
FunctionName: this.LambdaName | ||
}; | ||
lambda.getFunction(params, err => { | ||
return resolve(!err); | ||
}); | ||
}); | ||
} | ||
createLambda(buffer, roleArn) { | ||
create(roleArn) { | ||
return new Promise((resolve, reject) => { | ||
let lambda = new AWS.Lambda({ region: this.LambdaRegion }); | ||
let params = { | ||
Code: { | ||
ZipFile: buffer | ||
ZipFile: this.zipBuffer | ||
}, | ||
@@ -241,5 +231,4 @@ FunctionName: this.LambdaName, | ||
updateLambdaConfiguration(roleArn) { | ||
updateConfiguration(roleArn) { | ||
return new Promise((resolve, reject) => { | ||
let lambda = new AWS.Lambda({ region: this.LambdaRegion }); | ||
@@ -263,5 +252,4 @@ let params = { | ||
updateLambdaCode(buffer) { | ||
updateCode() { | ||
return new Promise((resolve, reject) => { | ||
let lambda = new AWS.Lambda({ region: this.LambdaRegion }); | ||
@@ -281,3 +269,3 @@ let params = { | ||
configureLambda() { | ||
configure() { | ||
return this.publishVersion() | ||
@@ -303,3 +291,2 @@ .then(params => { | ||
if (err) { | ||
console.log(err); | ||
return reject(err); | ||
@@ -369,3 +356,3 @@ } | ||
setLambdaEventSource(streamArn) { | ||
setEventSource(streamArn) { | ||
return this.getEventSources(streamArn) | ||
@@ -481,3 +468,3 @@ .then(eventSources => { | ||
setLambdaParams() { | ||
setParams() { | ||
return new Promise((resolve, reject) => { | ||
@@ -484,0 +471,0 @@ let config = { |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -25,12 +25,12 @@ 'use strict'; | ||
.then(() => { | ||
return this.lambdaInfrastructure.setLambdaParams(); | ||
return this.lambdaInfrastructure.setParams(); | ||
}) | ||
.then(() => { | ||
return this.lambdaInfrastructure.configureLambdaRole() | ||
return this.lambdaInfrastructure.configureRole() | ||
}) | ||
.then(roleArn => { | ||
return this.lambdaInfrastructure.deployLambda(roleArn) | ||
return this.lambdaInfrastructure.deploy(roleArn) | ||
}) | ||
.then(() => { | ||
return this.lambdaInfrastructure.configureLambda() | ||
return this.lambdaInfrastructure.configure() | ||
}) | ||
@@ -45,3 +45,3 @@ .catch(err => { | ||
.then(streamArn => { | ||
return this.lambdaInfrastructure.setLambdaEventSource(streamArn) | ||
return this.lambdaInfrastructure.setEventSource(streamArn) | ||
}) | ||
@@ -48,0 +48,0 @@ .catch(err => { |
@@ -0,0 +0,0 @@ 'use strict'; |
{ | ||
"name": "dynamodb-backup-restore", | ||
"version": "0.0.9", | ||
"version": "0.0.10", | ||
"description": "AWS DynamoDb tool for full, incremental backup and restore", | ||
@@ -20,2 +20,3 @@ "homepage": "https://github.com/Purple-Unicorns/DynamoDbBackUp", | ||
"lambda", | ||
"dynamo", | ||
"dynamodb", | ||
@@ -28,3 +29,2 @@ "dynamodbstream", | ||
"dependencies": { | ||
"aws-sdk": "^2.4.7", | ||
"lodash": "^4.13.1", | ||
@@ -35,2 +35,3 @@ "node-zip": "^1.1.0", | ||
"devDependencies": { | ||
"aws-sdk": "^2.4.7", | ||
"gulp-jasmine": "^2.4.0", | ||
@@ -37,0 +38,0 @@ "yargs": "^4.6.0", |
@@ -0,0 +0,0 @@ #dynamodb-backup-restore |
@@ -0,0 +0,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3
55543
4
20
- Removedaws-sdk@^2.4.7
- Removedavailable-typed-arrays@1.0.7(transitive)
- Removedaws-sdk@2.1692.0(transitive)
- Removedbase64-js@1.5.1(transitive)
- Removedbuffer@4.9.2(transitive)
- Removedcall-bind@1.0.7(transitive)
- Removeddefine-data-property@1.1.4(transitive)
- Removedes-define-property@1.0.0(transitive)
- Removedes-errors@1.3.0(transitive)
- Removedevents@1.1.1(transitive)
- Removedfor-each@0.3.3(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedget-intrinsic@1.2.4(transitive)
- Removedgopd@1.0.1(transitive)
- Removedhas-property-descriptors@1.0.2(transitive)
- Removedhas-proto@1.0.3(transitive)
- Removedhas-symbols@1.0.3(transitive)
- Removedhas-tostringtag@1.0.2(transitive)
- Removedhasown@2.0.2(transitive)
- Removedieee754@1.1.13(transitive)
- Removedis-arguments@1.1.1(transitive)
- Removedis-callable@1.2.7(transitive)
- Removedis-generator-function@1.0.10(transitive)
- Removedis-typed-array@1.1.13(transitive)
- Removedisarray@1.0.0(transitive)
- Removedjmespath@0.16.0(transitive)
- Removedpossible-typed-array-names@1.0.0(transitive)
- Removedpunycode@1.3.2(transitive)
- Removedquerystring@0.2.0(transitive)
- Removedsax@1.2.1(transitive)
- Removedset-function-length@1.2.2(transitive)
- Removedurl@0.10.3(transitive)
- Removedutil@0.12.5(transitive)
- Removeduuid@8.0.0(transitive)
- Removedwhich-typed-array@1.1.15(transitive)
- Removedxml2js@0.6.2(transitive)
- Removedxmlbuilder@11.0.1(transitive)