aws-architect 6.6.26 → 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/lib/CloudFormationDeployer.js +37 -26
- package/package.json +1 -1
|
@@ -54,35 +54,46 @@ class CloudFormationDeployer {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
stackExists(stackName) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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
|
+
}
|
|
80
90
|
}
|
|
81
|
-
|
|
82
|
-
}
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
throw { error: 'Current status of stack prevents creation or update.', status: stackStatus };
|
|
83
94
|
}
|
|
84
95
|
|
|
85
|
-
async waitForCompletion(stackName,
|
|
96
|
+
async waitForCompletion(stackName, allowUpdateRollback) {
|
|
86
97
|
let timeout = new Date();
|
|
87
98
|
let timeoutLength = 60 * 60 * 1000;
|
|
88
99
|
timeout.setTime(timeout.getTime() + timeoutLength);
|
|
@@ -110,7 +121,7 @@ class CloudFormationDeployer {
|
|
|
110
121
|
throw { error: 'Current status of the stack has failed', status: stackStatus };
|
|
111
122
|
}
|
|
112
123
|
|
|
113
|
-
if (!
|
|
124
|
+
if (!allowUpdateRollback && stackStatus === 'UPDATE_ROLLBACK_COMPLETE') {
|
|
114
125
|
throw { title: 'Current stack status is failure', status: stackStatus };
|
|
115
126
|
}
|
|
116
127
|
|