Skip to content

Commit

Permalink
fix(AWS Deploy): Fix stack errors processing
Browse files Browse the repository at this point in the history
  • Loading branch information
medikoo committed May 20, 2021
1 parent 29f0e9c commit 18a9b2b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 4 additions & 1 deletion lib/plugins/aws/lib/monitorStack.js
Expand Up @@ -101,9 +101,12 @@ module.exports = {
this.serverless.cli.log(`View the full error output: ${stackUrl}`);
let errorMessage = 'An error occurred: ';
errorMessage += `${stackLatestError.LogicalResourceId} - `;
errorMessage += `${stackLatestError.ResourceStatusReason}.`;
errorMessage += `${
stackLatestError.ResourceStatusReason || stackLatestError.ResourceStatus
}.`;
const errorCode = (() => {
if (
stackLatestError.ResourceStatusReason &&
stackLatestError.ResourceStatusReason.startsWith('Properties validation failed')
) {
return `AWS_STACK_${action.toUpperCase()}_VALIDATION_ERROR`;
Expand Down
3 changes: 1 addition & 2 deletions test/unit/lib/plugins/aws/lib/monitorStack.test.js
Expand Up @@ -921,7 +921,6 @@ describe('monitorStack', () => {
ResourceType: 'AWS::CloudFormation::Stack',
Timestamp: new Date(),
ResourceStatus: 'UPDATE_ROLLBACK_IN_PROGRESS',
ResourceStatusReason: 'Export is in use',
},
],
};
Expand All @@ -943,7 +942,7 @@ describe('monitorStack', () => {

return awsPlugin.monitorStack('update', cfDataMock, { frequency: 10 }).catch((e) => {
let errorMessage = 'An error occurred: ';
errorMessage += 'mocha - Export is in use.';
errorMessage += 'mocha - UPDATE_ROLLBACK_IN_PROGRESS.';
expect(e.name).to.be.equal('ServerlessError');
expect(e.message).to.be.equal(errorMessage);
// callCount is 2 because Serverless will immediately exits and shows the error
Expand Down

0 comments on commit 18a9b2b

Please sign in to comment.