aws-architect 6.6.23 → 6.6.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,7 @@ This is the changelog for [AWS Architect](readme.md).
4
4
  ## 6.6 ##
5
5
  * Add support to `deleteWebsiteVersion(version)`
6
6
  * Fix `The function must be in an Active state. The current state for function arn:aws:lambda:Function:514 is Pending`.
7
+ * Automatically delete existing ROLLBACK_COMPLETE stacks.
7
8
 
8
9
  ## 6.5 ##
9
10
  * Support APIGW version 2
@@ -54,33 +54,46 @@ class CloudFormationDeployer {
54
54
  }
55
55
  }
56
56
 
57
- stackExists(stackName) {
58
- return this.cloudFormationClient.describeStacks({ StackName: stackName }).promise()
59
- .then(data => {
60
- if (!data.Stacks[0]) {
61
- return false;
62
- }
63
- let stackStatus = data.Stacks[0].StackStatus;
64
- let stackExistsDict = {
65
- CREATE_COMPLETE: true,
66
- UPDATE_COMPLETE: true,
67
- UPDATE_ROLLBACK_COMPLETE: true
68
- };
57
+ async stackExists(stackName) {
58
+ let data;
59
+ try {
60
+ data = await this.cloudFormationClient.describeStacks({ StackName: stackName }).promise();
61
+ } catch (error) {
62
+ return false;
63
+ }
64
+ if (!data.Stacks[0]) {
65
+ return false;
66
+ }
67
+ let stackStatus = data.Stacks[0].StackStatus;
68
+ let stackExistsDict = {
69
+ CREATE_COMPLETE: true,
70
+ UPDATE_COMPLETE: true,
71
+ UPDATE_ROLLBACK_COMPLETE: true
72
+ };
69
73
 
70
- if (stackExistsDict[stackStatus]) {
71
- return true;
72
- }
73
- if (stackStatus === 'REVIEW_IN_PROGRESS') {
74
- return false;
75
- }
76
- if (stackStatus === 'ROLLBACK_COMPLETE') {
77
- throw { error: 'Stack must be deleted manually and cannot be used', status: stackStatus };
74
+ if (stackExistsDict[stackStatus]) {
75
+ return true;
76
+ }
77
+ if (stackStatus === 'REVIEW_IN_PROGRESS') {
78
+ return false;
79
+ }
80
+ if (stackStatus === 'ROLLBACK_COMPLETE') {
81
+ console.log('Current status of stack is ROLLBACK_COMPLETE, deleting before generating a new stack.');
82
+ await this.cloudFormationClient.deleteStack({ StackName: stackName }).promise();
83
+ for (let checkIteration = 0; checkIteration < 120; checkIteration++) {
84
+ try {
85
+ await this.cloudFormationClient.describeStacks({ StackName: stackName }).promise();
86
+ await new Promise(resolve => setTimeout(resolve, 5000));
87
+ } catch (error) {
88
+ break;
89
+ }
78
90
  }
79
- throw { error: 'Current status of stack prevents creation or update.', status: stackStatus };
80
- }, () => false);
91
+ return false;
92
+ }
93
+ throw { error: 'Current status of stack prevents creation or update.', status: stackStatus };
81
94
  }
82
95
 
83
- async waitForCompletion(stackName, allow_update_rollback) {
96
+ async waitForCompletion(stackName, allowUpdateRollback) {
84
97
  let timeout = new Date();
85
98
  let timeoutLength = 60 * 60 * 1000;
86
99
  timeout.setTime(timeout.getTime() + timeoutLength);
@@ -108,7 +121,7 @@ class CloudFormationDeployer {
108
121
  throw { error: 'Current status of the stack has failed', status: stackStatus };
109
122
  }
110
123
 
111
- if (!allow_update_rollback && stackStatus === 'UPDATE_ROLLBACK_COMPLETE') {
124
+ if (!allowUpdateRollback && stackStatus === 'UPDATE_ROLLBACK_COMPLETE') {
112
125
  throw { title: 'Current stack status is failure', status: stackStatus };
113
126
  }
114
127
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aws-architect",
3
- "version": "6.6.23",
3
+ "version": "6.6.28",
4
4
  "description": "AWS Architect is a node based tool to configure and deploy AWS-based microservices.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -44,7 +44,7 @@
44
44
  "error-object-polyfill": "^1.1.14",
45
45
  "eslint-config-cimpress-atsquad": "^1.0.67",
46
46
  "glob": "^5.0.15",
47
- "mocha": "^9.1.3",
47
+ "mocha": "^9.2.1",
48
48
  "sinon": "^1.17.3"
49
49
  },
50
50
  "repository": {