From db4a88b402169dab5b58ec1346043fc79b623b04 Mon Sep 17 00:00:00 2001 From: Raja Date: Mon, 16 Jul 2018 18:55:29 +0530 Subject: [PATCH 01/11] Batch processing ebs-snapshot-purge activity --- lambda/ebs_purge_old_snapshots_lambda.js | 26 ++++++++++++++++++++++++ lambda/ebs_snapshot_lambda.js | 19 ++++++++--------- 2 files changed, 35 insertions(+), 10 deletions(-) create mode 100644 lambda/ebs_purge_old_snapshots_lambda.js diff --git a/lambda/ebs_purge_old_snapshots_lambda.js b/lambda/ebs_purge_old_snapshots_lambda.js new file mode 100644 index 0000000..8198979 --- /dev/null +++ b/lambda/ebs_purge_old_snapshots_lambda.js @@ -0,0 +1,26 @@ +var Promise = require('bluebird'); + +var ebs = require('./ebs'); + +var handler = function* (event, context, callback) { + try { + + yield ebs.purgeSnapshotsInBatches(process.env.BATCH_SIZE || 10); + + callback(null, 'Finished'); + } catch(e) { + callback(e); + } +}; + +exports.handler = Promise.coroutine(handler); + +//Uncomment below to test locally +exports.handler(null, null, function(e, s) { + if(e) { + console.log("[ERROR] " + e); + return; + } + + console.log(s); +}); diff --git a/lambda/ebs_snapshot_lambda.js b/lambda/ebs_snapshot_lambda.js index cc4f64d..9dc30aa 100644 --- a/lambda/ebs_snapshot_lambda.js +++ b/lambda/ebs_snapshot_lambda.js @@ -5,7 +5,6 @@ var ebs = require('./ebs'); var handler = function* (event, context, callback) { try { - yield ebs.snapshotVolumes(); yield ebs.purgeSnapshots(); callback(null, 'Finished'); @@ -16,12 +15,12 @@ var handler = function* (event, context, callback) { exports.handler = Promise.coroutine(handler); -//Uncomment below to test locally -// exports.handler(null, null, function(e, s) { -// if(e) { -// console.log("[ERROR] " + e); -// return; -// } -// -// console.log(s); -// }); \ No newline at end of file +// Uncomment below to test locally +exports.handler(null, null, function(e, s) { + if(e) { + console.log("[ERROR] " + e); + return; + } + + console.log(s); +}); \ No newline at end of file From 58fc56b7c6045fab1997820cf5efb721b15bfe8e Mon Sep 17 00:00:00 2001 From: Raja Date: Mon, 16 Jul 2018 18:56:55 +0530 Subject: [PATCH 02/11] ebs.js updated --- lambda/ebs.js | 55 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 45 insertions(+), 10 deletions(-) diff --git a/lambda/ebs.js b/lambda/ebs.js index 23152d5..8cf80ce 100644 --- a/lambda/ebs.js +++ b/lambda/ebs.js @@ -83,28 +83,63 @@ var deleteSnapshot = function(snapshotId) { }; return ec2.deleteSnapshot(params).promise(); }; +var retryDeleteSnapshot = deleteSnapshot; -var purgeSnapshots = function() { +var getSnapshots = function(MaxResults, NextToken) { var today = utils.getDate(new Date()); - var snapshotsParams = { + + return ec2.describeSnapshots({ DryRun: false, Filters: [ { Name: "tag:PurgeDate", Values: [today] - }, - ] - }; - - var snapshotDeletePromises = ec2.describeSnapshots(snapshotsParams).promise() + } + ], + MaxResults, + NextToken, + }).promise(); +}; + +var purgeSnapshots = function(MaxResults, NextToken) { + var nextToken; + + var snapshotDeletePromises = getSnapshots(MaxResults, NextToken) .then(function(data) { + + nextToken = data.NextToken; + return data.Snapshots.map(function(snapshot) { - return deleteSnapshot(snapshot.SnapshotId); + return deleteSnapshot(snapshot.SnapshotId) + .then(checkSnapshotPurgeStatus, function() { return retryDeleteSnapshot(snapshot.SnapshotId); }); }); }); - return Promise.all(snapshotDeletePromises); + return Promise.all(snapshotDeletePromises).then(function() { + return Promise.resolve(nextToken); + }); +}; + +var checkSnapshotPurgeStatus = function(snapshot) { + if (snapshot.State == 'completed') + return Promise.resolve(); + + console.log('>>> ' + snapshot.SnapshotId + ' purge state is ' + snapshot.state + '. Retrying purge once more ...'); + return retryDeleteSnapshot(snapshot.SnapshotId); +}; + +var promisesToPurgeSnapshotsInBatches = [] +var purgeSnapshotsInBatches = function(BATCH_SIZE, next) { + return purgeSnapshots(BATCH_SIZE) + .then(function(nextToken) { + if (nextToken) + return promisesToPurgeSnapshotsInBatches.push(purgeSnapshotsInBatches(BATCH_SIZE, next)); + + console.log('>>> Purge snapshot activity completed in '+ (promisesToPurgeSnapshotsInBatches.length + 1) +' batches.'); + return Promise.all(promisesToPurgeSnapshotsInBatches); + }); }; exports.snapshotVolumes = snapshotVolumes; -exports.purgeSnapshots = purgeSnapshots; \ No newline at end of file +exports.purgeSnapshots = purgeSnapshots; +exports.purgeSnapshotsInBatches = purgeSnapshotsInBatches; \ No newline at end of file From b799332375a7fb18cf11cda39d58a0524bd535d4 Mon Sep 17 00:00:00 2001 From: Raja Date: Wed, 25 Jul 2018 18:19:27 +0530 Subject: [PATCH 03/11] More changes on ebj.js --- lambda/ebs.js | 75 ++++++++++++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 34 deletions(-) diff --git a/lambda/ebs.js b/lambda/ebs.js index 8cf80ce..8a5d167 100644 --- a/lambda/ebs.js +++ b/lambda/ebs.js @@ -1,9 +1,9 @@ var utils = require('./utils'); -var Promise = require('bluebird'); var AWS = require('aws-sdk'); var ec2 = new AWS.EC2(utils.getRegionObject()); var config = require('./config.json'); +var promisesToPurgeSnapshotsInBatches = [] var getPurgeDate = function(tags) { var purgeDate = new Date(); @@ -76,66 +76,73 @@ var snapshotVolumes = function () { return Promise.all(snapshotPromises); }; -var deleteSnapshot = function(snapshotId) { +var deleteSnapshot = function(SnapshotId) { var params = { - SnapshotId: snapshotId, + SnapshotId, DryRun: false }; - return ec2.deleteSnapshot(params).promise(); + + console.log(">>> Deleting "+ SnapshotId + " ..."); + return ec2.deleteSnapshot(params).promise() + .catch(err => { + if (err.statusCode == 400 && err.code == 'InvalidSnapshot.InUse') { + console.log(">>> Skiping ERROR on deleting "+ SnapshotId +" in use ..."); + return Promise.resolve({}); + } + return Promise.reject(); + }); }; + +var checkSnapshotPurgeStatus = function(snapshot) { + + if (!snapshot.State || snapshot.State == 'completed') // Empty-response OR snapshot-delete-status obj considered successful here. + return Promise.resolve(); + + console.log('>>> ' + snapshot.SnapshotId + ' purge state is ' + snapshot.state + '. Retrying purge once more ...'); + return retryDeleteSnapshot(snapshot.SnapshotId); +}; + var retryDeleteSnapshot = deleteSnapshot; var getSnapshots = function(MaxResults, NextToken) { - var today = utils.getDate(new Date()); - return ec2.describeSnapshots({ DryRun: false, Filters: [ { Name: "tag:PurgeDate", - Values: [today] + Values: [process.argv[2] || utils.getDate(new Date())] } ], - MaxResults, - NextToken, + // MaxResults, //-- + // NextToken, //-- This pagination is not working }).promise(); }; -var purgeSnapshots = function(MaxResults, NextToken) { - var nextToken; +var purgeSnapshots = (MaxResults, NextToken) => getSnapshots(MaxResults, NextToken) + .then(data => Promise.all( - var snapshotDeletePromises = getSnapshots(MaxResults, NextToken) - .then(function(data) { + data.Snapshots.map(snapshot => deleteSnapshot(snapshot.SnapshotId) + .then(checkSnapshotPurgeStatus, err => retryDeleteSnapshot(snapshot.SnapshotId)) + ) - nextToken = data.NextToken; + ).then(() => Promise.resolve( - return data.Snapshots.map(function(snapshot) { - return deleteSnapshot(snapshot.SnapshotId) - .then(checkSnapshotPurgeStatus, function() { return retryDeleteSnapshot(snapshot.SnapshotId); }); - }); - }); - - return Promise.all(snapshotDeletePromises).then(function() { - return Promise.resolve(nextToken); - }); -}; + (data.Snapshots && data.Snapshots.length) // If there are more snapshots + ? data.NextToken // PASS NextToken + : null // Else signal a NULL -var checkSnapshotPurgeStatus = function(snapshot) { - if (snapshot.State == 'completed') - return Promise.resolve(); + )) - console.log('>>> ' + snapshot.SnapshotId + ' purge state is ' + snapshot.state + '. Retrying purge once more ...'); - return retryDeleteSnapshot(snapshot.SnapshotId); -}; + ); -var promisesToPurgeSnapshotsInBatches = [] var purgeSnapshotsInBatches = function(BATCH_SIZE, next) { - return purgeSnapshots(BATCH_SIZE) + + return purgeSnapshots(BATCH_SIZE, next) .then(function(nextToken) { if (nextToken) - return promisesToPurgeSnapshotsInBatches.push(purgeSnapshotsInBatches(BATCH_SIZE, next)); + return promisesToPurgeSnapshotsInBatches.push(purgeSnapshotsInBatches(BATCH_SIZE, nextToken)); - console.log('>>> Purge snapshot activity completed in '+ (promisesToPurgeSnapshotsInBatches.length + 1) +' batches.'); + console.log('>>> Purge snapshot activity for '+ (process.argv[2] || utils.getDate(new Date())) +' completed in '+ (promisesToPurgeSnapshotsInBatches.length + 1) +' batches.'); return Promise.all(promisesToPurgeSnapshotsInBatches); }); }; From 4e1900996443bdbc584b5b3c76bb964f5c4c6405 Mon Sep 17 00:00:00 2001 From: Raja Date: Wed, 25 Jul 2018 18:20:10 +0530 Subject: [PATCH 04/11] ebs-snapshot prge script updated --- lambda/ebs_purge_old_snapshots_lambda.js | 26 ------------------------ lambda/ebs_purge_snapshots_lambda.js | 21 +++++++++++++++++++ 2 files changed, 21 insertions(+), 26 deletions(-) delete mode 100644 lambda/ebs_purge_old_snapshots_lambda.js create mode 100644 lambda/ebs_purge_snapshots_lambda.js diff --git a/lambda/ebs_purge_old_snapshots_lambda.js b/lambda/ebs_purge_old_snapshots_lambda.js deleted file mode 100644 index 8198979..0000000 --- a/lambda/ebs_purge_old_snapshots_lambda.js +++ /dev/null @@ -1,26 +0,0 @@ -var Promise = require('bluebird'); - -var ebs = require('./ebs'); - -var handler = function* (event, context, callback) { - try { - - yield ebs.purgeSnapshotsInBatches(process.env.BATCH_SIZE || 10); - - callback(null, 'Finished'); - } catch(e) { - callback(e); - } -}; - -exports.handler = Promise.coroutine(handler); - -//Uncomment below to test locally -exports.handler(null, null, function(e, s) { - if(e) { - console.log("[ERROR] " + e); - return; - } - - console.log(s); -}); diff --git a/lambda/ebs_purge_snapshots_lambda.js b/lambda/ebs_purge_snapshots_lambda.js new file mode 100644 index 0000000..d94dc46 --- /dev/null +++ b/lambda/ebs_purge_snapshots_lambda.js @@ -0,0 +1,21 @@ +var ebs = require('./ebs'); + + +var handler = (event, context, callback) => + + ebs.purgeSnapshotsInBatches(process.env.BATCH_SIZE || 100) + .then(()=> callback(null, 'Finished')) + .catch(callback); + + +exports.handler = handler + +//Uncomment below to test locally +exports.handler(null, null, function(e, s) { + if(e) { + console.log("[ERROR] ", e); + return; + } + + console.log(s); +}); From e8186465103e85d933c3a32262c05843d02c9ada Mon Sep 17 00:00:00 2001 From: Raja Date: Wed, 25 Jul 2018 18:20:49 +0530 Subject: [PATCH 05/11] ebs_snapshot_lambda script updated --- lambda/ebs_snapshot_lambda.js | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/lambda/ebs_snapshot_lambda.js b/lambda/ebs_snapshot_lambda.js index 9dc30aa..6a14cb2 100644 --- a/lambda/ebs_snapshot_lambda.js +++ b/lambda/ebs_snapshot_lambda.js @@ -1,19 +1,15 @@ -var Promise = require('bluebird'); var ebs = require('./ebs'); -var handler = function* (event, context, callback) { - try { - - yield ebs.purgeSnapshots(); + +var handler = (event, context, callback) => - callback(null, 'Finished'); - } catch(e) { - callback(e); - } -}; + ebs.snapshotVolumes(process.env.BATCH_SIZE || 100) + .then(()=> callback(null, 'Finished')) + .catch(callback); + -exports.handler = Promise.coroutine(handler); +exports.handler = handler; // Uncomment below to test locally exports.handler(null, null, function(e, s) { @@ -23,4 +19,4 @@ exports.handler(null, null, function(e, s) { } console.log(s); -}); \ No newline at end of file +}); From def3e5eb8f9f4cafd12e226ce7bf23a437699698 Mon Sep 17 00:00:00 2001 From: Raja Date: Wed, 25 Jul 2018 18:21:21 +0530 Subject: [PATCH 06/11] blubird dependency removed --- lambda/package.json | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lambda/package.json b/lambda/package.json index 3e4a811..ce8f3e5 100644 --- a/lambda/package.json +++ b/lambda/package.json @@ -2,11 +2,8 @@ "name": "ebs_snapshot_lambda", "version": "0.1.0", "description": "AWS Lambda function to create and purge EBS snapshots", - "main": "ebs_snapshot_lambda.js", "scripts": {}, "author": "manojlds (https://stacktoheap.com/)", "license": "MIT", - "dependencies": { - "bluebird": "3.4.1" - } + "dependencies": {} } \ No newline at end of file From 03cec966478ed98b7a12b16bbdfdc023acc855d1 Mon Sep 17 00:00:00 2001 From: Raja Date: Thu, 26 Jul 2018 09:54:17 +0530 Subject: [PATCH 07/11] ebs.snapshotVolumes method updated --- lambda/ebs.js | 21 +++++++++------------ lambda/ebs_snapshot_lambda.js | 2 +- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/lambda/ebs.js b/lambda/ebs.js index 8a5d167..edc364b 100644 --- a/lambda/ebs.js +++ b/lambda/ebs.js @@ -62,18 +62,15 @@ var snapshotVolumes = function () { ] }; - var snapshotPromises = ec2.describeVolumes(getVolumesParam) + return ec2.describeVolumes(getVolumesParam) .promise() - .then(function(data) { - return data.Volumes.map(function(volume) { - return createSnapshot(volume.VolumeId) - .then(function(data) { - return tagSnapshot(volume, data.SnapshotId); - }) - }); - }); - - return Promise.all(snapshotPromises); + .then(data => Promise.all( + data.Volumes.map(volume => + createSnapshot(volume.VolumeId) + .then(data => tagSnapshot(volume, data.SnapshotId)) + ) + )); + }; var deleteSnapshot = function(SnapshotId) { @@ -86,7 +83,7 @@ var deleteSnapshot = function(SnapshotId) { return ec2.deleteSnapshot(params).promise() .catch(err => { if (err.statusCode == 400 && err.code == 'InvalidSnapshot.InUse') { - console.log(">>> Skiping ERROR on deleting "+ SnapshotId +" in use ..."); + console.log(">>> Skipping ERROR on deleting "+ SnapshotId +" in use ..."); return Promise.resolve({}); } return Promise.reject(); diff --git a/lambda/ebs_snapshot_lambda.js b/lambda/ebs_snapshot_lambda.js index 6a14cb2..16b826c 100644 --- a/lambda/ebs_snapshot_lambda.js +++ b/lambda/ebs_snapshot_lambda.js @@ -4,7 +4,7 @@ var ebs = require('./ebs'); var handler = (event, context, callback) => - ebs.snapshotVolumes(process.env.BATCH_SIZE || 100) + ebs.snapshotVolumes() .then(()=> callback(null, 'Finished')) .catch(callback); From 3cb8be501a1568c278930ae7df178ffc5c37e0ee Mon Sep 17 00:00:00 2001 From: Raja Date: Thu, 26 Jul 2018 09:58:37 +0530 Subject: [PATCH 08/11] Local testing code-block commented out --- lambda/ebs_purge_snapshots_lambda.js | 14 +++++++------- lambda/ebs_snapshot_lambda.js | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lambda/ebs_purge_snapshots_lambda.js b/lambda/ebs_purge_snapshots_lambda.js index d94dc46..ff2e146 100644 --- a/lambda/ebs_purge_snapshots_lambda.js +++ b/lambda/ebs_purge_snapshots_lambda.js @@ -11,11 +11,11 @@ var handler = (event, context, callback) => exports.handler = handler //Uncomment below to test locally -exports.handler(null, null, function(e, s) { - if(e) { - console.log("[ERROR] ", e); - return; - } +// exports.handler(null, null, function(e, s) { +// if(e) { +// console.log("[ERROR] ", e); +// return; +// } - console.log(s); -}); +// console.log(s); +// }); diff --git a/lambda/ebs_snapshot_lambda.js b/lambda/ebs_snapshot_lambda.js index 16b826c..d5f7169 100644 --- a/lambda/ebs_snapshot_lambda.js +++ b/lambda/ebs_snapshot_lambda.js @@ -12,11 +12,11 @@ var handler = (event, context, callback) => exports.handler = handler; // Uncomment below to test locally -exports.handler(null, null, function(e, s) { - if(e) { - console.log("[ERROR] " + e); - return; - } +// exports.handler(null, null, function(e, s) { +// if(e) { +// console.log("[ERROR] " + e); +// return; +// } - console.log(s); -}); +// console.log(s); +// }); From 78344b65e17ec3b95fa735b3442085d772dca360 Mon Sep 17 00:00:00 2001 From: Raja Date: Fri, 27 Jul 2018 14:01:19 +0530 Subject: [PATCH 09/11] lambda module refactored Changes summary; - Unnecessary files removed - index.handler is set as lamda-handler --- lambda/ebs_snapshot_lambda.js | 22 ------------------- ...ebs_purge_snapshots_lambda.js => index.js} | 5 +++-- lambda/package/.gitkeep | 0 lambda/yarn.lock | 6 ----- 4 files changed, 3 insertions(+), 30 deletions(-) delete mode 100644 lambda/ebs_snapshot_lambda.js rename lambda/{ebs_purge_snapshots_lambda.js => index.js} (68%) delete mode 100644 lambda/package/.gitkeep delete mode 100644 lambda/yarn.lock diff --git a/lambda/ebs_snapshot_lambda.js b/lambda/ebs_snapshot_lambda.js deleted file mode 100644 index d5f7169..0000000 --- a/lambda/ebs_snapshot_lambda.js +++ /dev/null @@ -1,22 +0,0 @@ - -var ebs = require('./ebs'); - - -var handler = (event, context, callback) => - - ebs.snapshotVolumes() - .then(()=> callback(null, 'Finished')) - .catch(callback); - - -exports.handler = handler; - -// Uncomment below to test locally -// exports.handler(null, null, function(e, s) { -// if(e) { -// console.log("[ERROR] " + e); -// return; -// } - -// console.log(s); -// }); diff --git a/lambda/ebs_purge_snapshots_lambda.js b/lambda/index.js similarity index 68% rename from lambda/ebs_purge_snapshots_lambda.js rename to lambda/index.js index ff2e146..576fb6b 100644 --- a/lambda/ebs_purge_snapshots_lambda.js +++ b/lambda/index.js @@ -3,14 +3,15 @@ var ebs = require('./ebs'); var handler = (event, context, callback) => - ebs.purgeSnapshotsInBatches(process.env.BATCH_SIZE || 100) + ebs.purgeSnapshotsInBatches(process.env.BATCH_SIZE || 10) + .then(ebs.snapshotVolumes, ebs.snapshotVolumes) .then(()=> callback(null, 'Finished')) .catch(callback); exports.handler = handler -//Uncomment below to test locally +// // Uncomment below to test locally // exports.handler(null, null, function(e, s) { // if(e) { // console.log("[ERROR] ", e); diff --git a/lambda/package/.gitkeep b/lambda/package/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/lambda/yarn.lock b/lambda/yarn.lock deleted file mode 100644 index 1affab6..0000000 --- a/lambda/yarn.lock +++ /dev/null @@ -1,6 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 -bluebird@3.4.1: - version "3.4.1" - resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.4.1.tgz#b731ddf48e2dd3bedac2e75e1215a11bcb91fa07" - From f684a73e3e0789bb823dddfaa4fb408d8251c17a Mon Sep 17 00:00:00 2001 From: Raja Date: Fri, 27 Jul 2018 14:03:49 +0530 Subject: [PATCH 10/11] notifyFailure method added --- lambda/ebs.js | 43 +++++++++++++++++++++++++++++++++++++++---- lambda/utils.js | 13 ++++++++++++- 2 files changed, 51 insertions(+), 5 deletions(-) diff --git a/lambda/ebs.js b/lambda/ebs.js index edc364b..9c8830a 100644 --- a/lambda/ebs.js +++ b/lambda/ebs.js @@ -1,7 +1,9 @@ var utils = require('./utils'); var AWS = require('aws-sdk'); -var ec2 = new AWS.EC2(utils.getRegionObject()); +AWS.config.update(utils.getRegionObject()); +var ec2 = new AWS.EC2(utils.getApiVersionObject()); +var ses = new AWS.SES(utils.getApiVersionObject()); var config = require('./config.json'); var promisesToPurgeSnapshotsInBatches = [] @@ -69,7 +71,8 @@ var snapshotVolumes = function () { createSnapshot(volume.VolumeId) .then(data => tagSnapshot(volume, data.SnapshotId)) ) - )); + )) + .catch(notifyFailure); }; @@ -130,7 +133,7 @@ var purgeSnapshots = (MaxResults, NextToken) => getSnapshots(MaxResults, NextTok )) - ); + ).catch(notifyFailure); var purgeSnapshotsInBatches = function(BATCH_SIZE, next) { @@ -144,6 +147,38 @@ var purgeSnapshotsInBatches = function(BATCH_SIZE, next) { }); }; +var notifyFailure = function(error) { + + if (!(process.env.TO_EMAIL_ADDRESS && process.env.SENDER_EMAIL_ADDRESS)) + return Promise.reject(error); + + return ses.sendEmail({ + Destination: { + CcAddresses: [ + process.env.CC_EMAIL_ADDRESS || process.env.TO_EMAIL_ADDRESS, + ], + ToAddresses: [ + process.env.TO_EMAIL_ADDRESS, + ] + }, + Message: { + Body: { + Text: { + Charset: "UTF-8", + Data: error.message || error + } + }, + Subject: { + Charset: 'UTF-8', + Data: 'EBS Snapshot Lambda Failed' + } + }, + Source: process.env.SENDER_EMAIL_ADDRESS, + }).promise(); + +} + exports.snapshotVolumes = snapshotVolumes; exports.purgeSnapshots = purgeSnapshots; -exports.purgeSnapshotsInBatches = purgeSnapshotsInBatches; \ No newline at end of file +exports.purgeSnapshotsInBatches = purgeSnapshotsInBatches; +exports.notifyFailure = notifyFailure; \ No newline at end of file diff --git a/lambda/utils.js b/lambda/utils.js index b9a36d5..5240172 100644 --- a/lambda/utils.js +++ b/lambda/utils.js @@ -1,11 +1,20 @@ var region = process.env.AWS_DEFAULT_REGION || "us-east-1"; +var apiVersion = process.env.AWS_DEFAULT_API_VERSION || "2016-11-15"; var getRegion = function () { return region; } var getRegionObject = function() { - return { region: region }; + return { region }; +} + +var getApiVersion = function() { + return apiVersion; +} + +var getApiVersionObject = function() { + return { apiVersion }; } var getTags = function(tags) { @@ -21,5 +30,7 @@ var getDate = function(date) { exports.getRegion = getRegion; exports.getRegionObject = getRegionObject; +exports.getApiVersion = getApiVersion; +exports.getRegionObject = getRegionObject; exports.getTags = getTags; exports.getDate = getDate; From fa83b9d59798fa1b074de2c030d9fb6a63b46934 Mon Sep 17 00:00:00 2001 From: Raja Date: Fri, 27 Jul 2018 15:31:38 +0530 Subject: [PATCH 11/11] utils.js exports corrected --- lambda/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lambda/utils.js b/lambda/utils.js index 5240172..907dc72 100644 --- a/lambda/utils.js +++ b/lambda/utils.js @@ -31,6 +31,6 @@ var getDate = function(date) { exports.getRegion = getRegion; exports.getRegionObject = getRegionObject; exports.getApiVersion = getApiVersion; -exports.getRegionObject = getRegionObject; +exports.getApiVersionObject = getApiVersionObject; exports.getTags = getTags; exports.getDate = getDate;