From a37c890c15f04aa4370520708661d0378ab06d4d Mon Sep 17 00:00:00 2001 From: Philipp Muens Date: Mon, 27 Jun 2016 12:18:16 +0200 Subject: [PATCH] Add better stack identification on stack removal --- lib/plugins/aws/remove/lib/stack.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/plugins/aws/remove/lib/stack.js b/lib/plugins/aws/remove/lib/stack.js index 1c0329cea..8f15f0e53 100644 --- a/lib/plugins/aws/remove/lib/stack.js +++ b/lib/plugins/aws/remove/lib/stack.js @@ -47,7 +47,17 @@ module.exports = { .then((data) => { stackSummaries = data.StackSummaries; - const stack = _.find(stackSummaries, { StackName: stackName }); + let convertedStackSummary = {}; + // convert DeletionTime to UNIX timestamp + stackSummaries.forEach((stackSummary) => { + convertedStackSummary = stackSummary; + convertedStackSummary.DeletionTime = (new Date(stackSummary.DeletionTime)) + .getTime() / 1000; + }); + + const stack = _.find( + _.orderBy(stackSummaries, 'DeletionTime', 'desc'), { StackName: stackName } + ); stackStatus = stack.StackStatus; this.serverless.cli.log('Checking stack removal progress...');