Skip to content

Commit

Permalink
Merge pull request #57 from developmentseed/fix_upload_concurrency
Browse files Browse the repository at this point in the history
version 2.1.1
  • Loading branch information
Alireza authored Feb 8, 2018
2 parents efb32f5 + 1b7df10 commit 171226e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## v2.1.1

- fix a bug where uploaded lambda file was corrupted due to race condition
- add lambda name to zip file

## v2.1.0

- add support for nested cloudformation templates
Expand Down
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const deprecate = require('deprecate');
const pLimit = require('p-limit');
const Kes = require('./src/kes');
const Config = require('./src/config');
const utils = require('./src/utils');
Expand All @@ -17,10 +18,11 @@ const success = (r) => process.exit(0);
* @return {Promise} returns a promise of an updated Kes config object
*/
function buildNestedCfs(config, KesClass, options) {
const limit = pLimit(1);
if (config.nested_templates) {
const nested = config.nested_templates;
console.log('Nested templates are found!');
const ps = Object.keys(nested).map((name) => {
const ps = Object.keys(nested).map((name) => limit(() => {
console.log(`Compiling nested template for ${name}`);

const newOptions = Object.assign({}, options);
Expand All @@ -47,7 +49,7 @@ function buildNestedCfs(config, KesClass, options) {
return kes.uploadCF().then((uri) => {
config.nested_templates[name].url = uri;
});
});
}));
return Promise.all(ps).then(() => config);
}
return Promise.resolve(config);
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kes",
"version": "2.1.0",
"version": "2.1.1",
"description": "Making deployment to AWS using CloudFormation easier and fun",
"scripts": {
"html-docs": "documentation build bin/cli.js -f html -o _docs --theme node_modules/documentation-devseed-theme",
Expand Down Expand Up @@ -78,6 +78,7 @@
"moment": "^2.19.4",
"mustache": "^2.3.0",
"node-forge": "^0.7.1",
"p-limit": "^1.2.0",
"prompt": "^1.0.0",
"yaml-files": "^0.1.0"
},
Expand Down
7 changes: 6 additions & 1 deletion src/lambda.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,13 @@ class Lambda {
lambda.hash = this.getHash(lambda.source).toString();
lambda.bucket = this.bucket;

if (!this.grouped.hasOwnProperty(lambda.hash)) {
this.grouped[lambda.hash] = lambda.name;
}

// local zip
const zipFile = `${lambda.hash}.zip`;
const lambdaName = this.grouped[lambda.hash];
const zipFile = `${lambda.hash}-${lambdaName}.zip`;
lambda.local = path.join(this.buildFolder, zipFile);

// remote address
Expand Down

0 comments on commit 171226e

Please sign in to comment.