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...');