@cdkd/cli 0.334.3 → 0.335.0
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/dist/ambient-client-defaults-B9bnuob2.js +960 -0
- package/dist/ambient-client-defaults-B9bnuob2.js.map +1 -0
- package/dist/{asg-provider-Gu-qQLG9.js → asg-provider-pl5tnbiA.js} +4 -3
- package/dist/asg-provider-pl5tnbiA.js.map +1 -0
- package/dist/cli.js +2 -2
- package/dist/{db-instance-modify-retry-AJiRFAXa.js → db-instance-modify-retry-CD7NSyq4.js} +10 -9
- package/dist/{db-instance-modify-retry-AJiRFAXa.js.map → db-instance-modify-retry-CD7NSyq4.js.map} +1 -1
- package/dist/{deploy-engine-BktCSZdi.js → deploy-engine-iQpILlcZ.js} +2130 -1951
- package/dist/deploy-engine-iQpILlcZ.js.map +1 -0
- package/dist/{iam-role-provider-BJ5XgxFH.js → iam-role-provider-jC3_bsf-.js} +4 -3
- package/dist/iam-role-provider-jC3_bsf-.js.map +1 -0
- package/dist/index.d.ts +34 -42
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/{neptune-provider-6SGPWYUE.js → neptune-provider-CNEMvt4t.js} +5 -4
- package/dist/neptune-provider-CNEMvt4t.js.map +1 -0
- package/dist/{program-Dm0zFrcG.js → program-DaGdaozO.js} +21 -9
- package/dist/program-DaGdaozO.js.map +1 -0
- package/dist/{provider-classes-BDPm7luc.js → provider-classes-ZpRORGt2.js} +10 -9
- package/dist/provider-classes-ZpRORGt2.js.map +1 -0
- package/dist/{rds-provider--9aIoAY-.js → rds-provider-Ce7ua-ww.js} +289 -30
- package/dist/rds-provider-Ce7ua-ww.js.map +1 -0
- package/dist/read-replica-BJAUZwWe.js +201 -0
- package/dist/read-replica-BJAUZwWe.js.map +1 -0
- package/dist/{update-removal-73OUGFVU.js → update-removal-Dh6W86TO.js} +148 -1098
- package/dist/update-removal-Dh6W86TO.js.map +1 -0
- package/dist/{version-CO5muce9.js → version-BxcTCG5i.js} +2 -2
- package/dist/{version-CO5muce9.js.map → version-BxcTCG5i.js.map} +1 -1
- package/package.json +1 -1
- package/dist/asg-provider-Gu-qQLG9.js.map +0 -1
- package/dist/deploy-engine-BktCSZdi.js.map +0 -1
- package/dist/iam-role-provider-BJ5XgxFH.js.map +0 -1
- package/dist/neptune-provider-6SGPWYUE.js.map +0 -1
- package/dist/program-Dm0zFrcG.js.map +0 -1
- package/dist/provider-classes-BDPm7luc.js.map +0 -1
- package/dist/rds-provider--9aIoAY-.js.map +0 -1
- package/dist/update-removal-73OUGFVU.js.map +0 -1
|
@@ -1,962 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { c as ambientRegion,
|
|
1
|
+
import { $ as safeMsg, J as displaySafe, N as getCurrentStackName, Q as plainIdentOr, U as UNRENDERABLE, V as SECRET_REF_MAX_CODE_POINTS, X as isPasteableIdent, Y as displayStackName, Z as isPlainIdent, n as describeAwsFailure } from "./aws-failure-text-CoS1huLy.js";
|
|
2
|
+
import { B as isMarkedNonRetryable, I as isRetryableTransientError, L as isTransientServerError, N as isAmbiguousOutcomeError, R as retryClassificationText, T as markReplayMayCollide, ct as SHELL_ACTIVE, dt as commandHole, gt as plainOrDescribed, mt as pasteableCommand, nt as ProvisioningError, pt as isInertUnquoted, y as hasReplayMayCollide, yt as shellQuote } from "./ambient-client-defaults-B9bnuob2.js";
|
|
3
|
+
import { c as ambientRegion, r as getAssumedRoleCredentials } from "./aws-client-defaults-BLXFsfMa.js";
|
|
4
4
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
5
5
|
|
|
6
|
-
// src/utils/pasteable-run-context.ts
|
|
7
|
-
let runFlags = {};
|
|
8
|
-
let verbFlags;
|
|
9
|
-
function setPasteableRunFlags(flags) {
|
|
10
|
-
runFlags = { ...flags };
|
|
11
|
-
}
|
|
12
|
-
function pasteableRunFlags() {
|
|
13
|
-
return runFlags;
|
|
14
|
-
}
|
|
15
|
-
function setPasteableVerbFlags(map) {
|
|
16
|
-
verbFlags = map;
|
|
17
|
-
}
|
|
18
|
-
function pasteableVerbFlags(verb) {
|
|
19
|
-
return verbFlags?.get(verb);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// src/utils/pasteable-command.ts
|
|
23
|
-
const SHELL_ACTIVE = /[\s'"`$;&|<>()*?[\]{}!#~\\^=%,]/;
|
|
24
|
-
const PASTE_ARG_UNSAFE = /[\s'"`$;&|<>()\\*?[\]{}!]|^[#=]|(?:^|[=:])~/;
|
|
25
|
-
function shellQuote(value) {
|
|
26
|
-
return /^[A-Za-z0-9._/@:+-]+$/.test(value) ? value : `'${value.replace(/'/g, `'\\''`)}'`;
|
|
27
|
-
}
|
|
28
|
-
const CLAUSE_BREAK = /: | -- | — |[.!?]\s/;
|
|
29
|
-
function hasClauseBreak(text) {
|
|
30
|
-
return CLAUSE_BREAK.test(text);
|
|
31
|
-
}
|
|
32
|
-
const UNSHOWABLE_VALUE = "a value that cannot be shown safely here";
|
|
33
|
-
function shellBoundedDisplay(shown) {
|
|
34
|
-
if (hasClauseBreak(shown)) return UNSHOWABLE_VALUE;
|
|
35
|
-
return shown.startsWith("\"") || shown === "<unrenderable>" ? shellQuote(shown) : shown;
|
|
36
|
-
}
|
|
37
|
-
function commandHole(name) {
|
|
38
|
-
return `'<${name}>'`;
|
|
39
|
-
}
|
|
40
|
-
const SHELL_ACTIVE_WHY = "holds whitespace or a character a shell treats specially, and only a value that stays inert without its quotes is named in a command here, since text pasted before the command can undo the quotes and leave it to run as shell";
|
|
41
|
-
function plainOrDescribed(value, what) {
|
|
42
|
-
return isPasteableIdent(value) ? value : `a ${what} that is not a plain identifier`;
|
|
43
|
-
}
|
|
44
|
-
function quotedOrDescribed(value, what) {
|
|
45
|
-
return isPasteableIdent(value) ? `'${value}'` : plainOrDescribed(value, what);
|
|
46
|
-
}
|
|
47
|
-
function physicalIdShownBesideCommand(value, opts) {
|
|
48
|
-
if (typeof value !== "string" || value.startsWith("-")) return void 0;
|
|
49
|
-
const plain = (text) => isInertUnquoted(text) && displayIdent(text, { maxCodePoints: 613 }) === text;
|
|
50
|
-
if (plain(value)) return value;
|
|
51
|
-
const token = opts?.maskToken;
|
|
52
|
-
if (token === void 0 || token === "" || !value.includes(token)) return void 0;
|
|
53
|
-
const rendered = displayIdent(value, { maxCodePoints: 613 });
|
|
54
|
-
return value.split(token).every((part) => part === "" || plain(part)) && rendered === JSON.stringify(value) ? rendered : void 0;
|
|
55
|
-
}
|
|
56
|
-
function isInertUnquoted(value) {
|
|
57
|
-
return !PASTE_ARG_UNSAFE.test(value);
|
|
58
|
-
}
|
|
59
|
-
function withholdReason(value, opts) {
|
|
60
|
-
if (value === "") return "empty";
|
|
61
|
-
const safe = displaySafe(value, { asciiOnly: true });
|
|
62
|
-
if (safe !== value) return "altered";
|
|
63
|
-
const cap = opts?.maxCodePoints !== void 0 && Number.isFinite(opts.maxCodePoints) ? Math.max(1, opts.maxCodePoints) : STACK_REF_MAX_CODE_POINTS;
|
|
64
|
-
if (truncateCodePoints(safe, cap).truncated) return "too-long";
|
|
65
|
-
if (value.startsWith("-")) return "option-shaped";
|
|
66
|
-
if (opts?.patternMatched === true && (value.includes("*") || value.includes("/"))) return "pattern-shaped";
|
|
67
|
-
if (opts?.plainIdent === true) return isPasteableIdent(value) ? void 0 : "not-plain";
|
|
68
|
-
if (!isInertUnquoted(value)) return "shell-active";
|
|
69
|
-
}
|
|
70
|
-
function pasteableCommand(verb, args = [], extraFlags = []) {
|
|
71
|
-
let exact = true;
|
|
72
|
-
const withheld = [];
|
|
73
|
-
const parts = [verb];
|
|
74
|
-
for (const arg of args) {
|
|
75
|
-
if ("literal" in arg) {
|
|
76
|
-
parts.push(arg.literal);
|
|
77
|
-
continue;
|
|
78
|
-
}
|
|
79
|
-
if (!("value" in arg)) {
|
|
80
|
-
if ("flag" in arg) parts.push(arg.flag);
|
|
81
|
-
parts.push(commandHole(arg.hole));
|
|
82
|
-
exact = false;
|
|
83
|
-
continue;
|
|
84
|
-
}
|
|
85
|
-
const reason = withholdReason(arg.value, arg.opts);
|
|
86
|
-
let rendered;
|
|
87
|
-
if (reason === void 0) rendered = shellQuote(arg.value);
|
|
88
|
-
else {
|
|
89
|
-
rendered = commandHole(arg.hole);
|
|
90
|
-
exact = false;
|
|
91
|
-
withheld.push({
|
|
92
|
-
hole: arg.hole,
|
|
93
|
-
reason
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
if ("flag" in arg) parts.push(arg.flag);
|
|
97
|
-
parts.push(rendered);
|
|
98
|
-
}
|
|
99
|
-
parts.push(...extraFlags);
|
|
100
|
-
parts.push(...runFlagWords(verb, args, extraFlags));
|
|
101
|
-
return {
|
|
102
|
-
command: parts.join(" "),
|
|
103
|
-
exact,
|
|
104
|
-
withheld
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
function runFlagWords(verb, args, extraFlags) {
|
|
108
|
-
const accepted = pasteableVerbFlags(verb);
|
|
109
|
-
if (accepted === void 0) return [];
|
|
110
|
-
const present = /* @__PURE__ */ new Set();
|
|
111
|
-
for (const arg of args) if ("flag" in arg) present.add(arg.flag);
|
|
112
|
-
else if ("literal" in arg) present.add(arg.literal.split(" ")[0]);
|
|
113
|
-
for (const f of extraFlags) present.add(f.split(" ")[0]);
|
|
114
|
-
const run = pasteableRunFlags();
|
|
115
|
-
const out = [];
|
|
116
|
-
const add = (flag, value, hole, allowEmpty) => {
|
|
117
|
-
if (value === void 0 || value === "" && !allowEmpty) return;
|
|
118
|
-
if (!accepted.has(flag) || present.has(flag)) return;
|
|
119
|
-
const inert = displaySafe(value) === value && !value.startsWith("-") && !SHELL_ACTIVE.test(value) && !/\p{Cf}/u.test(value) && !truncateCodePoints(value, 1152).truncated;
|
|
120
|
-
out.push(`${flag} ${value === "" || inert ? shellQuote(value) : commandHole(hole)}`);
|
|
121
|
-
};
|
|
122
|
-
add("--profile", run.profile, "profile", false);
|
|
123
|
-
add("--state-bucket", run.stateBucket, "bucket", false);
|
|
124
|
-
add("--state-prefix", run.statePrefix, "prefix", true);
|
|
125
|
-
if (run.roleArn === true && accepted.has("--role-arn") && !present.has("--role-arn")) out.push(`--role-arn ${commandHole("role-arn")}`);
|
|
126
|
-
return out;
|
|
127
|
-
}
|
|
128
|
-
function withheldTargetClause(built, hole, verb, subject = "This record's name") {
|
|
129
|
-
const reason = built.withheld.find((w) => w.hole === hole)?.reason;
|
|
130
|
-
if (reason === void 0) return "";
|
|
131
|
-
let why;
|
|
132
|
-
switch (reason) {
|
|
133
|
-
case "altered":
|
|
134
|
-
why = `does NOT render exactly, so another record may render identically`;
|
|
135
|
-
break;
|
|
136
|
-
case "empty":
|
|
137
|
-
why = `is empty`;
|
|
138
|
-
break;
|
|
139
|
-
case "too-long":
|
|
140
|
-
why = `is too long to print`;
|
|
141
|
-
break;
|
|
142
|
-
case "option-shaped":
|
|
143
|
-
why = `begins with a '-', so it is not safe to print as an argument to '${verb}' — a name like '--all' is parsed as the FLAG and targets every stack`;
|
|
144
|
-
break;
|
|
145
|
-
case "pattern-shaped":
|
|
146
|
-
why = `would be read as a PATTERN by '${verb}', which can match other stacks`;
|
|
147
|
-
break;
|
|
148
|
-
case "shell-active":
|
|
149
|
-
why = SHELL_ACTIVE_WHY;
|
|
150
|
-
break;
|
|
151
|
-
case "not-plain":
|
|
152
|
-
why = "is not a plain identifier (a letter or digit, then letters, digits, '~', '_', '.' or '-'), the only shape named in a command here, since a name outside it can run as shell or read as a line of this message once the terminal wraps";
|
|
153
|
-
break;
|
|
154
|
-
default: throw new Error(`withheldTargetClause: unhandled WithholdReason ${String(reason)}`);
|
|
155
|
-
}
|
|
156
|
-
return ` ${subject} ${why} — so it is not named in the command below; list the records as stored with 'cdkd state list --long' and act on the one whose key matches.`;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
// src/utils/resource-type-shape.ts
|
|
160
|
-
const TIMEOUT_FLAG_RESOURCE_TYPE = /^[A-Z][A-Za-z0-9]+::[A-Z][A-Za-z0-9]+::[A-Z][A-Za-z0-9]+$/;
|
|
161
|
-
const RESOURCE_TYPE_MAX_LENGTH = 204;
|
|
162
|
-
const RESOURCE_TYPE_SHAPE$1 = /^(?:[A-Z][A-Za-z0-9]+(?:::[A-Z][A-Za-z0-9]+)+|Custom::[A-Za-z0-9_@-]+)$/;
|
|
163
|
-
function hasResourceTypeShape(value) {
|
|
164
|
-
return value.length <= 204 && RESOURCE_TYPE_SHAPE$1.test(value);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
// src/utils/error-handler/base-errors.ts
|
|
168
|
-
var CdkdError = class CdkdError extends Error {
|
|
169
|
-
code;
|
|
170
|
-
cause;
|
|
171
|
-
constructor(message, code, cause) {
|
|
172
|
-
super(message);
|
|
173
|
-
this.code = code;
|
|
174
|
-
this.cause = cause;
|
|
175
|
-
this.name = "CdkdError";
|
|
176
|
-
Object.setPrototypeOf(this, CdkdError.prototype);
|
|
177
|
-
}
|
|
178
|
-
};
|
|
179
|
-
var AccountIdUnavailableError = class AccountIdUnavailableError extends CdkdError {
|
|
180
|
-
constructor(message) {
|
|
181
|
-
super(message, "ACCOUNT_ID_UNAVAILABLE");
|
|
182
|
-
this.name = "AccountIdUnavailableError";
|
|
183
|
-
Object.setPrototypeOf(this, AccountIdUnavailableError.prototype);
|
|
184
|
-
}
|
|
185
|
-
};
|
|
186
|
-
var StateError = class StateError extends CdkdError {
|
|
187
|
-
constructor(message, cause) {
|
|
188
|
-
super(message, "STATE_ERROR", cause);
|
|
189
|
-
this.name = "StateError";
|
|
190
|
-
Object.setPrototypeOf(this, StateError.prototype);
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
var LockError = class LockError extends CdkdError {
|
|
194
|
-
constructor(message, cause) {
|
|
195
|
-
super(message, "LOCK_ERROR", cause);
|
|
196
|
-
this.name = "LockError";
|
|
197
|
-
Object.setPrototypeOf(this, LockError.prototype);
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
var SynthesisError = class SynthesisError extends CdkdError {
|
|
201
|
-
constructor(message, cause) {
|
|
202
|
-
super(message, "SYNTHESIS_ERROR", cause);
|
|
203
|
-
this.name = "SynthesisError";
|
|
204
|
-
Object.setPrototypeOf(this, SynthesisError.prototype);
|
|
205
|
-
}
|
|
206
|
-
};
|
|
207
|
-
var DeployCancelledError = class DeployCancelledError extends CdkdError {
|
|
208
|
-
constructor(message = "Deployment cancelled by user") {
|
|
209
|
-
super(message, "DEPLOY_CANCELLED");
|
|
210
|
-
this.name = "DeployCancelledError";
|
|
211
|
-
Object.setPrototypeOf(this, DeployCancelledError.prototype);
|
|
212
|
-
}
|
|
213
|
-
};
|
|
214
|
-
var DeploymentNotApprovedError = class DeploymentNotApprovedError extends CdkdError {
|
|
215
|
-
softAbort = true;
|
|
216
|
-
constructor(message) {
|
|
217
|
-
super(message, "DEPLOY_NOT_APPROVED");
|
|
218
|
-
this.name = "DeploymentNotApprovedError";
|
|
219
|
-
Object.setPrototypeOf(this, DeploymentNotApprovedError.prototype);
|
|
220
|
-
}
|
|
221
|
-
};
|
|
222
|
-
function isSoftAbort(error) {
|
|
223
|
-
return error instanceof Error && error.softAbort === true;
|
|
224
|
-
}
|
|
225
|
-
var AssetError = class AssetError extends CdkdError {
|
|
226
|
-
constructor(message, cause) {
|
|
227
|
-
super(message, "ASSET_ERROR", cause);
|
|
228
|
-
this.name = "AssetError";
|
|
229
|
-
Object.setPrototypeOf(this, AssetError.prototype);
|
|
230
|
-
}
|
|
231
|
-
};
|
|
232
|
-
var LocalInvokeBuildError = class LocalInvokeBuildError extends CdkdError {
|
|
233
|
-
constructor(message, cause) {
|
|
234
|
-
super(message, "LOCAL_INVOKE_BUILD_ERROR", cause);
|
|
235
|
-
this.name = "LocalInvokeBuildError";
|
|
236
|
-
Object.setPrototypeOf(this, LocalInvokeBuildError.prototype);
|
|
237
|
-
}
|
|
238
|
-
};
|
|
239
|
-
var ProvisioningError = class ProvisioningError extends CdkdError {
|
|
240
|
-
resourceType;
|
|
241
|
-
logicalId;
|
|
242
|
-
physicalId;
|
|
243
|
-
constructor(message, resourceType, logicalId, physicalId, cause) {
|
|
244
|
-
super(message, "PROVISIONING_ERROR", cause);
|
|
245
|
-
this.resourceType = resourceType;
|
|
246
|
-
this.logicalId = logicalId;
|
|
247
|
-
this.physicalId = physicalId;
|
|
248
|
-
this.name = "ProvisioningError";
|
|
249
|
-
Object.setPrototypeOf(this, ProvisioningError.prototype);
|
|
250
|
-
}
|
|
251
|
-
};
|
|
252
|
-
var ResourceTimeoutError = class ResourceTimeoutError extends CdkdError {
|
|
253
|
-
logicalId;
|
|
254
|
-
resourceType;
|
|
255
|
-
region;
|
|
256
|
-
elapsedMs;
|
|
257
|
-
operation;
|
|
258
|
-
timeoutMs;
|
|
259
|
-
constructor(logicalId, resourceType, region, elapsedMs, operation, timeoutMs) {
|
|
260
|
-
const elapsedLabel = formatDuration$1(elapsedMs);
|
|
261
|
-
const timeoutLabel = formatDuration$1(timeoutMs);
|
|
262
|
-
const shownId = plainOrDescribed(logicalId, "logical id");
|
|
263
|
-
const shownType = hasResourceTypeShape(resourceType) ? resourceType : "a resource type that is not printable as typed";
|
|
264
|
-
const remedy = hasResourceTypeShape(resourceType) && TIMEOUT_FLAG_RESOURCE_TYPE.test(resourceType) ? safeMsg`slow ENI provisioning. Re-run with --resource-timeout ${resourceType}='<DURATION>'\n` + "to bump the budget for this resource type only, or --verbose to see the\n" : "slow ENI provisioning. Re-run with a larger --resource-timeout '<DURATION>',\nor --verbose to see the\n";
|
|
265
|
-
super(safeMsg`Resource ${shownId} (${shownType}) in ${region} timed out after ${timeoutLabel} during ${operation} (elapsed ${elapsedLabel}).\n` + "This may indicate a stuck Cloud Control polling loop, hung Custom Resource, or\n" + remedy + "underlying provider activity.", "RESOURCE_TIMEOUT");
|
|
266
|
-
this.logicalId = logicalId;
|
|
267
|
-
this.resourceType = resourceType;
|
|
268
|
-
this.region = region;
|
|
269
|
-
this.elapsedMs = elapsedMs;
|
|
270
|
-
this.operation = operation;
|
|
271
|
-
this.timeoutMs = timeoutMs;
|
|
272
|
-
this.name = "ResourceTimeoutError";
|
|
273
|
-
Object.setPrototypeOf(this, ResourceTimeoutError.prototype);
|
|
274
|
-
}
|
|
275
|
-
};
|
|
276
|
-
function formatDuration$1(ms) {
|
|
277
|
-
if (ms < 6e4) return `${Math.round(ms / 1e3)}s`;
|
|
278
|
-
const totalMinutes = Math.round(ms / 6e4);
|
|
279
|
-
if (totalMinutes < 60) return `${totalMinutes}m`;
|
|
280
|
-
const hours = Math.floor(totalMinutes / 60);
|
|
281
|
-
const minutes = totalMinutes % 60;
|
|
282
|
-
return minutes === 0 ? `${hours}h` : `${hours}h${minutes}m`;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
// src/utils/error-handler/refusal-errors.ts
|
|
286
|
-
var IntrinsicResolutionRefusalError = class IntrinsicResolutionRefusalError extends CdkdError {
|
|
287
|
-
constructor(message, cause, code = "INTRINSIC_RESOLUTION_REFUSAL") {
|
|
288
|
-
super(message, code, cause);
|
|
289
|
-
this.name = "IntrinsicResolutionRefusalError";
|
|
290
|
-
Object.setPrototypeOf(this, IntrinsicResolutionRefusalError.prototype);
|
|
291
|
-
}
|
|
292
|
-
};
|
|
293
|
-
var CrossAccountSecretRefusalError = class CrossAccountSecretRefusalError extends IntrinsicResolutionRefusalError {
|
|
294
|
-
constructor(message, cause) {
|
|
295
|
-
super(message, cause, "INTRINSIC_RESOLUTION_REFUSAL_CROSS_ACCOUNT_SECRET");
|
|
296
|
-
this.name = "CrossAccountSecretRefusalError";
|
|
297
|
-
Object.setPrototypeOf(this, CrossAccountSecretRefusalError.prototype);
|
|
298
|
-
}
|
|
299
|
-
};
|
|
300
|
-
var MalformedProducerRecordRefusalError = class MalformedProducerRecordRefusalError extends IntrinsicResolutionRefusalError {
|
|
301
|
-
constructor(message, cause) {
|
|
302
|
-
super(message, cause, "INTRINSIC_RESOLUTION_REFUSAL_MALFORMED_PRODUCER_RECORD");
|
|
303
|
-
this.name = "MalformedProducerRecordRefusalError";
|
|
304
|
-
Object.setPrototypeOf(this, MalformedProducerRecordRefusalError.prototype);
|
|
305
|
-
}
|
|
306
|
-
};
|
|
307
|
-
var DynamicReferenceRegionAmbiguousError = class DynamicReferenceRegionAmbiguousError extends IntrinsicResolutionRefusalError {
|
|
308
|
-
constructor(message, cause) {
|
|
309
|
-
super(message, cause, "DYNAMIC_REFERENCE_REGION_AMBIGUOUS");
|
|
310
|
-
this.name = "DynamicReferenceRegionAmbiguousError";
|
|
311
|
-
Object.setPrototypeOf(this, DynamicReferenceRegionAmbiguousError.prototype);
|
|
312
|
-
}
|
|
313
|
-
};
|
|
314
|
-
|
|
315
|
-
// src/deployment/retryable-errors/patterns.ts
|
|
316
|
-
const IAM_PROPAGATION_ERROR_MESSAGE_PATTERNS = [
|
|
317
|
-
"cannot be assumed",
|
|
318
|
-
"Firehose is unable to assume role",
|
|
319
|
-
"is unable to assume provided role",
|
|
320
|
-
"is unable to assume the role",
|
|
321
|
-
"security token included in the request is invalid. (Service:",
|
|
322
|
-
"Received Exception while reading from provided stream. The security token included in the request is invalid",
|
|
323
|
-
"role defined for the function",
|
|
324
|
-
"not authorized to perform",
|
|
325
|
-
"execution role",
|
|
326
|
-
"trust policy",
|
|
327
|
-
"Role validation failed",
|
|
328
|
-
"does not have required permissions",
|
|
329
|
-
"Trusted Entity",
|
|
330
|
-
"Invalid principal in policy",
|
|
331
|
-
"Verify in IAM that the role has adequate trust relationships",
|
|
332
|
-
"The user with name",
|
|
333
|
-
"Policy Error: PrincipalNotFound",
|
|
334
|
-
"Invalid value for the parameter Policy",
|
|
335
|
-
"required permissions for: ENHANCED_MONITORING",
|
|
336
|
-
"Caught ServiceAccessDeniedException",
|
|
337
|
-
"The operator role is invalid or doesn't have sufficient permissions",
|
|
338
|
-
"doesn't have permission to perform ec2:DescribeSecurityGroups",
|
|
339
|
-
"One or more security group IDs are invalid",
|
|
340
|
-
"permissions required to assume the role",
|
|
341
|
-
"does not have a trust relationship allowing",
|
|
342
|
-
"does not have permission to publish with SNS",
|
|
343
|
-
"authorized to assume the provided role",
|
|
344
|
-
"not authorized to access the Log Destination",
|
|
345
|
-
"Cannot access stream",
|
|
346
|
-
"Please ensure the role can perform",
|
|
347
|
-
"KMS key is invalid for CreateGrant",
|
|
348
|
-
"Policy contains a statement with one or more invalid principals",
|
|
349
|
-
"Invalid IAM Instance Profile",
|
|
350
|
-
"Invalid InstanceProfile",
|
|
351
|
-
"Failed to authorize instance profile",
|
|
352
|
-
"is not a valid role to allow SNS",
|
|
353
|
-
"Could not assume the infrastructure role",
|
|
354
|
-
"AWS was not able to validate the provided access credentials (Service: Ecs,"
|
|
355
|
-
];
|
|
356
|
-
const OTHER_TRANSIENT_ERROR_MESSAGE_PATTERNS = [
|
|
357
|
-
"currently in the following state: Pending",
|
|
358
|
-
"has dependencies and cannot be deleted",
|
|
359
|
-
"can't be deleted since it has",
|
|
360
|
-
"DependencyViolation",
|
|
361
|
-
"does not exist",
|
|
362
|
-
"Schema is currently being altered",
|
|
363
|
-
"scheduled for deletion",
|
|
364
|
-
"Could not deliver test message",
|
|
365
|
-
"concurrent update operation",
|
|
366
|
-
"because it is in use",
|
|
367
|
-
"Rate exceeded",
|
|
368
|
-
"is marked disabled for mutation",
|
|
369
|
-
"There is an operation running on the Cluster",
|
|
370
|
-
"Unable to complete operation due to concurrent modification"
|
|
371
|
-
];
|
|
372
|
-
const NAME_COOLDOWN_ERROR_MESSAGE_PATTERNS = [
|
|
373
|
-
"QueueDeletedRecently",
|
|
374
|
-
"wait 60 seconds",
|
|
375
|
-
"StateMachineDeleting",
|
|
376
|
-
"State Machine is being deleted",
|
|
377
|
-
"conflicting conditional operation"
|
|
378
|
-
];
|
|
379
|
-
const RETRYABLE_ERROR_MESSAGE_PATTERNS = [
|
|
380
|
-
...IAM_PROPAGATION_ERROR_MESSAGE_PATTERNS,
|
|
381
|
-
...OTHER_TRANSIENT_ERROR_MESSAGE_PATTERNS,
|
|
382
|
-
...NAME_COOLDOWN_ERROR_MESSAGE_PATTERNS
|
|
383
|
-
];
|
|
384
|
-
const RETRYABLE_HTTP_STATUS_CODES = /* @__PURE__ */ new Set([429, 503]);
|
|
385
|
-
|
|
386
|
-
// src/deployment/retryable-errors/marks.ts
|
|
387
|
-
const THROTTLING_ERROR_NAMES = /* @__PURE__ */ new Set([
|
|
388
|
-
"BandwidthLimitExceeded",
|
|
389
|
-
"EC2ThrottledException",
|
|
390
|
-
"LimitExceededException",
|
|
391
|
-
"PriorRequestNotComplete",
|
|
392
|
-
"ProvisionedThroughputExceededException",
|
|
393
|
-
"RequestLimitExceeded",
|
|
394
|
-
"RequestThrottled",
|
|
395
|
-
"RequestThrottledException",
|
|
396
|
-
"SlowDown",
|
|
397
|
-
"ThrottledException",
|
|
398
|
-
"Throttling",
|
|
399
|
-
"ThrottlingException",
|
|
400
|
-
"TooManyRequestsException",
|
|
401
|
-
"TransactionInProgressException"
|
|
402
|
-
]);
|
|
403
|
-
const NON_RETRYABLE_MARKER = Symbol.for("cdkd.nonRetryable");
|
|
404
|
-
const MAX_CAUSE_CHAIN_DEPTH = 5;
|
|
405
|
-
const REDACTED_CAUSE_MARKER = Symbol.for("cdkd.redactedCause");
|
|
406
|
-
function markRedactedCause(error) {
|
|
407
|
-
if (!Object.isExtensible(error)) return error;
|
|
408
|
-
Object.defineProperty(error, REDACTED_CAUSE_MARKER, {
|
|
409
|
-
value: true,
|
|
410
|
-
enumerable: false,
|
|
411
|
-
configurable: true,
|
|
412
|
-
writable: false
|
|
413
|
-
});
|
|
414
|
-
return error;
|
|
415
|
-
}
|
|
416
|
-
function wrapMaskedAwsError(mask, error, build) {
|
|
417
|
-
const raw = describeAwsFailure(error).detail;
|
|
418
|
-
const masked = mask(raw);
|
|
419
|
-
const wrapped = build(masked);
|
|
420
|
-
return masked === raw ? wrapped : markRedactedCause(wrapped);
|
|
421
|
-
}
|
|
422
|
-
function hasRedactedCause(error) {
|
|
423
|
-
let current = error;
|
|
424
|
-
for (let depth = 0; depth < 5 && current != null; depth++) {
|
|
425
|
-
if (typeof current === "object" || typeof current === "function") {
|
|
426
|
-
if (current[REDACTED_CAUSE_MARKER] === true) return true;
|
|
427
|
-
}
|
|
428
|
-
current = current.cause;
|
|
429
|
-
}
|
|
430
|
-
return false;
|
|
431
|
-
}
|
|
432
|
-
function markNonRetryable(error) {
|
|
433
|
-
if (!Object.isExtensible(error)) return error;
|
|
434
|
-
Object.defineProperty(error, NON_RETRYABLE_MARKER, {
|
|
435
|
-
value: true,
|
|
436
|
-
enumerable: false,
|
|
437
|
-
configurable: true,
|
|
438
|
-
writable: false
|
|
439
|
-
});
|
|
440
|
-
return error;
|
|
441
|
-
}
|
|
442
|
-
function isMarkedNonRetryable(error) {
|
|
443
|
-
let current = error;
|
|
444
|
-
for (let depth = 0; depth < 5 && current != null; depth++) {
|
|
445
|
-
if (typeof current === "object" || typeof current === "function") {
|
|
446
|
-
if (current[NON_RETRYABLE_MARKER] === true) return true;
|
|
447
|
-
}
|
|
448
|
-
current = current.cause;
|
|
449
|
-
}
|
|
450
|
-
return false;
|
|
451
|
-
}
|
|
452
|
-
function isThrottlingError(error) {
|
|
453
|
-
let current = error;
|
|
454
|
-
for (let depth = 0; depth < 5 && current != null; depth++) {
|
|
455
|
-
const name = current.name;
|
|
456
|
-
if (typeof name === "string" && THROTTLING_ERROR_NAMES.has(name)) return true;
|
|
457
|
-
const status = current.$metadata?.httpStatusCode;
|
|
458
|
-
if (status !== void 0 && RETRYABLE_HTTP_STATUS_CODES.has(status)) return true;
|
|
459
|
-
current = current.cause;
|
|
460
|
-
}
|
|
461
|
-
return false;
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
// src/deployment/retryable-errors/transient.ts
|
|
465
|
-
const TRANSIENT_SERVER_ERROR_STATUS_CODES = /* @__PURE__ */ new Set([
|
|
466
|
-
500,
|
|
467
|
-
502,
|
|
468
|
-
503,
|
|
469
|
-
504
|
|
470
|
-
]);
|
|
471
|
-
function isTransientServerError(error) {
|
|
472
|
-
let current = error;
|
|
473
|
-
for (let depth = 0; depth < 5 && current != null; depth++) {
|
|
474
|
-
const status = current.$metadata?.httpStatusCode;
|
|
475
|
-
if (status !== void 0 && TRANSIENT_SERVER_ERROR_STATUS_CODES.has(status)) return true;
|
|
476
|
-
current = current.cause;
|
|
477
|
-
}
|
|
478
|
-
return false;
|
|
479
|
-
}
|
|
480
|
-
const AMBIGUOUS_SOCKET_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
481
|
-
"ECONNRESET",
|
|
482
|
-
"EPIPE",
|
|
483
|
-
"ETIMEDOUT",
|
|
484
|
-
"EADDRNOTAVAIL"
|
|
485
|
-
]);
|
|
486
|
-
const AMBIGUOUS_CC_HANDLER_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
487
|
-
"InternalFailure",
|
|
488
|
-
"HandlerInternalFailure",
|
|
489
|
-
"ServiceInternalError",
|
|
490
|
-
"NetworkFailure",
|
|
491
|
-
"NotStabilized",
|
|
492
|
-
"ServiceTimeout",
|
|
493
|
-
"GeneralServiceException",
|
|
494
|
-
"Throttling"
|
|
495
|
-
]);
|
|
496
|
-
function isAmbiguousCcHandlerErrorCode(code) {
|
|
497
|
-
return code !== void 0 && AMBIGUOUS_CC_HANDLER_ERROR_CODES.has(code);
|
|
498
|
-
}
|
|
499
|
-
function isAmbiguousOutcomeError(error) {
|
|
500
|
-
try {
|
|
501
|
-
let current = error;
|
|
502
|
-
for (let depth = 0; depth < 5 && typeof current === "object" && current !== null; depth++) {
|
|
503
|
-
const link = current;
|
|
504
|
-
if (typeof link.name === "string" && THROTTLING_ERROR_NAMES.has(link.name)) return false;
|
|
505
|
-
if (link.$retryable?.throttling === true) return false;
|
|
506
|
-
const status = link.$metadata?.httpStatusCode;
|
|
507
|
-
if (typeof status === "number" && TRANSIENT_SERVER_ERROR_STATUS_CODES.has(status)) return true;
|
|
508
|
-
if (typeof link.code === "string" && AMBIGUOUS_SOCKET_ERROR_CODES.has(link.code)) return true;
|
|
509
|
-
if (link.name === "TimeoutError") return true;
|
|
510
|
-
if (typeof link.ccErrorCode === "string" && AMBIGUOUS_CC_HANDLER_ERROR_CODES.has(link.ccErrorCode)) return true;
|
|
511
|
-
current = link.cause;
|
|
512
|
-
}
|
|
513
|
-
} catch {}
|
|
514
|
-
return false;
|
|
515
|
-
}
|
|
516
|
-
function describeRetryClassificationSignals(error) {
|
|
517
|
-
let current = error;
|
|
518
|
-
let deepestName;
|
|
519
|
-
let sawMetadata = false;
|
|
520
|
-
let metadataName;
|
|
521
|
-
let metadataRequestId;
|
|
522
|
-
for (let depth = 0; depth < 5 && current != null; depth++) {
|
|
523
|
-
const name = current.name;
|
|
524
|
-
if (depth > 0 && typeof name === "string" && name !== "") deepestName = name;
|
|
525
|
-
const metadata = current.$metadata;
|
|
526
|
-
if (metadata != null && typeof metadata === "object" && !Array.isArray(metadata)) {
|
|
527
|
-
const { httpStatusCode, requestId } = metadata;
|
|
528
|
-
const linkName = typeof name === "string" && name !== "" ? name : void 0;
|
|
529
|
-
if (!sawMetadata) {
|
|
530
|
-
sawMetadata = true;
|
|
531
|
-
metadataName = linkName;
|
|
532
|
-
metadataRequestId = typeof requestId === "string" && requestId !== "" ? requestId : void 0;
|
|
533
|
-
}
|
|
534
|
-
if (typeof httpStatusCode === "number") return {
|
|
535
|
-
name: linkName ?? deepestName,
|
|
536
|
-
httpStatusCode,
|
|
537
|
-
requestId: (typeof requestId === "string" && requestId !== "" ? requestId : void 0) ?? metadataRequestId,
|
|
538
|
-
noMetadata: false
|
|
539
|
-
};
|
|
540
|
-
}
|
|
541
|
-
current = current.cause;
|
|
542
|
-
}
|
|
543
|
-
return {
|
|
544
|
-
name: metadataName ?? deepestName,
|
|
545
|
-
requestId: metadataRequestId,
|
|
546
|
-
noMetadata: !sawMetadata
|
|
547
|
-
};
|
|
548
|
-
}
|
|
549
|
-
function formatRetryClassificationSignals(error) {
|
|
550
|
-
const signals = describeRetryClassificationSignals(error);
|
|
551
|
-
if (signals.name === void 0 && signals.httpStatusCode === void 0 && signals.requestId === void 0) return "";
|
|
552
|
-
const parts = [];
|
|
553
|
-
if (signals.name !== void 0) parts.push(`name=${signals.name}`);
|
|
554
|
-
if (signals.httpStatusCode !== void 0) parts.push(`http=${signals.httpStatusCode}`);
|
|
555
|
-
if (signals.requestId !== void 0) parts.push(`requestId=${signals.requestId}`);
|
|
556
|
-
if (signals.noMetadata) parts.push("no-$metadata");
|
|
557
|
-
return ` [${parts.join(" ")}]`;
|
|
558
|
-
}
|
|
559
|
-
function isRetryableTransientError(error, message) {
|
|
560
|
-
if (isMarkedNonRetryable(error)) return false;
|
|
561
|
-
if (isExplicitDenyError(message)) return false;
|
|
562
|
-
if (isThrottlingError(error)) return true;
|
|
563
|
-
if (isTransientServerError(error)) return true;
|
|
564
|
-
return RETRYABLE_ERROR_MESSAGE_PATTERNS.some((p) => message.includes(p));
|
|
565
|
-
}
|
|
566
|
-
function retryClassificationText(error) {
|
|
567
|
-
const top = describeAwsFailure(error).detail;
|
|
568
|
-
if (!hasRedactedCause(error)) return top;
|
|
569
|
-
const parts = [];
|
|
570
|
-
const seen = /* @__PURE__ */ new Set();
|
|
571
|
-
let current = error;
|
|
572
|
-
for (let depth = 0; depth < 5 && current != null && !seen.has(current); depth++) {
|
|
573
|
-
seen.add(current);
|
|
574
|
-
if (current instanceof Error) {
|
|
575
|
-
if (current.message) parts.push(current.message);
|
|
576
|
-
} else try {
|
|
577
|
-
parts.push(String(current));
|
|
578
|
-
} catch {}
|
|
579
|
-
current = current?.cause;
|
|
580
|
-
}
|
|
581
|
-
return parts.join("\n");
|
|
582
|
-
}
|
|
583
|
-
function isIamPropagationError(message) {
|
|
584
|
-
if (isExplicitDenyError(message)) return false;
|
|
585
|
-
return IAM_PROPAGATION_ERROR_MESSAGE_PATTERNS.some((p) => message.includes(p));
|
|
586
|
-
}
|
|
587
|
-
const EXPLICIT_DENY_PHRASE = "with an explicit deny";
|
|
588
|
-
const EXPLICIT_DENY_POLICY_KINDS = [
|
|
589
|
-
"service control policy",
|
|
590
|
-
"resource control policy",
|
|
591
|
-
"identity-based policy",
|
|
592
|
-
"resource-based policy",
|
|
593
|
-
"permissions boundary",
|
|
594
|
-
"session policy",
|
|
595
|
-
"VPC endpoint policy",
|
|
596
|
-
"role trust policy"
|
|
597
|
-
];
|
|
598
|
-
function isExplicitDenyError(message) {
|
|
599
|
-
return message.includes(EXPLICIT_DENY_PHRASE);
|
|
600
|
-
}
|
|
601
|
-
function explicitDenyPolicyKind(message) {
|
|
602
|
-
const at = message.indexOf(EXPLICIT_DENY_PHRASE);
|
|
603
|
-
if (at < 0) return void 0;
|
|
604
|
-
const rest = message.slice(at + 21);
|
|
605
|
-
const article = /^ in (?:a|an|the) /.exec(rest);
|
|
606
|
-
if (article === null) return void 0;
|
|
607
|
-
const tail = rest.slice(article[0].length);
|
|
608
|
-
return EXPLICIT_DENY_POLICY_KINDS.find((kind) => tail.startsWith(kind));
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
// src/utils/regexp.ts
|
|
612
|
-
function escapeRegExp(value) {
|
|
613
|
-
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
614
|
-
}
|
|
615
|
-
function stripControlChars(value) {
|
|
616
|
-
return value.replace(/[\u0000-\u001f\u007f-\u009f\u200e\u200f\u202a-\u202e\u2066-\u2069]/g, "");
|
|
617
|
-
}
|
|
618
|
-
function stripForDisplay(value) {
|
|
619
|
-
return displaySafe(stripControlChars(value));
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
// src/deployment/retryable-errors/name-collision.ts
|
|
623
|
-
const ALREADY_EXISTS_CODE = /(?<![-:/])\b[A-Za-z0-9]*AlreadyExists(?:Exception|Fault)?\b(?!-)/;
|
|
624
|
-
function isNameCollisionError(message) {
|
|
625
|
-
return /(?<!\b(?:must|not|should|may|cannot)\s)already exists?\b/i.test(message) || ALREADY_EXISTS_CODE.test(message);
|
|
626
|
-
}
|
|
627
|
-
function relayedNameCollision(withheldText) {
|
|
628
|
-
return isNameCollisionError(withheldText) ? " AWS reports that it already exists." : "";
|
|
629
|
-
}
|
|
630
|
-
const NAME_COLLISION_ERROR_NAMES = /* @__PURE__ */ new Set([
|
|
631
|
-
"DuplicateTargetGroupNameException",
|
|
632
|
-
"DuplicateLoadBalancerNameException",
|
|
633
|
-
"DuplicateTrustStoreNameException"
|
|
634
|
-
]);
|
|
635
|
-
const NAME_COLLISION_MARKER = Symbol.for("cdkd.nameCollision");
|
|
636
|
-
function markNameCollision(error) {
|
|
637
|
-
if (!Object.isExtensible(error)) return error;
|
|
638
|
-
Object.defineProperty(error, NAME_COLLISION_MARKER, {
|
|
639
|
-
value: true,
|
|
640
|
-
enumerable: false,
|
|
641
|
-
configurable: true
|
|
642
|
-
});
|
|
643
|
-
return error;
|
|
644
|
-
}
|
|
645
|
-
const REPLAY_MAY_COLLIDE_MARKER = Symbol.for("cdkd.replayMayCollide");
|
|
646
|
-
function markReplayMayCollide(error) {
|
|
647
|
-
try {
|
|
648
|
-
if (typeof error !== "object" && typeof error !== "function" || error === null || !Object.isExtensible(error)) return error;
|
|
649
|
-
Object.defineProperty(error, REPLAY_MAY_COLLIDE_MARKER, {
|
|
650
|
-
value: true,
|
|
651
|
-
enumerable: false,
|
|
652
|
-
configurable: true,
|
|
653
|
-
writable: false
|
|
654
|
-
});
|
|
655
|
-
} catch {}
|
|
656
|
-
return error;
|
|
657
|
-
}
|
|
658
|
-
function hasReplayMayCollide(error) {
|
|
659
|
-
try {
|
|
660
|
-
let current = error;
|
|
661
|
-
for (let depth = 0; depth < 5 && (typeof current === "object" || typeof current === "function") && current !== null; depth++) {
|
|
662
|
-
if (Object.getOwnPropertyDescriptor(current, REPLAY_MAY_COLLIDE_MARKER)?.value === true) return true;
|
|
663
|
-
current = current.cause;
|
|
664
|
-
}
|
|
665
|
-
} catch {}
|
|
666
|
-
return false;
|
|
667
|
-
}
|
|
668
|
-
function isNameCollisionErrorFrom(error, logicalId) {
|
|
669
|
-
if (hasReplayMayCollide(error)) return false;
|
|
670
|
-
return relaysNameCollision(error, logicalId, () => false);
|
|
671
|
-
}
|
|
672
|
-
function isReplayedNameCollisionFrom(error, logicalId, isRetryAnchor) {
|
|
673
|
-
if (!hasReplayMayCollide(error)) return false;
|
|
674
|
-
return relaysNameCollision(error, logicalId, isRetryAnchor);
|
|
675
|
-
}
|
|
676
|
-
function relaysNameCollision(error, logicalId, isRetryAnchor) {
|
|
677
|
-
const topRelaysIt = error instanceof Error && typeof error.message === "string" && isNameCollisionError(error.message);
|
|
678
|
-
let current = error;
|
|
679
|
-
for (let depth = 0; depth < 5 && current != null; depth++) {
|
|
680
|
-
const link = current;
|
|
681
|
-
if (typeof link.logicalId === "string" && link.logicalId !== logicalId && !isRetryAnchor(current)) return false;
|
|
682
|
-
if (typeof link.name === "string" && NAME_COLLISION_ERROR_NAMES.has(link.name)) return true;
|
|
683
|
-
if (link.ccErrorCode === "AlreadyExists") return true;
|
|
684
|
-
if (link[NAME_COLLISION_MARKER] === true) return true;
|
|
685
|
-
if (topRelaysIt && current instanceof Error && isAwsAuthoredFailure(current) && typeof link.message === "string" && isNameCollisionError(link.message)) return true;
|
|
686
|
-
current = link.cause;
|
|
687
|
-
}
|
|
688
|
-
return false;
|
|
689
|
-
}
|
|
690
|
-
function isNameCooldownError(message) {
|
|
691
|
-
return NAME_COOLDOWN_ERROR_MESSAGE_PATTERNS.some((p) => message.includes(p));
|
|
692
|
-
}
|
|
693
|
-
const REDACTED_ALREADY_EXISTS_CLASS = new RegExp(`\\b[A-Za-z0-9]*AlreadyExists(?:Exception|Fault)?(?=\\. ${escapeRegExp(VERBOSE_POINTER)})`, "g");
|
|
694
|
-
function isRecreateRetryableError(message, error) {
|
|
695
|
-
return isNameCollisionError(error !== void 0 && hasRedactedCause(error) ? message.replace(REDACTED_ALREADY_EXISTS_CLASS, "") : message) || isNameCooldownError(message);
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
// src/deployment/retryable-errors/update-unsupported.ts
|
|
699
|
-
const CC_UNSUPPORTED_ACTION_ERROR_NAME = "UnsupportedActionException";
|
|
700
|
-
function isUpdateUnsupportedError(error, logicalId) {
|
|
701
|
-
if (error?.name === "ResourceUpdateNotSupportedError") return false;
|
|
702
|
-
let current = error;
|
|
703
|
-
for (let depth = 0; current !== null && current !== void 0 && depth < 5; depth++) {
|
|
704
|
-
const link = current;
|
|
705
|
-
if (typeof link.logicalId === "string" && link.logicalId !== logicalId) return false;
|
|
706
|
-
if (link.name === "UnsupportedActionException") return true;
|
|
707
|
-
if (link.ccErrorCode === "UnsupportedActionException" && link.ccOperation === "UPDATE") return true;
|
|
708
|
-
current = link.cause;
|
|
709
|
-
}
|
|
710
|
-
return false;
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
// src/utils/error-handler/deploy-errors.ts
|
|
714
|
-
var DependencyError = class DependencyError extends CdkdError {
|
|
715
|
-
constructor(message, cause) {
|
|
716
|
-
super(message, "DEPENDENCY_ERROR", cause);
|
|
717
|
-
this.name = "DependencyError";
|
|
718
|
-
Object.setPrototypeOf(this, DependencyError.prototype);
|
|
719
|
-
}
|
|
720
|
-
};
|
|
721
|
-
var ConfigError = class ConfigError extends CdkdError {
|
|
722
|
-
constructor(message, cause) {
|
|
723
|
-
super(message, "CONFIG_ERROR", cause);
|
|
724
|
-
this.name = "ConfigError";
|
|
725
|
-
Object.setPrototypeOf(this, ConfigError.prototype);
|
|
726
|
-
}
|
|
727
|
-
};
|
|
728
|
-
var PartialFailureError = class PartialFailureError extends CdkdError {
|
|
729
|
-
exitCode = 2;
|
|
730
|
-
constructor(message, cause) {
|
|
731
|
-
super(message, "PARTIAL_FAILURE", cause);
|
|
732
|
-
this.name = "PartialFailureError";
|
|
733
|
-
Object.setPrototypeOf(this, PartialFailureError.prototype);
|
|
734
|
-
}
|
|
735
|
-
};
|
|
736
|
-
var ResourceUpdateNotSupportedError = class ResourceUpdateNotSupportedError extends CdkdError {
|
|
737
|
-
exitCode = 2;
|
|
738
|
-
resourceType;
|
|
739
|
-
logicalId;
|
|
740
|
-
suggestion;
|
|
741
|
-
constructor(resourceType, logicalId, suggestion, cause) {
|
|
742
|
-
super(`${resourceType} (${logicalId}) cannot be updated in place: ${suggestion ? suggestion : "use cdkd deploy with --replace, or change the resource definition to create a new version"}.`, "RESOURCE_UPDATE_NOT_SUPPORTED", cause);
|
|
743
|
-
this.resourceType = resourceType;
|
|
744
|
-
this.logicalId = logicalId;
|
|
745
|
-
this.suggestion = suggestion;
|
|
746
|
-
this.name = "ResourceUpdateNotSupportedError";
|
|
747
|
-
Object.setPrototypeOf(this, ResourceUpdateNotSupportedError.prototype);
|
|
748
|
-
markNonRetryable(this);
|
|
749
|
-
}
|
|
750
|
-
};
|
|
751
|
-
var StackTerminationProtectionError = class StackTerminationProtectionError extends CdkdError {
|
|
752
|
-
stackName;
|
|
753
|
-
constructor(stackName, cause, account, recorded) {
|
|
754
|
-
if (recorded !== void 0) {
|
|
755
|
-
const { command, root, stackRegion } = recorded;
|
|
756
|
-
const bypass = pasteableCommand(command, [
|
|
757
|
-
{
|
|
758
|
-
value: stackName,
|
|
759
|
-
hole: "stack",
|
|
760
|
-
opts: {
|
|
761
|
-
plainIdent: true,
|
|
762
|
-
...command === "cdkd destroy" && { patternMatched: true }
|
|
763
|
-
}
|
|
764
|
-
},
|
|
765
|
-
...stackRegion !== void 0 && command === "cdkd state destroy" ? [{
|
|
766
|
-
flag: "--stack-region",
|
|
767
|
-
value: stackRegion,
|
|
768
|
-
hole: "region",
|
|
769
|
-
opts: { plainIdent: true }
|
|
770
|
-
}] : [],
|
|
771
|
-
{ literal: "--remove-protection" },
|
|
772
|
-
...account?.args ?? []
|
|
773
|
-
]);
|
|
774
|
-
super((root === void 0 ? `Stack ${quotedOrDescribed(stackName, "stack name")} was last deployed with terminationProtection: true and cannot be destroyed.` : `Stack ${quotedOrDescribed(stackName, "stack name")} is nested under ${quotedOrDescribed(root, "stack name")}, which was last deployed with terminationProtection: true, so it cannot be destroyed.`) + (command === "cdkd destroy" ? ` Redeploy it with the protection off, or pass --remove-protection to destroy it anyway;` : ` To destroy it anyway, pass --remove-protection;`) + ` the flag also turns off the deletion protection of each resource it deletes.` + withheldTargetClause(bypass, "stack", command, "This stack's name") + (account?.clause ? ` ${account.clause.trimEnd()}` : "") + `\nDestroy it with: ${bypass.command}`, "STACK_TERMINATION_PROTECTION", cause);
|
|
775
|
-
this.stackName = stackName;
|
|
776
|
-
this.name = "StackTerminationProtectionError";
|
|
777
|
-
Object.setPrototypeOf(this, StackTerminationProtectionError.prototype);
|
|
778
|
-
return;
|
|
779
|
-
}
|
|
780
|
-
const retry = pasteableCommand("cdkd destroy", [{
|
|
781
|
-
value: stackName,
|
|
782
|
-
hole: "stack",
|
|
783
|
-
opts: {
|
|
784
|
-
patternMatched: true,
|
|
785
|
-
plainIdent: true
|
|
786
|
-
}
|
|
787
|
-
}, ...account?.args ?? []]);
|
|
788
|
-
super(`Stack ${quotedOrDescribed(stackName, "stack name")} has terminationProtection: true and cannot be destroyed. Set terminationProtection: false in the CDK code, redeploy, then retry the destroy.` + withheldTargetClause(retry, "stack", "cdkd destroy", "This stack's name") + (account?.clause ? ` ${account.clause.trimEnd()}` : "") + `\nRetry with: ${retry.command}`, "STACK_TERMINATION_PROTECTION", cause);
|
|
789
|
-
this.stackName = stackName;
|
|
790
|
-
this.name = "StackTerminationProtectionError";
|
|
791
|
-
Object.setPrototypeOf(this, StackTerminationProtectionError.prototype);
|
|
792
|
-
}
|
|
793
|
-
};
|
|
794
|
-
var NestedStackChildDirectDestroyError = class NestedStackChildDirectDestroyError extends CdkdError {
|
|
795
|
-
stackName;
|
|
796
|
-
parentStack;
|
|
797
|
-
parentLogicalId;
|
|
798
|
-
constructor(stackName, parentStack, parentLogicalId, cause, account) {
|
|
799
|
-
const accountArgs = account?.args ?? [];
|
|
800
|
-
const logicalIdSuffix = parentLogicalId ? ` (parent's logical id: ${plainOrDescribed(parentLogicalId, "logical id")})` : "";
|
|
801
|
-
const cascade = pasteableCommand("cdkd destroy", [{
|
|
802
|
-
value: parentStack,
|
|
803
|
-
hole: "parent",
|
|
804
|
-
opts: {
|
|
805
|
-
patternMatched: true,
|
|
806
|
-
plainIdent: true
|
|
807
|
-
}
|
|
808
|
-
}, ...accountArgs]);
|
|
809
|
-
const childDestroy = pasteableCommand("cdkd state destroy", [{
|
|
810
|
-
value: stackName,
|
|
811
|
-
hole: "stack",
|
|
812
|
-
opts: { plainIdent: true }
|
|
813
|
-
}, ...accountArgs]);
|
|
814
|
-
const withheld = withheldTargetClause(cascade, "parent", "cdkd destroy", "The parent stack's name") + withheldTargetClause(childDestroy, "stack", "cdkd state destroy", "The child stack's name") + (account?.clause ? ` ${account.clause.trimEnd()}` : "");
|
|
815
|
-
const child = quotedOrDescribed(stackName, "stack name");
|
|
816
|
-
const parent = quotedOrDescribed(parentStack, "stack name");
|
|
817
|
-
super(`Stack ${child} is a nested child of ${parent}${logicalIdSuffix}; directly destroying a nested stack is not supported. Either cascade-delete this child along with its parent, or destroy the child on its own — which deletes its AWS resources and its record, and leaves the parent's reference dangling (the synth-free escape hatch).${withheld}\nCascade-delete with: ${cascade.command}\nDestroy the child alone with: ${childDestroy.command}`, "NESTED_STACK_CHILD_DIRECT_DESTROY", cause);
|
|
818
|
-
this.stackName = stackName;
|
|
819
|
-
this.parentStack = parentStack;
|
|
820
|
-
if (parentLogicalId !== void 0) this.parentLogicalId = parentLogicalId;
|
|
821
|
-
this.name = "NestedStackChildDirectDestroyError";
|
|
822
|
-
Object.setPrototypeOf(this, NestedStackChildDirectDestroyError.prototype);
|
|
823
|
-
}
|
|
824
|
-
};
|
|
825
|
-
function exportNamePhrase(exportName) {
|
|
826
|
-
const shown = plainIdentOr(exportName, "");
|
|
827
|
-
return shown ? `export '${shown}'` : "an export whose name is not a plain identifier";
|
|
828
|
-
}
|
|
829
|
-
var StackHasActiveImportsError = class StackHasActiveImportsError extends CdkdError {
|
|
830
|
-
exitCode = 2;
|
|
831
|
-
producerStack;
|
|
832
|
-
producerRegion;
|
|
833
|
-
consumers;
|
|
834
|
-
constructor(producerStack, producerRegion, consumers, cause) {
|
|
835
|
-
const lines = consumers.map((c) => ` - ${plainOrDescribed(c.consumerStack, "stack name")} (${plainOrDescribed(c.consumerRegion, "region")}): imports ${exportNamePhrase(c.exportName)}`);
|
|
836
|
-
super(`Cannot destroy stack ${quotedOrDescribed(producerStack, "stack name")} (${plainOrDescribed(producerRegion, "region")}): the following stacks still import its outputs via Fn::ImportValue:\n${lines.join("\n")}\n\nThis matches CloudFormation's strong-reference semantics — exports are\nprotected as long as a consumer references them.\n\nTo proceed:\n 1. Destroy the consumer first: cdkd destroy <consumer-stack>\n 2. Or remove the Fn::ImportValue from the consumer's template\n (e.g. inline the value, or refactor) and re-deploy the consumer,\n then retry this destroy.\n\nNote: cdkd's Fn::GetStackOutput intrinsic is a weak alternative that\ndoes NOT protect the producer — use it when you intentionally want\nthe producer to be deletable independently of consumers.`, "STACK_HAS_ACTIVE_IMPORTS", cause);
|
|
837
|
-
this.producerStack = producerStack;
|
|
838
|
-
this.producerRegion = producerRegion;
|
|
839
|
-
this.consumers = consumers;
|
|
840
|
-
this.name = "StackHasActiveImportsError";
|
|
841
|
-
Object.setPrototypeOf(this, StackHasActiveImportsError.prototype);
|
|
842
|
-
}
|
|
843
|
-
};
|
|
844
|
-
|
|
845
|
-
// src/utils/error-handler/command-errors.ts
|
|
846
|
-
var LocalStartServiceError = class LocalStartServiceError extends CdkdError {
|
|
847
|
-
constructor(message, cause) {
|
|
848
|
-
super(message, "LOCAL_START_SERVICE_ERROR", cause);
|
|
849
|
-
this.name = "LocalStartServiceError";
|
|
850
|
-
Object.setPrototypeOf(this, LocalStartServiceError.prototype);
|
|
851
|
-
}
|
|
852
|
-
};
|
|
853
|
-
var MacroExpansionError = class MacroExpansionError extends CdkdError {
|
|
854
|
-
exitCode = 2;
|
|
855
|
-
constructor(message, cause) {
|
|
856
|
-
super(message, "MACRO_EXPANSION_ERROR", cause);
|
|
857
|
-
this.name = "MacroExpansionError";
|
|
858
|
-
Object.setPrototypeOf(this, MacroExpansionError.prototype);
|
|
859
|
-
}
|
|
860
|
-
};
|
|
861
|
-
|
|
862
|
-
// src/utils/error-handler/format.ts
|
|
863
|
-
function isCdkdError(error) {
|
|
864
|
-
return error instanceof CdkdError;
|
|
865
|
-
}
|
|
866
|
-
function formatError(error) {
|
|
867
|
-
if (isCdkdError(error)) {
|
|
868
|
-
let message = `${error.name}: ${error.message}`;
|
|
869
|
-
if (error.cause) {
|
|
870
|
-
const cause = displayAwsMessage(error.cause.message);
|
|
871
|
-
if (cause) message += `\nCaused by: ${cause}`;
|
|
872
|
-
}
|
|
873
|
-
return message;
|
|
874
|
-
}
|
|
875
|
-
if (error instanceof Error) return `${error.name}: ${error.message}`;
|
|
876
|
-
return safeStringify(error);
|
|
877
|
-
}
|
|
878
|
-
function handleError(error) {
|
|
879
|
-
const logger = getLogger();
|
|
880
|
-
const silent = error instanceof CdkdError && error.silent;
|
|
881
|
-
if (isSoftAbort(error)) logger.warn(error.message);
|
|
882
|
-
else if (!silent) logger.error(formatError(error));
|
|
883
|
-
if (error instanceof Error && error.stack) logger.debug("Stack trace:", error.stack);
|
|
884
|
-
const customExitCode = error instanceof CdkdError ? error.exitCode : void 0;
|
|
885
|
-
const exitCode = typeof customExitCode === "number" ? customExitCode : 1;
|
|
886
|
-
process.exit(exitCode);
|
|
887
|
-
}
|
|
888
|
-
function withErrorHandling(fn) {
|
|
889
|
-
return async (...args) => {
|
|
890
|
-
try {
|
|
891
|
-
await fn(...args);
|
|
892
|
-
} catch (error) {
|
|
893
|
-
handleError(error);
|
|
894
|
-
}
|
|
895
|
-
};
|
|
896
|
-
}
|
|
897
|
-
|
|
898
|
-
// src/utils/error-handler/normalize-aws.ts
|
|
899
|
-
function bucketNames(bucket) {
|
|
900
|
-
if (bucket === void 0) return {
|
|
901
|
-
subject: "Bucket '<unknown bucket>'",
|
|
902
|
-
object: "bucket '<unknown bucket>'",
|
|
903
|
-
quoted: "'<unknown bucket>'"
|
|
904
|
-
};
|
|
905
|
-
if (isPasteableIdent(bucket)) return {
|
|
906
|
-
subject: `Bucket '${bucket}'`,
|
|
907
|
-
object: `bucket '${bucket}'`,
|
|
908
|
-
quoted: `'${bucket}'`
|
|
909
|
-
};
|
|
910
|
-
const described = "a bucket whose name is not a plain identifier";
|
|
911
|
-
return {
|
|
912
|
-
subject: "A bucket whose name is not a plain identifier",
|
|
913
|
-
object: described,
|
|
914
|
-
quoted: described
|
|
915
|
-
};
|
|
916
|
-
}
|
|
917
|
-
function normalizeAwsError(err, context = {}) {
|
|
918
|
-
if (!(err instanceof Error)) return new Error(safeStringify(err), { cause: err });
|
|
919
|
-
if (!(err.name === "Unknown" || err.message === "UnknownError")) return err;
|
|
920
|
-
const status = err.$metadata?.httpStatusCode;
|
|
921
|
-
const bucket = bucketNames(context.bucket);
|
|
922
|
-
const operation = context.operation ?? "operation";
|
|
923
|
-
switch (status) {
|
|
924
|
-
case 301: {
|
|
925
|
-
const responseHeaders = err.$response?.headers;
|
|
926
|
-
const region = responseHeaders?.["x-amz-bucket-region"] ?? responseHeaders?.["X-Amz-Bucket-Region"];
|
|
927
|
-
const where = region ? ` (in ${region})` : "";
|
|
928
|
-
return new Error(`${bucket.subject}${where} is in a different region than the client. cdkd resolves this automatically; if you see this message, please report it.`, { cause: err });
|
|
929
|
-
}
|
|
930
|
-
case 403: return new Error(`Access denied to ${bucket.object}. Verify credentials and bucket policy.`, { cause: err });
|
|
931
|
-
case 404: return new Error(`${bucket.subject} does not exist.`, { cause: err });
|
|
932
|
-
default: {
|
|
933
|
-
const statusStr = status !== void 0 ? `HTTP ${status}` : "unknown HTTP status";
|
|
934
|
-
return new Error(`S3 error during ${operation} on ${bucket.quoted} (${statusStr}). See CloudTrail for details.`, { cause: err });
|
|
935
|
-
}
|
|
936
|
-
}
|
|
937
|
-
}
|
|
938
|
-
|
|
939
|
-
// src/utils/ambient-client-defaults.ts
|
|
940
|
-
function ambientCredentialConfig() {
|
|
941
|
-
return getAwsClients()?.credentialConfig ?? {};
|
|
942
|
-
}
|
|
943
|
-
function clientDefaultsFor(credentialConfig, ignoreAssumedRole) {
|
|
944
|
-
return {
|
|
945
|
-
...awsClientDefaults({
|
|
946
|
-
profile: credentialConfig.profile,
|
|
947
|
-
...ignoreAssumedRole !== void 0 && { ignoreAssumedRole }
|
|
948
|
-
}),
|
|
949
|
-
...credentialConfig.profile && { profile: credentialConfig.profile },
|
|
950
|
-
...credentialConfig.credentials && { credentials: { ...credentialConfig.credentials } }
|
|
951
|
-
};
|
|
952
|
-
}
|
|
953
|
-
function ambientClientDefaults() {
|
|
954
|
-
return clientDefaultsFor(ambientCredentialConfig());
|
|
955
|
-
}
|
|
956
|
-
function credentialFingerprint(credentialConfig) {
|
|
957
|
-
return JSON.stringify([credentialConfig.profile ?? null, credentialConfig.credentials?.accessKeyId ?? null]);
|
|
958
|
-
}
|
|
959
|
-
|
|
960
6
|
// src/utils/pasteable-aws-profile.ts
|
|
961
7
|
let explicitProfile;
|
|
962
8
|
function setPasteableAwsProfile(profile) {
|
|
@@ -1493,57 +539,6 @@ function interruptWatchListenerCount() {
|
|
|
1493
539
|
return sharedSigintHandler === void 0 ? 0 : 1;
|
|
1494
540
|
}
|
|
1495
541
|
|
|
1496
|
-
// src/utils/elapsed-budget.ts
|
|
1497
|
-
const monotonicNowMs = typeof globalThis.performance?.now === "function" ? () => globalThis.performance.now() : () => Date.now();
|
|
1498
|
-
var ElapsedBudget = class {
|
|
1499
|
-
totalMs;
|
|
1500
|
-
clock;
|
|
1501
|
-
startedAt;
|
|
1502
|
-
constructor(totalMs, clock = monotonicNowMs) {
|
|
1503
|
-
if (!Number.isFinite(totalMs) || totalMs <= 0) throw new RangeError(`ElapsedBudget: totalMs must be a positive finite number (got ${totalMs})`);
|
|
1504
|
-
this.totalMs = totalMs;
|
|
1505
|
-
this.clock = clock;
|
|
1506
|
-
this.startedAt = clock();
|
|
1507
|
-
}
|
|
1508
|
-
elapsedMs() {
|
|
1509
|
-
return Math.max(0, this.clock() - this.startedAt);
|
|
1510
|
-
}
|
|
1511
|
-
remainingMs() {
|
|
1512
|
-
return Math.max(0, this.totalMs - this.elapsedMs());
|
|
1513
|
-
}
|
|
1514
|
-
isExhausted() {
|
|
1515
|
-
return this.remainingMs() <= 0;
|
|
1516
|
-
}
|
|
1517
|
-
attemptsWithin(cap, perAttemptMs, minAttempts = 1) {
|
|
1518
|
-
if (!Number.isFinite(cap) || cap <= 0) return 0;
|
|
1519
|
-
if (!Number.isFinite(perAttemptMs) || perAttemptMs <= 0) return Math.min(minAttempts, cap);
|
|
1520
|
-
const affordable = Math.floor(this.remainingMs() / perAttemptMs);
|
|
1521
|
-
return Math.max(Math.min(minAttempts, cap), Math.min(cap, affordable));
|
|
1522
|
-
}
|
|
1523
|
-
};
|
|
1524
|
-
var ElapsedBudgetRegistry = class {
|
|
1525
|
-
budgets = /* @__PURE__ */ new Map();
|
|
1526
|
-
acquire(key, totalMs, clock = monotonicNowMs, reuseWithinMs) {
|
|
1527
|
-
const existing = this.budgets.get(key);
|
|
1528
|
-
if (existing) {
|
|
1529
|
-
if (!(reuseWithinMs !== void 0 && existing.elapsedMs() > reuseWithinMs)) return existing;
|
|
1530
|
-
this.budgets.delete(key);
|
|
1531
|
-
}
|
|
1532
|
-
const created = new ElapsedBudget(totalMs, clock);
|
|
1533
|
-
this.budgets.set(key, created);
|
|
1534
|
-
return created;
|
|
1535
|
-
}
|
|
1536
|
-
release(key) {
|
|
1537
|
-
this.budgets.delete(key);
|
|
1538
|
-
}
|
|
1539
|
-
get size() {
|
|
1540
|
-
return this.budgets.size;
|
|
1541
|
-
}
|
|
1542
|
-
clear() {
|
|
1543
|
-
this.budgets.clear();
|
|
1544
|
-
}
|
|
1545
|
-
};
|
|
1546
|
-
|
|
1547
542
|
// src/provisioning/replacement-protection-advice.ts
|
|
1548
543
|
const DELETION_PROTECTION_DOC_POINTER = "\"Deletion protection blocks a replacement, and deploy cannot clear it\" at https://cdkd.dev/cli-deploy-safety/#deletion-protection-blocks-a-replacement-and-deploy-cannot-clear-it";
|
|
1549
544
|
const UNNAMEABLE_ID_CLAUSE = "Then disable protection out of band, via the console: the physical id cdkd recorded for this resource cannot be reproduced safely on a command line (sanitizing would change it, so a command would act on a different resource, or it holds a character or prefix a pasted shell line, or the AWS CLI itself, would act on, or it is derived from a secret, which a pasted command would print).";
|
|
@@ -1604,7 +599,58 @@ function protectedReplacementAdvice(args) {
|
|
|
1604
599
|
return `${head} Then disable protection out of band — \`${command}\`, or via the console.${disable.caveat ? ` ${disable.caveat}` : ""} Then re-run with ${replaceFlags}.`;
|
|
1605
600
|
}
|
|
1606
601
|
|
|
1607
|
-
// src/
|
|
602
|
+
// src/utils/elapsed-budget.ts
|
|
603
|
+
const monotonicNowMs = typeof globalThis.performance?.now === "function" ? () => globalThis.performance.now() : () => Date.now();
|
|
604
|
+
var ElapsedBudget = class {
|
|
605
|
+
totalMs;
|
|
606
|
+
clock;
|
|
607
|
+
startedAt;
|
|
608
|
+
constructor(totalMs, clock = monotonicNowMs) {
|
|
609
|
+
if (!Number.isFinite(totalMs) || totalMs <= 0) throw new RangeError(`ElapsedBudget: totalMs must be a positive finite number (got ${totalMs})`);
|
|
610
|
+
this.totalMs = totalMs;
|
|
611
|
+
this.clock = clock;
|
|
612
|
+
this.startedAt = clock();
|
|
613
|
+
}
|
|
614
|
+
elapsedMs() {
|
|
615
|
+
return Math.max(0, this.clock() - this.startedAt);
|
|
616
|
+
}
|
|
617
|
+
remainingMs() {
|
|
618
|
+
return Math.max(0, this.totalMs - this.elapsedMs());
|
|
619
|
+
}
|
|
620
|
+
isExhausted() {
|
|
621
|
+
return this.remainingMs() <= 0;
|
|
622
|
+
}
|
|
623
|
+
attemptsWithin(cap, perAttemptMs, minAttempts = 1) {
|
|
624
|
+
if (!Number.isFinite(cap) || cap <= 0) return 0;
|
|
625
|
+
if (!Number.isFinite(perAttemptMs) || perAttemptMs <= 0) return Math.min(minAttempts, cap);
|
|
626
|
+
const affordable = Math.floor(this.remainingMs() / perAttemptMs);
|
|
627
|
+
return Math.max(Math.min(minAttempts, cap), Math.min(cap, affordable));
|
|
628
|
+
}
|
|
629
|
+
};
|
|
630
|
+
var ElapsedBudgetRegistry = class {
|
|
631
|
+
budgets = /* @__PURE__ */ new Map();
|
|
632
|
+
acquire(key, totalMs, clock = monotonicNowMs, reuseWithinMs) {
|
|
633
|
+
const existing = this.budgets.get(key);
|
|
634
|
+
if (existing) {
|
|
635
|
+
if (!(reuseWithinMs !== void 0 && existing.elapsedMs() > reuseWithinMs)) return existing;
|
|
636
|
+
this.budgets.delete(key);
|
|
637
|
+
}
|
|
638
|
+
const created = new ElapsedBudget(totalMs, clock);
|
|
639
|
+
this.budgets.set(key, created);
|
|
640
|
+
return created;
|
|
641
|
+
}
|
|
642
|
+
release(key) {
|
|
643
|
+
this.budgets.delete(key);
|
|
644
|
+
}
|
|
645
|
+
get size() {
|
|
646
|
+
return this.budgets.size;
|
|
647
|
+
}
|
|
648
|
+
clear() {
|
|
649
|
+
this.budgets.clear();
|
|
650
|
+
}
|
|
651
|
+
};
|
|
652
|
+
|
|
653
|
+
// src/provisioning/providers/deletion-protection-compensation/flip-record.ts
|
|
1608
654
|
var ProtectionFlipRegistry = class {
|
|
1609
655
|
records = /* @__PURE__ */ new Map();
|
|
1610
656
|
acquire(key, reuseWithinMs, clock = monotonicNowMs) {
|
|
@@ -1651,6 +697,97 @@ function isTerminalDeleteFailure(error) {
|
|
|
1651
697
|
const classify = retryClassificationText(error);
|
|
1652
698
|
return !(isRetryableTransientError(error, classify) || classify.includes("Too Many Requests"));
|
|
1653
699
|
}
|
|
700
|
+
|
|
701
|
+
// src/provisioning/providers/deletion-protection-compensation/final-snapshot-wait.ts
|
|
702
|
+
const PROTECTION_FLIP_RETRY_WAIT_MS = 6e5;
|
|
703
|
+
const FINAL_SNAPSHOT_SETTLE_WAIT_MS = 9e5;
|
|
704
|
+
const FINAL_SNAPSHOT_COMPENSATION_MARGIN_MS = 6e4;
|
|
705
|
+
const FLIP_TRANSITION_GRACE_MS = 3e4;
|
|
706
|
+
function finalSnapshotWaitBudgetMs(opts) {
|
|
707
|
+
const budgetMs = Math.min(opts.maxWaitMs ?? 9e5, opts.remainingMs - FINAL_SNAPSHOT_COMPENSATION_MARGIN_MS);
|
|
708
|
+
if (budgetMs <= 0) throw new Error(`--remove-protection turned DeletionProtection off, but the resource timeout leaves no time to wait for the ${opts.noun} to return to 'available', which the final snapshot its DeletionPolicy asks for needs. The delete was not sent and the guard is put back; re-run the destroy with a longer --resource-timeout`);
|
|
709
|
+
return budgetMs;
|
|
710
|
+
}
|
|
711
|
+
const TERMINAL_DB_STATUSES = /* @__PURE__ */ new Set([
|
|
712
|
+
"deleting",
|
|
713
|
+
"failed",
|
|
714
|
+
"stopped",
|
|
715
|
+
"storage-full",
|
|
716
|
+
"insufficient-capacity",
|
|
717
|
+
"restore-error"
|
|
718
|
+
]);
|
|
719
|
+
const PROCEED_DB_STATUSES = /* @__PURE__ */ new Set(["storage-optimization", "storage-initialization"]);
|
|
720
|
+
function isProceedDbStatus(status) {
|
|
721
|
+
return status === "available" || status !== void 0 && PROCEED_DB_STATUSES.has(status);
|
|
722
|
+
}
|
|
723
|
+
function isTerminalDbStatus(status) {
|
|
724
|
+
if (status === void 0) return false;
|
|
725
|
+
return TERMINAL_DB_STATUSES.has(status) || status.startsWith("inaccessible-") || status.startsWith("incompatible-") || status.endsWith("-failed");
|
|
726
|
+
}
|
|
727
|
+
function isTerminalDbWaitStatus(status) {
|
|
728
|
+
return status !== "inaccessible-encryption-credentials-recoverable" && isTerminalDbStatus(status);
|
|
729
|
+
}
|
|
730
|
+
async function settleBeforeFinalSnapshot(opts, startTime, budgetMs) {
|
|
731
|
+
const { noun, label, logicalId } = opts;
|
|
732
|
+
let delay = 5e3;
|
|
733
|
+
let graceSleptMs = 0;
|
|
734
|
+
let sawOff = false;
|
|
735
|
+
let sawTransitional = false;
|
|
736
|
+
for (;;) {
|
|
737
|
+
const current = await opts.read();
|
|
738
|
+
if (current === void 0) return;
|
|
739
|
+
const terminal = isTerminalDbStatus(current.status);
|
|
740
|
+
const operational = current.status !== "available" && isProceedDbStatus(current.status);
|
|
741
|
+
if (!isProceedDbStatus(current.status) && !terminal) sawTransitional = true;
|
|
742
|
+
if (current.deletionProtection === false) sawOff = true;
|
|
743
|
+
if (current.deletionProtection === false && (terminal || operational)) return;
|
|
744
|
+
if (current.deletionProtection === true && terminal) throw new Error(`--remove-protection turned DeletionProtection off, but the ${noun} still reads it ON in status '${current.status ?? "unknown"}', which does not change on its own, and the final snapshot its DeletionPolicy asks for needs it 'available'. The delete was not sent and the guard is put back; re-run the destroy once the ${noun} is 'available'`);
|
|
745
|
+
const settled = current.deletionProtection === false && current.status === "available";
|
|
746
|
+
const inGrace = !sawTransitional && graceSleptMs < 3e4;
|
|
747
|
+
if (settled && !inGrace) return;
|
|
748
|
+
const step = inGrace ? Math.min(delay, FLIP_TRANSITION_GRACE_MS - graceSleptMs) : delay;
|
|
749
|
+
if (Date.now() - startTime + step >= budgetMs) {
|
|
750
|
+
if (settled) return;
|
|
751
|
+
if (current.deletionProtection === false && current.status !== void 0 && current.status !== "modifying") return;
|
|
752
|
+
break;
|
|
753
|
+
}
|
|
754
|
+
opts.logger.debug(safeMsg`${label} ${logicalId}: waiting for the DeletionProtection change to settle before the final snapshot (status ${current.status ?? "unknown"})`);
|
|
755
|
+
await opts.sleep(step);
|
|
756
|
+
if (sawOff) graceSleptMs += step;
|
|
757
|
+
delay = Math.min(delay * 2, 1e4);
|
|
758
|
+
}
|
|
759
|
+
throw new Error(`--remove-protection turned DeletionProtection off, but the ${noun} did not return to 'available' within ${Math.max(1, Math.round(budgetMs / 6e4))} minutes, and the final snapshot its DeletionPolicy asks for needs it. The delete was not sent and the guard is put back; re-run the destroy once the ${noun} is 'available'`);
|
|
760
|
+
}
|
|
761
|
+
function isFinalSnapshotNotAvailableRefusal(error, stateFault) {
|
|
762
|
+
if (!(error instanceof Error) || error.name !== stateFault) return false;
|
|
763
|
+
return /(?:isn't|is not|isn’t) (?:currently )?in (?:the )?available state/i.test(error.message);
|
|
764
|
+
}
|
|
765
|
+
async function deleteAfterProtectionFlipWithFinalSnapshot(opts) {
|
|
766
|
+
const budgetMs = finalSnapshotWaitBudgetMs(opts);
|
|
767
|
+
const startTime = Date.now();
|
|
768
|
+
await settleBeforeFinalSnapshot(opts, startTime, budgetMs);
|
|
769
|
+
let delay = 5e3;
|
|
770
|
+
let refusals = 0;
|
|
771
|
+
for (;;) try {
|
|
772
|
+
await opts.send();
|
|
773
|
+
return;
|
|
774
|
+
} catch (error) {
|
|
775
|
+
if (!isFinalSnapshotNotAvailableRefusal(error, opts.stateFault)) throw error;
|
|
776
|
+
refusals += 1;
|
|
777
|
+
opts.logger.debug(safeMsg`${opts.label} ${opts.logicalId}: final-snapshot delete refused as not 'available' (refusal ${String(refusals)}); waiting for it to return to 'available' before retrying`);
|
|
778
|
+
for (;;) {
|
|
779
|
+
if (Date.now() - startTime + delay >= budgetMs) throw error;
|
|
780
|
+
await opts.sleep(delay);
|
|
781
|
+
delay = Math.min(delay * 2, 1e4);
|
|
782
|
+
const current = await opts.read();
|
|
783
|
+
if (current === void 0) break;
|
|
784
|
+
if (current.deletionProtection === false && isProceedDbStatus(current.status)) break;
|
|
785
|
+
if (current.deletionProtection === true || isTerminalDbStatus(current.status)) throw error;
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
// src/provisioning/providers/deletion-protection-compensation.ts
|
|
1654
791
|
function rdsFamilyProtectionSite(opts) {
|
|
1655
792
|
return {
|
|
1656
793
|
subject: `${opts.serviceLabel} ${opts.kind === "cluster" ? "DBCluster" : "DBInstance"}`,
|
|
@@ -1786,93 +923,6 @@ async function settleProtectionFlip(opts) {
|
|
|
1786
923
|
}
|
|
1787
924
|
return false;
|
|
1788
925
|
}
|
|
1789
|
-
const PROTECTION_FLIP_RETRY_WAIT_MS = 6e5;
|
|
1790
|
-
const FINAL_SNAPSHOT_SETTLE_WAIT_MS = 9e5;
|
|
1791
|
-
const FINAL_SNAPSHOT_COMPENSATION_MARGIN_MS = 6e4;
|
|
1792
|
-
const FLIP_TRANSITION_GRACE_MS = 3e4;
|
|
1793
|
-
function finalSnapshotWaitBudgetMs(opts) {
|
|
1794
|
-
const budgetMs = Math.min(opts.maxWaitMs ?? 9e5, opts.remainingMs - FINAL_SNAPSHOT_COMPENSATION_MARGIN_MS);
|
|
1795
|
-
if (budgetMs <= 0) throw new Error(`--remove-protection turned DeletionProtection off, but the resource timeout leaves no time to wait for the ${opts.noun} to return to 'available', which the final snapshot its DeletionPolicy asks for needs. The delete was not sent and the guard is put back; re-run the destroy with a longer --resource-timeout`);
|
|
1796
|
-
return budgetMs;
|
|
1797
|
-
}
|
|
1798
|
-
const TERMINAL_DB_STATUSES = /* @__PURE__ */ new Set([
|
|
1799
|
-
"deleting",
|
|
1800
|
-
"failed",
|
|
1801
|
-
"stopped",
|
|
1802
|
-
"storage-full",
|
|
1803
|
-
"insufficient-capacity",
|
|
1804
|
-
"restore-error"
|
|
1805
|
-
]);
|
|
1806
|
-
const PROCEED_DB_STATUSES = /* @__PURE__ */ new Set(["storage-optimization", "storage-initialization"]);
|
|
1807
|
-
function isProceedDbStatus(status) {
|
|
1808
|
-
return status === "available" || status !== void 0 && PROCEED_DB_STATUSES.has(status);
|
|
1809
|
-
}
|
|
1810
|
-
function isTerminalDbStatus(status) {
|
|
1811
|
-
if (status === void 0) return false;
|
|
1812
|
-
return TERMINAL_DB_STATUSES.has(status) || status.startsWith("inaccessible-") || status.startsWith("incompatible-") || status.endsWith("-failed");
|
|
1813
|
-
}
|
|
1814
|
-
function isTerminalDbWaitStatus(status) {
|
|
1815
|
-
return status !== "inaccessible-encryption-credentials-recoverable" && isTerminalDbStatus(status);
|
|
1816
|
-
}
|
|
1817
|
-
async function settleBeforeFinalSnapshot(opts, startTime, budgetMs) {
|
|
1818
|
-
const { noun, label, logicalId } = opts;
|
|
1819
|
-
let delay = 5e3;
|
|
1820
|
-
let graceSleptMs = 0;
|
|
1821
|
-
let sawOff = false;
|
|
1822
|
-
let sawTransitional = false;
|
|
1823
|
-
for (;;) {
|
|
1824
|
-
const current = await opts.read();
|
|
1825
|
-
if (current === void 0) return;
|
|
1826
|
-
const terminal = isTerminalDbStatus(current.status);
|
|
1827
|
-
const operational = current.status !== "available" && isProceedDbStatus(current.status);
|
|
1828
|
-
if (!isProceedDbStatus(current.status) && !terminal) sawTransitional = true;
|
|
1829
|
-
if (current.deletionProtection === false) sawOff = true;
|
|
1830
|
-
if (current.deletionProtection === false && (terminal || operational)) return;
|
|
1831
|
-
if (current.deletionProtection === true && terminal) throw new Error(`--remove-protection turned DeletionProtection off, but the ${noun} still reads it ON in status '${current.status ?? "unknown"}', which does not change on its own, and the final snapshot its DeletionPolicy asks for needs it 'available'. The delete was not sent and the guard is put back; re-run the destroy once the ${noun} is 'available'`);
|
|
1832
|
-
const settled = current.deletionProtection === false && current.status === "available";
|
|
1833
|
-
const inGrace = !sawTransitional && graceSleptMs < 3e4;
|
|
1834
|
-
if (settled && !inGrace) return;
|
|
1835
|
-
const step = inGrace ? Math.min(delay, FLIP_TRANSITION_GRACE_MS - graceSleptMs) : delay;
|
|
1836
|
-
if (Date.now() - startTime + step >= budgetMs) {
|
|
1837
|
-
if (settled) return;
|
|
1838
|
-
if (current.deletionProtection === false && current.status !== void 0 && current.status !== "modifying") return;
|
|
1839
|
-
break;
|
|
1840
|
-
}
|
|
1841
|
-
opts.logger.debug(safeMsg`${label} ${logicalId}: waiting for the DeletionProtection change to settle before the final snapshot (status ${current.status ?? "unknown"})`);
|
|
1842
|
-
await opts.sleep(step);
|
|
1843
|
-
if (sawOff) graceSleptMs += step;
|
|
1844
|
-
delay = Math.min(delay * 2, 1e4);
|
|
1845
|
-
}
|
|
1846
|
-
throw new Error(`--remove-protection turned DeletionProtection off, but the ${noun} did not return to 'available' within ${Math.max(1, Math.round(budgetMs / 6e4))} minutes, and the final snapshot its DeletionPolicy asks for needs it. The delete was not sent and the guard is put back; re-run the destroy once the ${noun} is 'available'`);
|
|
1847
|
-
}
|
|
1848
|
-
function isFinalSnapshotNotAvailableRefusal(error, stateFault) {
|
|
1849
|
-
if (!(error instanceof Error) || error.name !== stateFault) return false;
|
|
1850
|
-
return /(?:isn't|is not|isn’t) (?:currently )?in (?:the )?available state/i.test(error.message);
|
|
1851
|
-
}
|
|
1852
|
-
async function deleteAfterProtectionFlipWithFinalSnapshot(opts) {
|
|
1853
|
-
const budgetMs = finalSnapshotWaitBudgetMs(opts);
|
|
1854
|
-
const startTime = Date.now();
|
|
1855
|
-
await settleBeforeFinalSnapshot(opts, startTime, budgetMs);
|
|
1856
|
-
let delay = 5e3;
|
|
1857
|
-
let refusals = 0;
|
|
1858
|
-
for (;;) try {
|
|
1859
|
-
await opts.send();
|
|
1860
|
-
return;
|
|
1861
|
-
} catch (error) {
|
|
1862
|
-
if (!isFinalSnapshotNotAvailableRefusal(error, opts.stateFault)) throw error;
|
|
1863
|
-
refusals += 1;
|
|
1864
|
-
opts.logger.debug(safeMsg`${opts.label} ${opts.logicalId}: final-snapshot delete refused as not 'available' (refusal ${String(refusals)}); waiting for it to return to 'available' before retrying`);
|
|
1865
|
-
for (;;) {
|
|
1866
|
-
if (Date.now() - startTime + delay >= budgetMs) throw error;
|
|
1867
|
-
await opts.sleep(delay);
|
|
1868
|
-
delay = Math.min(delay * 2, 1e4);
|
|
1869
|
-
const current = await opts.read();
|
|
1870
|
-
if (current === void 0) break;
|
|
1871
|
-
if (current.deletionProtection === false && isProceedDbStatus(current.status)) break;
|
|
1872
|
-
if (current.deletionProtection === true || isTerminalDbStatus(current.status)) throw error;
|
|
1873
|
-
}
|
|
1874
|
-
}
|
|
1875
|
-
}
|
|
1876
926
|
|
|
1877
927
|
// src/provisioning/not-gone.ts
|
|
1878
928
|
const NOT_GONE = Symbol.for("cdkd.notGone");
|
|
@@ -2351,5 +1401,5 @@ function removalWarning(logicalId, resourceType, unhandled, caller = "deploy") {
|
|
|
2351
1401
|
return caller === "rollback" ? safeMsg`${logicalId} (${resourceType}): ${names} ${one ? "is" : "are"} absent from the state being restored; the rollback leaves the value the failed deploy applied in place (CloudFormation would reset it to its default).` : safeMsg`${logicalId} (${resourceType}): ${names} ${one ? "was" : "were"} removed from the template; cdkd leaves the current AWS value in place (CloudFormation would reset it to its default).`;
|
|
2352
1402
|
}
|
|
2353
1403
|
|
|
2354
|
-
export {
|
|
2355
|
-
//# sourceMappingURL=update-removal-
|
|
1404
|
+
export { deleteAfterProtectionFlipWithFinalSnapshot as $, forceQuitRecoveryClause as $t, setBounded as A, segmentAfterAnchor as At, resolveExplicitPhysicalId as B, clearCreatedBeforeFailure as Bt, AmbiguousCreateLatch as C, canonicalizeRoute53QueryName as Ct, isInsideWindow as D, logicalIdShown as Dt, createAttemptKey as E, compositeIdSkipResult as Et, isQuotableImportValue as F, maskDeep as Ft, compensateProtectionFlip as G, isAuxiliaryMarkOf as Gt, assertRegionMatch as H, createdResourceIdentityBeforeFailure as Ht, normalizeAwsTagsToCfn as I, maskerOrIdentity as It, observeThenDisableProtection as J, markSupersedesEarlierCreate as Jt, deleteWithProtectionCompensation as K, markAuxiliaryFailure as Kt, quotedRemedyLogicalId as L, withDerivedNameMasks as Lt, VALUE_NOT_SHOWN as M, createMaskedLogSinks as Mt, isPlainImportJson as N, createMaskedRetryLogger as Nt, replayFollowedAmbiguousAttempt as O, packCompositeId as Ot, isPlainImportValue as P, isSecretDerivedValue as Pt, PROTECTION_FLIP_RETRY_WAIT_MS as Q, buildLockContentionMessage as Qt, refusalTypeShown as R, RETRY_AUXILIARY_OWNER as Rt, AMBIGUOUS_LATCH_TTL_MS as S, startInterruptWatch as St, ambiguousAttemptLead as T, compositeIdSeparatorRefusal as Tt, isMarkedNotGone as U, hasCreatedBeforeFailure as Ut, RESOURCE_NOT_FOUND as V, createdBeforeFailure as Vt, markNotGone as W, isAuxiliaryFailure as Wt, settleProtectionFlip as X, UNREPRODUCIBLE_LOCK_CLAUSE as Xt, rdsFamilyProtectionSite as Y, replayMadeAnotherResource as Yt, userPoolProtectionSite as Z, buildForceUnlockCommand as Zt, onlySecretDerived as _, renderDisableCommand as _t, withRemovalDefaults as a, CUSTOM_RESOURCE_RESPONSE_PREFIX as an, isTerminalDeleteFailure as at, recordedPrincipalsRepair as b, interruptWatchListenerCount as bt, clearCreatedReport as c, injectiveKeyPrefix as cn, ElapsedBudget as ct, reportedCreatedResource as d, setPasteableAwsProfile as dn, DELETION_PROTECTION_DOC_POINTER as dt, formatLockExpiry as en, isFinalSnapshotNotAvailableRefusal as et, retractCreatedResource as f, withPasteableAwsProfile as fn, UNNAMEABLE_ID_CLAUSE as ft, holdsSecretDerivedEntry as g, protectedReplacementAdvice as gt, SECRET_DERIVED_READ_LIVE as h, pasteableAwsCommand as ht, removedTemplateKeys as i, sanitizeRecoveryValue as in, ProtectionFlipRegistry as it, withoutServerErrorRetries as j, stateOrphanRecordRemedy as jt, replayedSendWindow as k, resourceTypeShown as kt, collectCreatedResources as l, producerCoordinateKey as ln, ElapsedBudgetRegistry as lt, RESOLVED_PREVIOUS_PRINCIPAL_KEYS as m, isAwsCliLiteral as mt, prepareRemovalForUpdate as n, formatLockOwner as nn, isTerminalDbWaitStatus as nt, withoutInjectedRemovals as o, DEFAULT_STATE_PREFIX as on, protectionFlipKey as ot, IAM_PRINCIPAL_NAME as p, WITHHELD_AWS_COMMAND as pt, logGroupProtectionSite as q, markCreatedBeforeFailure as qt, removalWarning as r, recoveryCommandFlags as rn, PROTECTION_FLIP_REUSE_WINDOW_MS as rt, CreatedResourceSink as s, injectiveKey as sn, runDeleteAttempt as st, clearOnUpdateRemoval as t, formatLockOperation as tn, isProceedDbStatus as tt, reportCreatedResource as u, producerRecordKey as un, monotonicNowMs as ut, readPrincipalLists as v, beginCommandInterruptScope as vt, RecentIdSet as w, compositeIdFormatMessage as wt, withUnchangedSecretPrincipalLists as x, isInterruptedWaitError as xt, readRecordedPrincipals as y, endCommandInterruptScope as yt, remedyLogicalId as z, carryCreatedBeforeFailure as zt };
|
|
1405
|
+
//# sourceMappingURL=update-removal-Dh6W86TO.js.map
|