@cdkd/cli 0.373.1 → 0.373.3

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.
Files changed (74) hide show
  1. package/dist/{ambient-client-defaults-BLKND30a.js → ambient-client-defaults-ChOenyD2.js} +18 -4
  2. package/dist/ambient-client-defaults-ChOenyD2.js.map +1 -0
  3. package/dist/{asg-provider-DXL1CE4m.js → asg-provider-Bfinx42n.js} +8 -8
  4. package/dist/{asg-provider-DXL1CE4m.js.map → asg-provider-Bfinx42n.js.map} +1 -1
  5. package/dist/cli.js +3 -3
  6. package/dist/{replacement-rules-BkUZIP44.js → created-resource-sink-D7iM5jwM.js} +1394 -1474
  7. package/dist/created-resource-sink-D7iM5jwM.js.map +1 -0
  8. package/dist/{custom-resource-runtime-DK4-5kRC.js → custom-resource-runtime-9fjsDVrs.js} +6 -6
  9. package/dist/{custom-resource-runtime-DK4-5kRC.js.map → custom-resource-runtime-9fjsDVrs.js.map} +1 -1
  10. package/dist/{db-associated-roles-zv71gI1O.js → db-associated-roles-Bn8HCQ2r.js} +2 -2
  11. package/dist/{db-associated-roles-zv71gI1O.js.map → db-associated-roles-Bn8HCQ2r.js.map} +1 -1
  12. package/dist/{delete-started-E38sSyUX.js → delete-started-CiTP5c3_.js} +4 -4
  13. package/dist/{delete-started-E38sSyUX.js.map → delete-started-CiTP5c3_.js.map} +1 -1
  14. package/dist/{deploy-engine-BDueF79_.js → deploy-engine-D7Iv9v8e.js} +3573 -2888
  15. package/dist/deploy-engine-D7Iv9v8e.js.map +1 -0
  16. package/dist/{ec2-termination-protection-DI-aPxET.js → ec2-termination-protection-BXy91mrW.js} +3 -3
  17. package/dist/{ec2-termination-protection-DI-aPxET.js.map → ec2-termination-protection-BXy91mrW.js.map} +1 -1
  18. package/dist/{ecr-uri-kW_K5U02.js → ecr-uri-DUDwEekn.js} +2 -2
  19. package/dist/{ecr-uri-kW_K5U02.js.map → ecr-uri-DUDwEekn.js.map} +1 -1
  20. package/dist/{emr-cluster-provider-BcqnxYsN.js → emr-cluster-provider-MokUAEGh.js} +11 -11
  21. package/dist/emr-cluster-provider-MokUAEGh.js.map +1 -0
  22. package/dist/{expected-bucket-owner-j5BCLzAB.js → expected-bucket-owner-BrzB1C4p.js} +2 -2
  23. package/dist/{expected-bucket-owner-j5BCLzAB.js.map → expected-bucket-owner-BrzB1C4p.js.map} +1 -1
  24. package/dist/{iam-role-provider-BlUbRjQo.js → iam-role-provider-CB--BYVm.js} +12 -12
  25. package/dist/{iam-role-provider-BlUbRjQo.js.map → iam-role-provider-CB--BYVm.js.map} +1 -1
  26. package/dist/{identity-read-denied-BhnkMyxk.js → identity-read-denied-CoeMBkCz.js} +5 -6
  27. package/dist/identity-read-denied-CoeMBkCz.js.map +1 -0
  28. package/dist/{image-plan-CUvO0Qe2.js → image-plan-RNp8hqc4.js} +8 -8
  29. package/dist/{image-plan-CUvO0Qe2.js.map → image-plan-RNp8hqc4.js.map} +1 -1
  30. package/dist/index.d.ts +13 -1
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +5 -5
  33. package/dist/{logger-B673mhBe.js → logger-Bfz63gW5.js} +2 -2
  34. package/dist/{logger-B673mhBe.js.map → logger-Bfz63gW5.js.map} +1 -1
  35. package/dist/{neptune-provider-BOIjF_i3.js → neptune-provider-BFwovty1.js} +9 -9
  36. package/dist/{neptune-provider-BOIjF_i3.js.map → neptune-provider-BFwovty1.js.map} +1 -1
  37. package/dist/{program-avOxa_7W.js → program-DR3X8-7x.js} +563 -233
  38. package/dist/program-DR3X8-7x.js.map +1 -0
  39. package/dist/{provider-classes-BMrkl7zN.js → provider-classes-BNZGFwNO.js} +375 -129
  40. package/dist/provider-classes-BNZGFwNO.js.map +1 -0
  41. package/dist/{rds-provider-DD8ka8NG.js → rds-provider-evebINWq.js} +13 -13
  42. package/dist/{rds-provider-DD8ka8NG.js.map → rds-provider-evebINWq.js.map} +1 -1
  43. package/dist/{read-replica-Ddvkib9A.js → read-replica-BGoRAh10.js} +3 -3
  44. package/dist/{read-replica-Ddvkib9A.js.map → read-replica-BGoRAh10.js.map} +1 -1
  45. package/dist/{redacted-delete-address-CkcTwr-O.js → redacted-delete-address-rTL8ikg4.js} +5 -5
  46. package/dist/redacted-delete-address-rTL8ikg4.js.map +1 -0
  47. package/dist/replacement-rules-roVU6gYR.js +1967 -0
  48. package/dist/replacement-rules-roVU6gYR.js.map +1 -0
  49. package/dist/{resource-deadline-B2z0yyKo.js → resource-deadline-B4Rp-3f7.js} +2 -2
  50. package/dist/{resource-deadline-B2z0yyKo.js.map → resource-deadline-B4Rp-3f7.js.map} +1 -1
  51. package/dist/{restore-source-guard-1UD7ucv5.js → restore-source-guard-Dz_vQPiM.js} +5 -5
  52. package/dist/restore-source-guard-Dz_vQPiM.js.map +1 -0
  53. package/dist/{run-cli-Dm2l-FUd.js → run-cli-vKsR6JeT.js} +2 -2
  54. package/dist/{run-cli-Dm2l-FUd.js.map → run-cli-vKsR6JeT.js.map} +1 -1
  55. package/dist/{secret-reference-immutable-Bk60ZfqH.js → secret-reference-immutable-BF02Wobz.js} +108 -10
  56. package/dist/{secret-reference-immutable-Bk60ZfqH.js.map → secret-reference-immutable-BF02Wobz.js.map} +1 -1
  57. package/dist/{settle-own-write-members-YQxWAEvB.js → settle-own-write-members-CF-RPYMD.js} +10 -10
  58. package/dist/{settle-own-write-members-YQxWAEvB.js.map → settle-own-write-members-CF-RPYMD.js.map} +1 -1
  59. package/dist/{tag-list-C8pMq_W3.js → tag-list-DbmXev9Z.js} +4 -4
  60. package/dist/{tag-list-C8pMq_W3.js.map → tag-list-DbmXev9Z.js.map} +1 -1
  61. package/dist/{version-D2qdiEuf.js → version-CP9RYTCy.js} +2 -2
  62. package/dist/{version-D2qdiEuf.js.map → version-CP9RYTCy.js.map} +1 -1
  63. package/package.json +1 -1
  64. package/dist/ambient-client-defaults-BLKND30a.js.map +0 -1
  65. package/dist/created-resource-sink-DlVo2nqB.js +0 -1397
  66. package/dist/created-resource-sink-DlVo2nqB.js.map +0 -1
  67. package/dist/deploy-engine-BDueF79_.js.map +0 -1
  68. package/dist/emr-cluster-provider-BcqnxYsN.js.map +0 -1
  69. package/dist/identity-read-denied-BhnkMyxk.js.map +0 -1
  70. package/dist/program-avOxa_7W.js.map +0 -1
  71. package/dist/provider-classes-BMrkl7zN.js.map +0 -1
  72. package/dist/redacted-delete-address-CkcTwr-O.js.map +0 -1
  73. package/dist/replacement-rules-BkUZIP44.js.map +0 -1
  74. package/dist/restore-source-guard-1UD7ucv5.js.map +0 -1
@@ -0,0 +1,1967 @@
1
+ import { n as getLogger } from "./logger-Bfz63gW5.js";
2
+ import { Gn as recordLogOnlyValue, Jr as DYNAMIC_REFERENCE_TOKEN_SCAN, Oi as isPlainObject, Xr as dynamicReferenceTokens, Yr as dynamicReferenceSpans, an as mentionsMask, ii as carriesSecretMask, ki as isSingleDynamicReferenceToken, ri as splitGetAttStringForm, sn as opensDynamicReferenceTo, vr as identityKeyFor } from "./created-resource-sink-D7iM5jwM.js";
3
+ import { isDeepStrictEqual } from "node:util";
4
+
5
+ // src/deployment/secret-redaction/unresolved-token-frame.ts
6
+ function liveMatchesUnresolvedTokenFrame(send, live, unresolvedTokens, secrets) {
7
+ const wildcards = dynamicReferenceSpans(send).filter((span) => unresolvedTokens.has(send.slice(span.start, span.end)));
8
+ if (wildcards.length === 0) return false;
9
+ if (wildcardOverlapsResolvedPlaintext(send, wildcards, secrets)) return false;
10
+ const literals = [];
11
+ let at = 0;
12
+ for (const span of wildcards) {
13
+ literals.push(send.slice(at, span.start));
14
+ at = span.end;
15
+ }
16
+ literals.push(send.slice(at));
17
+ const first = literals[0];
18
+ const last = literals[literals.length - 1];
19
+ if (live.length < first.length + last.length) return false;
20
+ if (!live.startsWith(first) || !live.endsWith(last)) return false;
21
+ let pos = first.length;
22
+ const end = live.length - last.length;
23
+ for (let i = 1; i < literals.length - 1; i++) {
24
+ const literal = literals[i];
25
+ const found = live.indexOf(literal, pos);
26
+ if (found < 0 || found + literal.length > end) return false;
27
+ pos = found + literal.length;
28
+ }
29
+ return true;
30
+ }
31
+ function wildcardOverlapsResolvedPlaintext(send, wildcards, secrets) {
32
+ for (const plaintext of secrets.keys()) {
33
+ if (plaintext === "") continue;
34
+ for (let from = send.indexOf(plaintext); from >= 0; from = send.indexOf(plaintext, from + 1)) {
35
+ const to = from + plaintext.length;
36
+ if (wildcards.some((span) => span.start < to && from < span.end)) return true;
37
+ }
38
+ }
39
+ return false;
40
+ }
41
+
42
+ // src/deployment/secret-redaction/noecho-leaves.ts
43
+ const SUB_VARIABLE = /\$\{([^}!][^}]*)\}/g;
44
+ function intrinsicKeyOf(node) {
45
+ const keys = Object.keys(node);
46
+ if (keys.length !== 1) return void 0;
47
+ const key = keys[0];
48
+ return key === "Ref" || key.startsWith("Fn::") ? key : void 0;
49
+ }
50
+ function conditionVerdict(sources, name) {
51
+ if (typeof name !== "string" || sources.conditions === void 0) return void 0;
52
+ return Object.hasOwn(sources.conditions, name) ? sources.conditions[name] : void 0;
53
+ }
54
+ function getAttReadsNoEcho(argument, sources) {
55
+ if (sources.attributeIsNoEcho === void 0) return false;
56
+ let target;
57
+ let attribute;
58
+ if (typeof argument === "string") {
59
+ const dot = argument.indexOf(".");
60
+ if (dot <= 0) return false;
61
+ target = argument.slice(0, dot);
62
+ attribute = argument.slice(dot + 1);
63
+ } else if (Array.isArray(argument) && argument.length === 2) [target, attribute] = argument;
64
+ else return false;
65
+ if (typeof target !== "string") return false;
66
+ if (typeof attribute !== "string") return readsNoEchoSource(attribute, sources);
67
+ return sources.attributeIsNoEcho(target, attribute);
68
+ }
69
+ function subStringReadsNoEcho(text, variables, sources) {
70
+ for (const match of text.matchAll(SUB_VARIABLE)) {
71
+ const name = match[1].trim();
72
+ if (variables !== void 0 && Object.hasOwn(variables, name)) continue;
73
+ if (sources.parameters.has(name)) return true;
74
+ const dot = name.indexOf(".");
75
+ if (dot > 0 && sources.attributeIsNoEcho?.(name.slice(0, dot), name.slice(dot + 1)) === true) return true;
76
+ }
77
+ return false;
78
+ }
79
+ function readsNoEchoSource(node, sources) {
80
+ const seen = /* @__PURE__ */ new Set();
81
+ const walk = (value) => {
82
+ if (value === null || typeof value !== "object") return false;
83
+ if (seen.has(value)) return false;
84
+ seen.add(value);
85
+ if (Array.isArray(value)) return value.some(walk);
86
+ const record = value;
87
+ const intrinsic = intrinsicKeyOf(record);
88
+ if (intrinsic === "Ref") return typeof record["Ref"] === "string" && sources.parameters.has(record["Ref"]);
89
+ if (intrinsic === "Fn::GetAtt") return getAttReadsNoEcho(record["Fn::GetAtt"], sources);
90
+ if (intrinsic === "Fn::Sub") {
91
+ const argument = record["Fn::Sub"];
92
+ if (typeof argument === "string") return subStringReadsNoEcho(argument, void 0, sources);
93
+ if (Array.isArray(argument)) {
94
+ const [text, variables] = argument;
95
+ const vars = isPlainObject(variables) ? variables : void 0;
96
+ if (typeof text === "string" && subStringReadsNoEcho(text, vars, sources)) return true;
97
+ return vars !== void 0 && Object.values(vars).some(walk);
98
+ }
99
+ return walk(argument);
100
+ }
101
+ if (intrinsic === "Fn::If") {
102
+ const argument = record["Fn::If"];
103
+ if (Array.isArray(argument) && argument.length === 3) {
104
+ const verdict = conditionVerdict(sources, argument[0]);
105
+ if (verdict !== void 0) return walk(verdict ? argument[1] : argument[2]);
106
+ return walk(argument[1]) || walk(argument[2]);
107
+ }
108
+ return walk(argument);
109
+ }
110
+ return Object.values(record).some(walk);
111
+ };
112
+ return walk(node);
113
+ }
114
+ function literalIndex(index) {
115
+ if (typeof index === "number" && Number.isInteger(index)) return index;
116
+ if (typeof index === "string" && /^\d+$/.test(index)) return Number(index);
117
+ }
118
+ function noEchoCoordinatesOf(template, resolved, sources, onCoordinate) {
119
+ const coordinates = [];
120
+ const push = (path, node) => {
121
+ coordinates.push(path);
122
+ onCoordinate?.(path, node);
123
+ };
124
+ const ancestors = /* @__PURE__ */ new Set();
125
+ const parametersOnly = {
126
+ parameters: sources.parameters,
127
+ ...sources.conditions !== void 0 && { conditions: sources.conditions }
128
+ };
129
+ const isBareDeclaredGetAtt = (node) => isPlainObject(node) && intrinsicKeyOf(node) === "Fn::GetAtt" && getAttReadsNoEcho(node["Fn::GetAtt"], sources);
130
+ const walk = (source, value, path) => {
131
+ if (value === void 0) return;
132
+ if (source === null || typeof source !== "object") return;
133
+ if (ancestors.has(source)) return;
134
+ ancestors.add(source);
135
+ try {
136
+ if (Array.isArray(source)) {
137
+ if (!readsNoEchoSource(source, sources)) return;
138
+ if (Array.isArray(value) && value.length === source.length) source.forEach((item, index) => walk(item, value[index], [...path, index]));
139
+ else if (readsNoEchoSource(source, parametersOnly) || source.some(isBareDeclaredGetAtt)) push(path, source);
140
+ return;
141
+ }
142
+ const record = source;
143
+ const intrinsic = intrinsicKeyOf(record);
144
+ if (intrinsic === void 0) {
145
+ if (!isPlainObject(value)) {
146
+ if (readsNoEchoSource(record, parametersOnly)) push(path, source);
147
+ return;
148
+ }
149
+ for (const [key, child] of Object.entries(record)) if (Object.hasOwn(value, key)) walk(child, value[key], [...path, key]);
150
+ return;
151
+ }
152
+ if (intrinsic === "Fn::If") {
153
+ const argument = record["Fn::If"];
154
+ if (Array.isArray(argument) && argument.length === 3) {
155
+ const verdict = conditionVerdict(sources, argument[0]);
156
+ if (verdict !== void 0) {
157
+ walk(verdict ? argument[1] : argument[2], value, path);
158
+ return;
159
+ }
160
+ if (isBareDeclaredGetAtt(argument[1]) || isBareDeclaredGetAtt(argument[2])) {
161
+ push(path, source);
162
+ return;
163
+ }
164
+ }
165
+ }
166
+ if (intrinsic === "Fn::Select") {
167
+ const argument = record["Fn::Select"];
168
+ if (Array.isArray(argument) && argument.length === 2 && Array.isArray(argument[1])) {
169
+ const index = literalIndex(argument[0]);
170
+ const list = argument[1];
171
+ if (index !== void 0 && index < list.length) {
172
+ walk(list[index], value, path);
173
+ return;
174
+ }
175
+ }
176
+ }
177
+ if (intrinsic === "Fn::GetAtt") {
178
+ if (getAttReadsNoEcho(record["Fn::GetAtt"], sources)) push(path, source);
179
+ return;
180
+ }
181
+ if (readsNoEchoSource(record, parametersOnly)) push(path, source);
182
+ } finally {
183
+ ancestors.delete(source);
184
+ }
185
+ };
186
+ walk(template, resolved, []);
187
+ return coordinates;
188
+ }
189
+ function noEchoParameterNodesAt(templateProperties, shape, noEchoParameters, conditions) {
190
+ const nodes = /* @__PURE__ */ new Map();
191
+ noEchoCoordinatesOf(templateProperties ?? {}, shape, {
192
+ parameters: noEchoParameters,
193
+ ...conditions !== void 0 && { conditions }
194
+ }, (coordinate, node) => nodes.set(canonicalJson(coordinate), {
195
+ coordinate,
196
+ node
197
+ }));
198
+ return nodes;
199
+ }
200
+ function recordedNoEchoValuesOf(templateProperties, record, noEchoParameterNames, conditions) {
201
+ const bag = /* @__PURE__ */ new Map();
202
+ const properties = record?.properties;
203
+ if (properties === null || typeof properties !== "object") return bag;
204
+ const coordinates = /* @__PURE__ */ new Map();
205
+ if (noEchoParameterNames.size > 0 && templateProperties !== void 0) for (const [key, { coordinate }] of noEchoParameterNodesAt(templateProperties, properties, noEchoParameterNames, conditions)) coordinates.set(key, coordinate);
206
+ for (const coordinate of noEchoLeavesOf(record ?? {}) ?? []) coordinates.set(canonicalJson(coordinate), coordinate);
207
+ const recordLeaf = (leaf) => {
208
+ if (typeof leaf === "string") {
209
+ if (leaf === "***" || leaf.includes("{{resolve:")) return;
210
+ recordLogOnlyValue(bag, leaf);
211
+ } else if (typeof leaf === "number") recordLogOnlyValue(bag, String(leaf));
212
+ };
213
+ const seen = /* @__PURE__ */ new Set();
214
+ const walk = (value) => {
215
+ if (value === null || typeof value !== "object") {
216
+ recordLeaf(value);
217
+ return;
218
+ }
219
+ if (seen.has(value)) return;
220
+ seen.add(value);
221
+ for (const child of Object.values(value)) walk(child);
222
+ };
223
+ for (const coordinate of coordinates.values()) walk(valueAtCoordinate(properties, coordinate));
224
+ return bag;
225
+ }
226
+ function maskWholeValue(value) {
227
+ if (value === null || value === void 0) return value;
228
+ if (typeof value === "string" && isSingleDynamicReferenceToken(value)) return value;
229
+ if (Array.isArray(value)) return value.map(maskWholeValue);
230
+ if (isPlainObject(value)) {
231
+ const out = {};
232
+ for (const [key, child] of Object.entries(value)) Object.defineProperty(out, key, {
233
+ value: maskWholeValue(child),
234
+ enumerable: true,
235
+ writable: true,
236
+ configurable: true
237
+ });
238
+ return out;
239
+ }
240
+ return "***";
241
+ }
242
+ function readAt(bag, coordinate) {
243
+ let node = bag;
244
+ for (const segment of coordinate) {
245
+ if (typeof segment === "number") {
246
+ if (!Array.isArray(node) || segment >= node.length) return {
247
+ found: false,
248
+ value: void 0
249
+ };
250
+ node = node[segment];
251
+ continue;
252
+ }
253
+ if (!isPlainObject(node) || !Object.hasOwn(node, segment)) return {
254
+ found: false,
255
+ value: void 0
256
+ };
257
+ node = node[segment];
258
+ }
259
+ return {
260
+ found: true,
261
+ value: node
262
+ };
263
+ }
264
+ function valueAtCoordinate(bag, coordinate) {
265
+ return readAt(bag, coordinate).value;
266
+ }
267
+ function isWhollyMask(value) {
268
+ if (value === "***") return true;
269
+ if (Array.isArray(value)) return value.length > 0 && value.every(isWhollyMask);
270
+ if (value !== null && typeof value === "object") {
271
+ const children = Object.values(value);
272
+ return children.length > 0 && children.every(isWhollyMask);
273
+ }
274
+ return false;
275
+ }
276
+ function isStaleNoEchoLeaf(recorded, today, coordinate) {
277
+ if (!isWhollyMask(valueAtCoordinate(recorded, coordinate))) return false;
278
+ const value = valueAtCoordinate(today, coordinate);
279
+ return value !== void 0 && !carriesSecretMask(value);
280
+ }
281
+ function cloneContainer(node) {
282
+ if (Array.isArray(node)) return [...node];
283
+ if (isPlainObject(node)) return { ...node };
284
+ return node;
285
+ }
286
+ function maskAtCoordinates(bag, coordinates) {
287
+ if (coordinates.length === 0) return bag;
288
+ let root = bag;
289
+ for (const coordinate of coordinates) {
290
+ if (!readAt(root, coordinate).found) continue;
291
+ if (coordinate.length === 0) {
292
+ root = maskWholeValue(root);
293
+ continue;
294
+ }
295
+ root = cloneContainer(root);
296
+ let node = root;
297
+ for (let i = 0; i < coordinate.length - 1; i++) {
298
+ const segment = coordinate[i];
299
+ const next = cloneContainer(node[segment]);
300
+ node[segment] = next;
301
+ node = next;
302
+ }
303
+ const last = coordinate[coordinate.length - 1];
304
+ node[last] = maskWholeValue(node[last]);
305
+ }
306
+ return root;
307
+ }
308
+ function replaceAtCoordinates(bag, entries) {
309
+ let root = bag;
310
+ for (const { coordinate, value } of entries) {
311
+ if (!readAt(root, coordinate).found) continue;
312
+ if (coordinate.length === 0) {
313
+ root = value;
314
+ continue;
315
+ }
316
+ root = cloneContainer(root);
317
+ let node = root;
318
+ for (let i = 0; i <= coordinate.length - 1; i++) {
319
+ const segment = coordinate[i];
320
+ const next = i === coordinate.length - 1 ? value : cloneContainer(node[segment]);
321
+ if (typeof segment === "number") node[segment] = next;
322
+ else Object.defineProperty(node, segment, {
323
+ value: next,
324
+ enumerable: true,
325
+ writable: true,
326
+ configurable: true
327
+ });
328
+ node = next;
329
+ }
330
+ }
331
+ return root;
332
+ }
333
+ function maskReadbackAtCoordinates(readback, properties, coordinates) {
334
+ let result = readback;
335
+ for (const coordinate of coordinates) {
336
+ const target = readbackPathFor(result, properties, coordinate);
337
+ if (target !== void 0) result = maskAtCoordinates(result, [target]);
338
+ }
339
+ return result;
340
+ }
341
+ function readbackPathFor(readback, properties, coordinate) {
342
+ const path = [];
343
+ let live = readback;
344
+ let desired = properties;
345
+ for (const segment of coordinate) {
346
+ if (typeof segment === "number") {
347
+ if (!Array.isArray(live)) return path.length === 0 ? void 0 : path;
348
+ const key = Array.isArray(desired) ? identityKeyFor(live, desired) : void 0;
349
+ const element = Array.isArray(desired) ? desired[segment] : void 0;
350
+ if (key === void 0 || !isPlainObject(element)) return path;
351
+ const identity = element[key];
352
+ const index = live.findIndex((item) => isPlainObject(item) && item[key] === identity);
353
+ if (index < 0) return path;
354
+ path.push(index);
355
+ live = live[index];
356
+ desired = element;
357
+ continue;
358
+ }
359
+ if (!isPlainObject(live)) return path.length === 0 ? void 0 : path;
360
+ if (!Object.hasOwn(live, segment)) return void 0;
361
+ path.push(segment);
362
+ live = live[segment];
363
+ desired = isPlainObject(desired) ? desired[segment] : void 0;
364
+ }
365
+ return path;
366
+ }
367
+ function canonicalCoordinates(coordinates) {
368
+ const keyed = /* @__PURE__ */ new Map();
369
+ for (const coordinate of coordinates) keyed.set(JSON.stringify(coordinate), [...coordinate]);
370
+ const all = [...keyed.values()];
371
+ const covered = (inner) => all.some((outer) => outer.length < inner.length && outer.every((segment, i) => segment === inner[i]));
372
+ return all.filter((coordinate) => !covered(coordinate)).sort((a, b) => JSON.stringify(a).localeCompare(JSON.stringify(b)));
373
+ }
374
+ function noEchoLeavesOf(record) {
375
+ const field = record.noEchoLeaves;
376
+ if (!Array.isArray(field)) return void 0;
377
+ const out = [];
378
+ for (const entry of field) {
379
+ if (!Array.isArray(entry)) return void 0;
380
+ if (!entry.every((s) => typeof s === "string" || typeof s === "number" && Number.isInteger(s))) return void 0;
381
+ out.push(entry);
382
+ }
383
+ return out;
384
+ }
385
+ function isMarkedCoordinate(coordinate, marked) {
386
+ return marked.some((outer) => outer.length <= coordinate.length && outer.every((segment, i) => segment === coordinate[i]));
387
+ }
388
+ function witnessNormalize(stored, today, v11) {
389
+ const confirmed = [];
390
+ const differing = [];
391
+ const walk = (s, t, v, path) => {
392
+ if (v !== "***" && containsMask(v) && (Array.isArray(v) ? !Array.isArray(s) || s.length !== v.length : isPlainObject(v) ? !isPlainObject(s) : false)) {
393
+ if (s === void 0 || containsMask(s)) return s;
394
+ if (jsonEqual(s, t)) {
395
+ confirmed.push(path);
396
+ return v;
397
+ }
398
+ differing.push(path);
399
+ return s;
400
+ }
401
+ if (v === "***") {
402
+ if (s === void 0 || containsMask(s)) return s;
403
+ if (jsonEqual(s, t)) {
404
+ confirmed.push(path);
405
+ return v;
406
+ }
407
+ differing.push(path);
408
+ return s;
409
+ }
410
+ if (Array.isArray(v) && Array.isArray(s)) {
411
+ if (s.length !== v.length) return s;
412
+ const tt = Array.isArray(t) ? t : [];
413
+ let changed = false;
414
+ const out = s.map((item, i) => {
415
+ const next = walk(item, tt[i], v[i], [...path, i]);
416
+ if (next !== item) changed = true;
417
+ return next;
418
+ });
419
+ return changed ? out : s;
420
+ }
421
+ if (isPlainObject(v) && isPlainObject(s)) {
422
+ const tt = isPlainObject(t) ? t : {};
423
+ let out;
424
+ for (const key of Object.keys(v)) {
425
+ if (!Object.hasOwn(s, key)) continue;
426
+ const next = walk(s[key], tt[key], v[key], [...path, key]);
427
+ if (next !== s[key]) {
428
+ out ??= { ...s };
429
+ out[key] = next;
430
+ }
431
+ }
432
+ return out ?? s;
433
+ }
434
+ return s;
435
+ };
436
+ return {
437
+ current: walk(stored, today, v11, []),
438
+ confirmed,
439
+ differing
440
+ };
441
+ }
442
+ function containsMask(value) {
443
+ if (value === "***") return true;
444
+ if (Array.isArray(value)) return value.some(containsMask);
445
+ if (isPlainObject(value)) return Object.values(value).some(containsMask);
446
+ return false;
447
+ }
448
+ function jsonEqual(a, b) {
449
+ return canonicalJson(a) === canonicalJson(b);
450
+ }
451
+ function canonicalJson(value) {
452
+ return JSON.stringify(value, (_key, node) => {
453
+ if (node === null || typeof node !== "object" || Array.isArray(node)) return node;
454
+ const sorted = Object.create(null);
455
+ for (const key of Object.keys(node).sort()) sorted[key] = node[key];
456
+ return sorted;
457
+ });
458
+ }
459
+ const PREVIOUS_NOECHO_VALUE = "(previous NoEcho value)";
460
+ function noEchoParametersReadBy(node, sources) {
461
+ return [...sources.parameters].filter((name) => readsNoEchoSource(node, {
462
+ parameters: /* @__PURE__ */ new Set([name]),
463
+ ...sources.conditions !== void 0 && { conditions: sources.conditions }
464
+ }));
465
+ }
466
+ function noEchoComparison(options) {
467
+ const { sources, values, minNeedleLength, publicTokens } = options;
468
+ return ({ templateProperties, desired, current }) => {
469
+ const coordinates = noEchoCoordinatesOf(templateProperties, desired, sources);
470
+ const needles = [];
471
+ for (const name of noEchoParametersReadBy(templateProperties, sources)) {
472
+ const value = values[name];
473
+ const leaves = Array.isArray(value) ? value : [value];
474
+ for (const leaf of leaves) if (typeof leaf === "string" && leaf.length >= minNeedleLength && !isSingleDynamicReferenceToken(leaf)) needles.push(leaf);
475
+ }
476
+ if (coordinates.length === 0 && needles.length === 0) return void 0;
477
+ let masked = maskAtCoordinates(desired, coordinates);
478
+ if (needles.length > 0) {
479
+ const walk = (node) => {
480
+ if (typeof node === "string") {
481
+ if (node === "***") return node;
482
+ const outside = node.replace(DYNAMIC_REFERENCE_TOKEN_SCAN, "");
483
+ return needles.some((needle) => node === needle || publicTokens?.has(needle) !== true && outside.includes(needle)) ? "***" : node;
484
+ }
485
+ if (Array.isArray(node)) {
486
+ const out = node.map(walk);
487
+ return out.some((item, i) => item !== node[i]) ? out : node;
488
+ }
489
+ if (isPlainObject(node)) {
490
+ let out;
491
+ for (const [key, child] of Object.entries(node)) {
492
+ const next = walk(child);
493
+ if (next !== child) {
494
+ out ??= { ...node };
495
+ out[key] = next;
496
+ }
497
+ }
498
+ return out ?? node;
499
+ }
500
+ return node;
501
+ };
502
+ masked = walk(masked);
503
+ }
504
+ const witnessed = witnessNormalize(current, desired, masked);
505
+ const shown = maskAtCoordinatesWith(witnessed.current, witnessed.differing, PREVIOUS_NOECHO_VALUE);
506
+ return {
507
+ desired: masked,
508
+ current: shown
509
+ };
510
+ };
511
+ }
512
+ function maskAtCoordinatesWith(bag, coordinates, replacement) {
513
+ let root = bag;
514
+ for (const coordinate of coordinates) {
515
+ if (coordinate.length === 0 || !readAt(root, coordinate).found) continue;
516
+ root = cloneContainer(root);
517
+ let node = root;
518
+ for (let i = 0; i < coordinate.length - 1; i++) {
519
+ const segment = coordinate[i];
520
+ const next = cloneContainer(node[segment]);
521
+ node[segment] = next;
522
+ node = next;
523
+ }
524
+ node[coordinate[coordinate.length - 1]] = replacement;
525
+ }
526
+ return root;
527
+ }
528
+ function noEchoOutputsComparison(templateValues, sources) {
529
+ return (current, desired) => {
530
+ const coordinates = noEchoCoordinatesOf(templateValues, desired, sources);
531
+ const maskedKeys = new Set(coordinates.map((coordinate) => coordinate[0]).filter((key) => typeof key === "string"));
532
+ const maskedValues = new Set([...maskedKeys].map((key) => canonicalJson(desired[key])));
533
+ for (const key of Object.keys(desired)) if (!Object.hasOwn(templateValues, key) && maskedValues.has(canonicalJson(desired[key]))) maskedKeys.add(key);
534
+ if (maskedKeys.size === 0) return {
535
+ current,
536
+ desired,
537
+ masked: []
538
+ };
539
+ const maskedDesired = { ...desired };
540
+ for (const key of maskedKeys) maskedDesired[key] = maskWholeValue(desired[key]);
541
+ let normalized = current;
542
+ if (current !== void 0 && current !== null && typeof current === "object") for (const key of maskedKeys) {
543
+ if (!Object.hasOwn(current, key)) continue;
544
+ const stored = current[key];
545
+ if (containsMask(stored)) continue;
546
+ normalized = { ...normalized ?? {} };
547
+ normalized[key] = canonicalJson(stored) === canonicalJson(desired[key]) ? maskedDesired[key] : PREVIOUS_NOECHO_VALUE;
548
+ }
549
+ return {
550
+ current: normalized,
551
+ desired: maskedDesired,
552
+ masked: [...maskedKeys]
553
+ };
554
+ };
555
+ }
556
+ function maskedLeafCoordinatesOf(bag) {
557
+ const coordinates = [];
558
+ const ancestors = /* @__PURE__ */ new Set();
559
+ const walk = (node, path) => {
560
+ if (node === "***") {
561
+ coordinates.push(path);
562
+ return;
563
+ }
564
+ if (node === null || typeof node !== "object" || ancestors.has(node)) return;
565
+ ancestors.add(node);
566
+ if (Array.isArray(node)) node.forEach((item, index) => walk(item, [...path, index]));
567
+ else for (const [key, child] of Object.entries(node)) walk(child, [...path, key]);
568
+ ancestors.delete(node);
569
+ };
570
+ walk(bag, []);
571
+ return coordinates;
572
+ }
573
+ const passedNoEchoParameters = /* @__PURE__ */ new WeakMap();
574
+ function recordPassedNoEchoParameters(bag, parameters, sources) {
575
+ const names = /* @__PURE__ */ new Set();
576
+ if (sources !== void 0 && parameters !== null && typeof parameters === "object") {
577
+ for (const [name, value] of Object.entries(parameters)) if (readsNoEchoSource(value, sources)) names.add(name);
578
+ }
579
+ if (names.size > 0) passedNoEchoParameters.set(bag, names);
580
+ else passedNoEchoParameters.delete(bag);
581
+ }
582
+ function passedNoEchoParametersOf(bag) {
583
+ return bag === void 0 ? void 0 : passedNoEchoParameters.get(bag);
584
+ }
585
+
586
+ // src/deployment/secret-redaction/off-template-echo.ts
587
+ function secretReferenceTest(provenPublic) {
588
+ return (token) => opensDynamicReferenceTo(token, "ssm-secure") || opensDynamicReferenceTo(token, "secretsmanager") || opensDynamicReferenceTo(token, "ssm") && provenPublic?.(token) === void 0;
589
+ }
590
+ function observedMaskedLeavesOf(record) {
591
+ return noEchoLeavesOf({ noEchoLeaves: record.observedMaskedLeaves });
592
+ }
593
+ function withoutObservedMaskedLeaves(observed, record) {
594
+ const leaves = observedMaskedLeavesOf(record) ?? [];
595
+ if (leaves.length === 0) return observed;
596
+ return replaceAtCoordinates(observed, leaves.map((coordinate) => ({
597
+ coordinate,
598
+ value: null
599
+ })));
600
+ }
601
+ function plaintextFor(recorded, readback) {
602
+ if (typeof readback !== "string" || readback === recorded || mentionsMask(readback)) return;
603
+ const tokens = dynamicReferenceTokens(recorded);
604
+ if (tokens.length === 1) {
605
+ const at = recorded.indexOf(tokens[0]);
606
+ const prefix = recorded.slice(0, at);
607
+ const suffix = recorded.slice(at + tokens[0].length);
608
+ if (readback.length >= prefix.length + suffix.length && readback.startsWith(prefix) && readback.endsWith(suffix)) return readback.slice(prefix.length, readback.length - suffix.length);
609
+ return;
610
+ }
611
+ return tokens.length > 1 ? readback : void 0;
612
+ }
613
+ function secretReferenceLeaves(bag, isSecretReference) {
614
+ const out = [];
615
+ const walk = (node, path) => {
616
+ if (typeof node === "string") {
617
+ if (dynamicReferenceTokens(node).some((token) => isSecretReference(token))) out.push({
618
+ coordinate: path,
619
+ text: node
620
+ });
621
+ return;
622
+ }
623
+ if (Array.isArray(node)) {
624
+ node.forEach((item, i) => walk(item, [...path, i]));
625
+ return;
626
+ }
627
+ if (isPlainObject(node)) for (const [key, value] of Object.entries(node)) walk(value, [...path, key]);
628
+ };
629
+ walk(bag, []);
630
+ return out;
631
+ }
632
+ function corroborates(live, recorded, isSecretReference) {
633
+ if (typeof recorded === "string") {
634
+ if (mentionsMask(recorded)) return true;
635
+ if (dynamicReferenceTokens(recorded).some((token) => isSecretReference(token))) return typeof live === "string";
636
+ return live === recorded;
637
+ }
638
+ if (Array.isArray(recorded)) return Array.isArray(live) && live.length === recorded.length && recorded.every((item, i) => corroborates(live[i], item, isSecretReference));
639
+ if (isPlainObject(recorded)) return isPlainObject(live) && Object.entries(recorded).every(([key, value]) => Object.hasOwn(live, key) && corroborates(live[key], value, isSecretReference));
640
+ return live === recorded;
641
+ }
642
+ function listPairing(live, recorded, isSecretReference) {
643
+ const key = identityKeyFor(live, recorded);
644
+ if (key !== void 0) return (index) => {
645
+ const element = recorded[index];
646
+ if (!isPlainObject(element)) return void 0;
647
+ const found = live.findIndex((item) => isPlainObject(item) && item[key] === element[key]);
648
+ return found < 0 ? void 0 : found;
649
+ };
650
+ if (live.length === recorded.length && recorded.every((item, i) => corroborates(live[i], item, isSecretReference))) return (index) => index;
651
+ }
652
+ function readbackValueAt(readback, properties, coordinate, isSecretReference) {
653
+ let live = readback;
654
+ let recorded = properties;
655
+ for (const segment of coordinate) {
656
+ if (typeof segment === "number") {
657
+ if (!Array.isArray(live) || !Array.isArray(recorded)) return void 0;
658
+ const index = listPairing(live, recorded, isSecretReference)?.(segment);
659
+ if (index === void 0) return void 0;
660
+ live = live[index];
661
+ recorded = recorded[segment];
662
+ continue;
663
+ }
664
+ if (!isPlainObject(live) || !Object.hasOwn(live, segment)) return void 0;
665
+ live = live[segment];
666
+ recorded = isPlainObject(recorded) ? recorded[segment] : void 0;
667
+ }
668
+ return live;
669
+ }
670
+ function offTemplateEchoes(observed, properties, needles, isSecretReference) {
671
+ const hits = [];
672
+ const walk = (node, source, path, offTemplate) => {
673
+ if (typeof node === "string") {
674
+ if (offTemplate && needles.some((needle) => node.includes(needle))) hits.push(path);
675
+ return;
676
+ }
677
+ if (Array.isArray(node)) {
678
+ if (offTemplate) {
679
+ node.forEach((item, i) => walk(item, void 0, [...path, i], true));
680
+ return;
681
+ }
682
+ if (!Array.isArray(source)) return;
683
+ const pairing = listPairing(node, source, isSecretReference);
684
+ if (pairing === void 0) return;
685
+ source.forEach((item, i) => {
686
+ const index = pairing(i);
687
+ if (index !== void 0) walk(node[index], item, [...path, index], false);
688
+ });
689
+ return;
690
+ }
691
+ if (!isPlainObject(node)) return;
692
+ for (const [key, value] of Object.entries(node)) {
693
+ const absent = isPlainObject(source) && !Object.hasOwn(source, key);
694
+ walk(value, isPlainObject(source) ? source[key] : void 0, [...path, key], offTemplate || absent);
695
+ }
696
+ };
697
+ walk(observed, properties, [], false);
698
+ return hits;
699
+ }
700
+ function isOffTemplate(observed, properties, coordinate, isSecretReference) {
701
+ let live = observed;
702
+ let source = properties;
703
+ for (const segment of coordinate) {
704
+ if (typeof segment === "number") {
705
+ if (!Array.isArray(live) || !Array.isArray(source)) return false;
706
+ const pairing = listPairing(live, source, isSecretReference);
707
+ if (pairing === void 0) return false;
708
+ const recordedIndex = source.findIndex((_, i) => pairing(i) === segment);
709
+ if (recordedIndex < 0) return false;
710
+ live = live[segment];
711
+ source = source[recordedIndex];
712
+ continue;
713
+ }
714
+ if (!isPlainObject(source)) return false;
715
+ if (!Object.hasOwn(source, segment)) return true;
716
+ live = isPlainObject(live) ? live[segment] : void 0;
717
+ source = source[segment];
718
+ }
719
+ return false;
720
+ }
721
+ function maskOffTemplateEchoes(input) {
722
+ const { bag, properties, publicTokens } = input;
723
+ const readback = input.readback ?? bag;
724
+ const resolved = input.resolvedProperties ?? properties;
725
+ const physicalId = typeof input.physicalId === "string" ? input.physicalId : "";
726
+ const isSecretReference = secretReferenceTest(input.provenPublic);
727
+ const needles = /* @__PURE__ */ new Set();
728
+ const learn = (value) => {
729
+ if (typeof value !== "string" || value.length < 4) return;
730
+ if (mentionsMask(value)) return;
731
+ if (publicTokens?.has(value) === true || physicalId.includes(value)) return;
732
+ needles.add(value);
733
+ };
734
+ for (const coordinate of noEchoLeavesOf({ noEchoLeaves: input.noEchoLeaves }) ?? []) {
735
+ learn(readbackValueAt(readback, resolved, coordinate, isSecretReference));
736
+ learn(valueAtCoordinate(resolved, coordinate));
737
+ }
738
+ for (const { coordinate, text } of secretReferenceLeaves(properties, isSecretReference)) {
739
+ learn(plaintextFor(text, readbackValueAt(readback, properties, coordinate, isSecretReference)));
740
+ learn(plaintextFor(text, valueAtCoordinate(resolved, coordinate)));
741
+ }
742
+ const provenPublic = input.provenPublic;
743
+ if (provenPublic !== void 0) {
744
+ const proven = (token) => opensDynamicReferenceTo(token, "ssm") && provenPublic(token) !== void 0;
745
+ for (const { coordinate, text } of secretReferenceLeaves(properties, proven)) {
746
+ const tokens = dynamicReferenceTokens(text);
747
+ if (tokens.length !== 1) continue;
748
+ const live = plaintextFor(text, readbackValueAt(readback, properties, coordinate, isSecretReference));
749
+ if (live !== provenPublic(tokens[0])) learn(live);
750
+ }
751
+ }
752
+ const hits = (needles.size === 0 ? [] : offTemplateEchoes(readback, properties, [...needles], isSecretReference)).filter((coordinate) => {
753
+ const leaf = valueAtCoordinate(bag, coordinate);
754
+ if (leaf === void 0) return false;
755
+ return !(typeof leaf === "string" && !mentionsMask(leaf) && dynamicReferenceTokens(leaf).length > 0);
756
+ });
757
+ const masked = hits.length === 0 ? bag : maskAtCoordinates(bag, hits);
758
+ const kept = (observedMaskedLeavesOf({ observedMaskedLeaves: input.previous }) ?? []).filter((coordinate) => isOffTemplate(masked, properties, coordinate, isSecretReference) && coordinate.some((_, i) => isWhollyMask(valueAtCoordinate(masked, coordinate.slice(0, i + 1)))));
759
+ return {
760
+ bag: masked,
761
+ leaves: canonicalCoordinates([...kept, ...hits])
762
+ };
763
+ }
764
+ function withOffTemplateEchoesMasked(record, raw, publicTokens) {
765
+ const observed = record.observedProperties;
766
+ if (observed === void 0) {
767
+ if (record.observedMaskedLeaves === void 0) return record;
768
+ const next = { ...record };
769
+ delete next.observedMaskedLeaves;
770
+ return next;
771
+ }
772
+ const { bag, leaves } = maskOffTemplateEchoes({
773
+ bag: observed,
774
+ ...raw.readback !== void 0 && { readback: raw.readback },
775
+ properties: record.properties ?? {},
776
+ ...raw.properties !== void 0 && { resolvedProperties: raw.properties },
777
+ noEchoLeaves: record.noEchoLeaves,
778
+ physicalId: record.physicalId,
779
+ previous: record.observedMaskedLeaves,
780
+ publicTokens
781
+ });
782
+ const previous = JSON.stringify(observedMaskedLeavesOf(record) ?? []);
783
+ if (bag === observed && JSON.stringify(leaves) === previous) {
784
+ if (leaves.length === 0 && record.observedMaskedLeaves !== void 0) {
785
+ const next = { ...record };
786
+ delete next.observedMaskedLeaves;
787
+ return next;
788
+ }
789
+ return record;
790
+ }
791
+ const next = {
792
+ ...record,
793
+ observedProperties: bag
794
+ };
795
+ if (leaves.length > 0) next.observedMaskedLeaves = leaves;
796
+ else delete next.observedMaskedLeaves;
797
+ return next;
798
+ }
799
+
800
+ // src/deployment/secret-redaction/secret-attribute-keys.ts
801
+ function isCustomResourceType(resourceType) {
802
+ return typeof resourceType === "string" && (resourceType === "AWS::CloudFormation::CustomResource" || resourceType.startsWith("Custom::"));
803
+ }
804
+ const readsByTemplate = /* @__PURE__ */ new WeakMap();
805
+ function templateGetAttNamesOf(template, logicalId) {
806
+ let reads = readsByTemplate.get(template);
807
+ if (reads === void 0) {
808
+ reads = templateGetAttReadsOf(template);
809
+ readsByTemplate.set(template, reads);
810
+ }
811
+ return reads.get(logicalId) ?? /* @__PURE__ */ new Set();
812
+ }
813
+ function templateGetAttReadsOf(template) {
814
+ const reads = /* @__PURE__ */ new Map();
815
+ const seen = /* @__PURE__ */ new Set();
816
+ const add = (id, attribute) => {
817
+ const current = reads.get(id);
818
+ if (current === "any") return;
819
+ if (typeof attribute !== "string") {
820
+ reads.set(id, "any");
821
+ return;
822
+ }
823
+ if (current === void 0) reads.set(id, /* @__PURE__ */ new Set([attribute]));
824
+ else current.add(attribute);
825
+ };
826
+ const walk = (node) => {
827
+ if (node === null || typeof node !== "object" || seen.has(node)) return;
828
+ seen.add(node);
829
+ if (Array.isArray(node)) {
830
+ for (const item of node) walk(item);
831
+ return;
832
+ }
833
+ for (const [key, inner] of Object.entries(node)) {
834
+ if (key === "Fn::GetAtt") {
835
+ if (Array.isArray(inner) && typeof inner[0] === "string") add(inner[0], inner[1]);
836
+ else if (typeof inner === "string") {
837
+ const split = splitGetAttStringForm(inner);
838
+ if (split) add(split.logicalId, split.attributeName);
839
+ }
840
+ } else if (key === "Fn::Sub") {
841
+ const text = Array.isArray(inner) ? inner[0] : inner;
842
+ if (typeof text === "string") for (const match of text.matchAll(/\$\{([^}!][^}]*)\}/g)) {
843
+ const split = splitGetAttStringForm(match[1] ?? "");
844
+ if (split) add(split.logicalId, split.attributeName);
845
+ }
846
+ }
847
+ walk(inner);
848
+ }
849
+ };
850
+ walk(template);
851
+ return reads;
852
+ }
853
+ function withSecretAttributeKeysDropped(record, raw, secrets, getAttNames, publicTokens) {
854
+ const attributes = record.attributes;
855
+ if (!isCustomResourceType(record.resourceType) || !isPlainObject(attributes)) return record;
856
+ if (getAttNames === void 0 || getAttNames === "any") return record;
857
+ const physicalId = typeof record.physicalId === "string" ? record.physicalId : "";
858
+ const needles = /* @__PURE__ */ new Set();
859
+ const learn = (value) => {
860
+ if (typeof value !== "string" || value.length < 4 || mentionsMask(value)) return;
861
+ if (publicTokens?.has(value) === true || physicalId.includes(value)) return;
862
+ needles.add(value);
863
+ };
864
+ for (const plaintext of secrets?.keys() ?? []) learn(plaintext);
865
+ const declared = record.noEchoAttributeNames;
866
+ if (Array.isArray(declared) && isPlainObject(raw.attributes)) {
867
+ for (const name of declared) if (typeof name === "string" && Object.hasOwn(raw.attributes, name)) learn(raw.attributes[name]);
868
+ }
869
+ if (needles.size === 0) return record;
870
+ const dropped = Object.keys(attributes).filter((key) => !getAttNames.has(key) && [...needles].some((needle) => key.includes(needle)));
871
+ if (dropped.length === 0) return record;
872
+ const kept = {};
873
+ for (const [key, value] of Object.entries(attributes)) if (!dropped.includes(key)) Object.defineProperty(kept, key, {
874
+ value,
875
+ enumerable: true,
876
+ writable: true,
877
+ configurable: true
878
+ });
879
+ const next = {
880
+ ...record,
881
+ attributes: kept
882
+ };
883
+ if (Array.isArray(declared)) {
884
+ const names = declared.filter((name) => !dropped.includes(name));
885
+ if (names.length > 0) next.noEchoAttributeNames = names;
886
+ else delete next.noEchoAttributeNames;
887
+ }
888
+ return next;
889
+ }
890
+
891
+ // src/deployment/secret-redaction/stored-record-finish.ts
892
+ function storedRecordFinisher(template, publicTokens) {
893
+ return (record, needles, { logicalId, state }) => {
894
+ const masked = withOffTemplateEchoesMasked(record, {
895
+ ...state.properties !== void 0 && { properties: state.properties },
896
+ ...state.observedProperties !== void 0 && { readback: state.observedProperties }
897
+ }, publicTokens);
898
+ return withSecretAttributeKeysDropped(masked, masked, needles, templateGetAttNamesOf(template, logicalId), publicTokens);
899
+ };
900
+ }
901
+
902
+ // src/deployment/secret-redaction/stored-reference-positions.ts
903
+ function withStoredReferencePositionsMasked(record) {
904
+ const observed = record.observedProperties;
905
+ const properties = record.properties;
906
+ if (observed === void 0 || properties === void 0) return record;
907
+ const next = storedReferenceLeavesPutBack(observed, properties);
908
+ return next === observed ? record : {
909
+ ...record,
910
+ observedProperties: next
911
+ };
912
+ }
913
+ function storedReferenceLeavesPutBack(observed, properties) {
914
+ const isSecretReference = secretReferenceTest();
915
+ const restore = [];
916
+ const mask = [];
917
+ for (const { coordinate, text } of secretReferenceLeaves(properties, isSecretReference)) {
918
+ const tokens = dynamicReferenceTokens(text).filter((token) => isSecretReference(token));
919
+ const settled = (leaf) => leaf === text || isWhollyMask(leaf) || !mentionsMask(leaf) && tokens.every((token) => leaf.includes(token));
920
+ const walk = (live, recorded, depth, path, ambiguous) => {
921
+ if (live === void 0 || live === null) return;
922
+ if (depth === coordinate.length) {
923
+ if (typeof live === "string") {
924
+ if (settled(live)) return;
925
+ if (!ambiguous && !mentionsMask(live) && dynamicReferenceTokens(live).length === 0 && plaintextFor(text, live) !== void 0) {
926
+ restore.push({
927
+ coordinate: path,
928
+ value: text
929
+ });
930
+ return;
931
+ }
932
+ }
933
+ mask.push(path);
934
+ return;
935
+ }
936
+ const segment = coordinate[depth];
937
+ if (typeof segment === "string") {
938
+ if (typeof live === "string") {
939
+ if (!settled(live)) mask.push(path);
940
+ return;
941
+ }
942
+ if (!isPlainObject(live) || !Object.hasOwn(live, segment)) return;
943
+ walk(live[segment], isPlainObject(recorded) ? recorded[segment] : void 0, depth + 1, [...path, segment], ambiguous);
944
+ return;
945
+ }
946
+ if (!Array.isArray(live) || !Array.isArray(recorded)) return;
947
+ const element = recorded[segment];
948
+ const pairing = listPairing(live, recorded, isSecretReference);
949
+ const paired = pairing?.(segment);
950
+ if (paired !== void 0) {
951
+ walk(live[paired], element, depth + 1, [...path, paired], ambiguous);
952
+ return;
953
+ }
954
+ const claimed = new Set(pairing === void 0 ? [] : recorded.flatMap((_, j) => {
955
+ const index = j === segment ? void 0 : pairing(j);
956
+ return index === void 0 ? [] : [index];
957
+ }));
958
+ const corroborating = live.flatMap((item, i) => !claimed.has(i) && corroborates(item, element, isSecretReference) ? [i] : []);
959
+ const maskedElement = holdsMaskText(element);
960
+ if (corroborating.length === 1 && !maskedElement) {
961
+ const only = corroborating[0];
962
+ walk(live[only], element, depth + 1, [...path, only], ambiguous);
963
+ return;
964
+ }
965
+ const pool = corroborating.length > 0 && !maskedElement ? corroborating : live.flatMap((_, i) => claimed.has(i) ? [] : [i]);
966
+ for (const i of pool) walk(live[i], element, depth + 1, [...path, i], true);
967
+ };
968
+ walk(observed, properties, 0, [], false);
969
+ }
970
+ if (restore.length === 0 && mask.length === 0) return observed;
971
+ return maskAtCoordinates(replaceAtCoordinates(observed, restore), mask);
972
+ }
973
+ function holdsMaskText(node) {
974
+ if (typeof node === "string") return mentionsMask(node);
975
+ if (Array.isArray(node)) return node.some(holdsMaskText);
976
+ if (isPlainObject(node)) return Object.values(node).some(holdsMaskText);
977
+ return false;
978
+ }
979
+
980
+ // src/analyzer/replacement-rules/batch-compute-environment.ts
981
+ const INFRASTRUCTURE_UPDATE_MEMBERS = [
982
+ "AllocationStrategy",
983
+ "BidPercentage",
984
+ "Ec2Configuration",
985
+ "Ec2KeyPair",
986
+ "ImageId",
987
+ "InstanceRole",
988
+ "InstanceTypes",
989
+ "LaunchTemplate",
990
+ "PlacementGroup",
991
+ "Tags",
992
+ "Type",
993
+ "UpdateToLatestImageVersion"
994
+ ];
995
+ const CREATE_ONLY_PATHS = [
996
+ ["SpotIamFleetRole"],
997
+ [
998
+ "ManagedInstancesProvider",
999
+ "InstanceLaunchTemplate",
1000
+ "CapacityOptionType"
1001
+ ],
1002
+ [
1003
+ "ManagedInstancesProvider",
1004
+ "InstanceLaunchTemplate",
1005
+ "FipsEnabled"
1006
+ ]
1007
+ ];
1008
+ function at(value, path) {
1009
+ let cursor = value;
1010
+ for (const segment of path) {
1011
+ if (typeof cursor !== "object" || cursor === null || Array.isArray(cursor)) return void 0;
1012
+ cursor = cursor[segment];
1013
+ }
1014
+ return cursor;
1015
+ }
1016
+ function noInfrastructureUpdate(current) {
1017
+ const type = at(current, ["Type"]);
1018
+ if (type === "FARGATE" || type === "FARGATE_SPOT") return "fargate";
1019
+ const strategy = at(current, ["AllocationStrategy"]);
1020
+ return strategy === void 0 || strategy === "BEST_FIT" ? "best-fit" : void 0;
1021
+ }
1022
+ function isExplicitFalse(value) {
1023
+ return value === false || value === "false";
1024
+ }
1025
+ function batchComputeResourcesChangeReplaces(oldValue, newValue, siblings) {
1026
+ if (CREATE_ONLY_PATHS.some((p) => !isDeepStrictEqual(at(oldValue, p), at(newValue, p)))) return true;
1027
+ const changed = (member) => !isDeepStrictEqual(at(oldValue, [member]), at(newValue, [member]));
1028
+ const bestFit = noInfrastructureUpdate(oldValue) === "best-fit" || noInfrastructureUpdate(newValue) === "best-fit";
1029
+ if (!(INFRASTRUCTURE_UPDATE_MEMBERS.some(changed) || bestFit && (changed("Subnets") || changed("SecurityGroupIds"))) || siblings === void 0) return false;
1030
+ return !isExplicitFalse(siblings.newProperties["ReplaceComputeEnvironment"]);
1031
+ }
1032
+
1033
+ // src/utils/lambda-function-name.ts
1034
+ function parseLambdaFunctionAddress(value) {
1035
+ const full = /^arn:([^:]+):lambda:([^:]+):(\d{12}):function:([^:]+)$/.exec(value);
1036
+ if (full) return {
1037
+ partition: full[1],
1038
+ region: full[2],
1039
+ account: full[3],
1040
+ name: full[4]
1041
+ };
1042
+ const partial = /^(\d{12}):function:([^:]+)$/.exec(value);
1043
+ if (partial) return {
1044
+ account: partial[1],
1045
+ name: partial[2]
1046
+ };
1047
+ if (/^[A-Za-z0-9_-]+$/.test(value)) return { name: value };
1048
+ }
1049
+ function sameLambdaFunctionAddress(a, b) {
1050
+ if (a === b) return true;
1051
+ const x = parseLambdaFunctionAddress(a);
1052
+ const y = parseLambdaFunctionAddress(b);
1053
+ if (x === void 0 || y === void 0) return false;
1054
+ return x.name === y.name && (x.partition === void 0 || y.partition === void 0 || x.partition === y.partition) && (x.region === void 0 || y.region === void 0 || x.region === y.region) && (x.account === void 0 || y.account === void 0 || x.account === y.account);
1055
+ }
1056
+ function canonicalLambdaFunctionName(value) {
1057
+ return parseLambdaFunctionAddress(value)?.name ?? value;
1058
+ }
1059
+ function lambdaFunctionNameForMask(value) {
1060
+ return /^(?:arn:[^:]+:lambda:[^:]+:\d{12}:function:|\d{12}:function:)?([A-Za-z0-9_-]+)(?::[^:]+)?$/.exec(value)?.[1] ?? canonicalLambdaFunctionName(value);
1061
+ }
1062
+
1063
+ // src/analyzer/replacement-rules/predicates.ts
1064
+ function vpcInstanceTenancyChangeReplaces(oldValue, newValue) {
1065
+ const tenancyOf = (v) => v == null ? "default" : String(v);
1066
+ return tenancyOf(newValue) !== "default" && tenancyOf(newValue) !== tenancyOf(oldValue);
1067
+ }
1068
+ function instanceSecurityGroupIdsChangeReplaces(oldValue, newValue, siblings) {
1069
+ if (siblings === void 0) return false;
1070
+ if (Array.isArray(oldValue) && Array.isArray(newValue)) {
1071
+ const before = new Set(oldValue.map(String));
1072
+ const after = new Set(newValue.map(String));
1073
+ if (before.size === after.size && [...before].every((g) => after.has(g))) return false;
1074
+ }
1075
+ return siblings.newProperties["SubnetId"] == null;
1076
+ }
1077
+ function instanceTenancyChangeReplaces(oldValue, newValue) {
1078
+ if (oldValue == null) return false;
1079
+ if (newValue == null) return true;
1080
+ const text = (v) => typeof v === "string" ? v : JSON.stringify(v);
1081
+ const before = text(oldValue);
1082
+ const after = text(newValue);
1083
+ if (before === after) return false;
1084
+ return before === "default" || after === "default";
1085
+ }
1086
+ function instancePrivateDnsNameOptionsChangeReplaces(oldValue, newValue) {
1087
+ return oldValue != null && newValue == null;
1088
+ }
1089
+ function instanceBlockDeviceMappingsChangeReplaces(oldValue, newValue) {
1090
+ return !blockDeviceMappingsDifferOnlyInDeleteOnTermination(oldValue, newValue);
1091
+ }
1092
+ function blockDeviceMappingsDifferOnlyInDeleteOnTermination(oldValue, newValue) {
1093
+ if (!Array.isArray(oldValue) || !Array.isArray(newValue)) return false;
1094
+ if (oldValue.length !== newValue.length) return false;
1095
+ const strip = (m) => {
1096
+ if (m === null || typeof m !== "object" || Array.isArray(m)) return m;
1097
+ const out = { ...m };
1098
+ const ebs = out["Ebs"];
1099
+ if (ebs !== null && typeof ebs === "object" && !Array.isArray(ebs)) {
1100
+ const rest = { ...ebs };
1101
+ delete rest["DeleteOnTermination"];
1102
+ out["Ebs"] = rest;
1103
+ }
1104
+ return out;
1105
+ };
1106
+ return oldValue.every((m, i) => isDeepStrictEqual(scalarsAsStrings(strip(m)), scalarsAsStrings(strip(newValue[i]))));
1107
+ }
1108
+ function scalarsAsStrings(value) {
1109
+ if (Array.isArray(value)) return value.map(scalarsAsStrings);
1110
+ if (value !== null && typeof value === "object") return Object.fromEntries(Object.entries(value).filter(([, v]) => v !== void 0).map(([k, v]) => [k, scalarsAsStrings(v)]));
1111
+ return typeof value === "number" || typeof value === "boolean" ? String(value) : value;
1112
+ }
1113
+ function durableConfigPresenceToggled(oldValue, newValue) {
1114
+ return oldValue == null !== (newValue == null);
1115
+ }
1116
+ function eventInvokeConfigFunctionChanged(oldValue, newValue) {
1117
+ if (oldValue === void 0 && newValue === void 0) return true;
1118
+ if (typeof oldValue === "string" && typeof newValue === "string") return !sameLambdaFunctionAddress(oldValue, newValue);
1119
+ return JSON.stringify(oldValue) !== JSON.stringify(newValue);
1120
+ }
1121
+ function attributeTypeChangedForSharedAttribute(oldValue, newValue) {
1122
+ const toTypeMap = (value) => {
1123
+ const map = /* @__PURE__ */ new Map();
1124
+ if (Array.isArray(value)) {
1125
+ for (const def of value) if (def && typeof def === "object") {
1126
+ const name = def["AttributeName"];
1127
+ const type = def["AttributeType"];
1128
+ if (typeof name === "string" && typeof type === "string") map.set(name, type);
1129
+ }
1130
+ }
1131
+ return map;
1132
+ };
1133
+ const oldTypes = toTypeMap(oldValue);
1134
+ const newTypes = toTypeMap(newValue);
1135
+ for (const [name, oldType] of oldTypes) {
1136
+ const newType = newTypes.get(name);
1137
+ if (newType !== void 0 && newType !== oldType) return true;
1138
+ }
1139
+ return false;
1140
+ }
1141
+ function globalTableLocalSecondaryIndexesRemoved(oldValue, newValue) {
1142
+ const declares = (value) => Array.isArray(value) && value.length > 0;
1143
+ return declares(oldValue) && (newValue === void 0 || newValue === null || Array.isArray(newValue) && newValue.length === 0);
1144
+ }
1145
+ function budgetNameChanged(oldValue, newValue) {
1146
+ const nameOf = (value) => {
1147
+ if (value === null || typeof value !== "object") return void 0;
1148
+ const name = value["BudgetName"];
1149
+ return typeof name === "string" ? name : void 0;
1150
+ };
1151
+ const oldName = nameOf(oldValue);
1152
+ const newName = nameOf(newValue);
1153
+ if (oldName === void 0 && newName === void 0) return false;
1154
+ return oldName !== newName;
1155
+ }
1156
+ function iamRolePathChanged(oldValue, newValue) {
1157
+ const effective = (value) => value === void 0 || value === null || value === "" ? "/" : value;
1158
+ const oldPath = effective(oldValue);
1159
+ const newPath = effective(newValue);
1160
+ if (typeof oldPath === "string" && typeof newPath === "string") return oldPath !== newPath;
1161
+ return !isDeepStrictEqual(oldPath, newPath);
1162
+ }
1163
+ function glueTableNameChanged(oldValue, newValue) {
1164
+ const nameOf = (value) => {
1165
+ if (value === null || typeof value !== "object" || Array.isArray(value)) return void 0;
1166
+ const name = value["Name"];
1167
+ return typeof name === "string" ? name : void 0;
1168
+ };
1169
+ const oldName = nameOf(oldValue);
1170
+ const newName = nameOf(newValue);
1171
+ if (oldName === void 0 || newName === void 0) return false;
1172
+ return oldName.toLowerCase() !== newName.toLowerCase();
1173
+ }
1174
+ function natZoneAddressesAddedToAutomaticGateway(oldValue, newValue) {
1175
+ return oldValue == null && newValue != null;
1176
+ }
1177
+ function ecsServiceLaunchTypeSetOrChanged(oldValue, newValue) {
1178
+ return newValue != null && !isDeepStrictEqual(oldValue, newValue);
1179
+ }
1180
+ const EMR_INSTANCES_IN_PLACE_MEMBERS = ["TerminationProtected", "UnhealthyNodeReplacement"];
1181
+ const EMR_GROUP_IN_PLACE_MEMBERS = ["InstanceCount", "AutoScalingPolicy"];
1182
+ const EMR_FLEET_IN_PLACE_MEMBERS = ["TargetOnDemandCapacity", "TargetSpotCapacity"];
1183
+ function withoutKeys(value, keys) {
1184
+ if (value === null || typeof value !== "object" || Array.isArray(value)) return value;
1185
+ const copy = { ...value };
1186
+ for (const key of keys) delete copy[key];
1187
+ return copy;
1188
+ }
1189
+ function emrInstancesReplacingPart(value) {
1190
+ if (value === null || typeof value !== "object" || Array.isArray(value)) return value;
1191
+ const instances = withoutKeys(value, EMR_INSTANCES_IN_PLACE_MEMBERS);
1192
+ const strip = (key, keys) => {
1193
+ if (!(key in instances)) return;
1194
+ const member = instances[key];
1195
+ instances[key] = Array.isArray(member) ? member.map((entry) => withoutKeys(entry, keys)) : withoutKeys(member, keys);
1196
+ };
1197
+ strip("CoreInstanceGroup", EMR_GROUP_IN_PLACE_MEMBERS);
1198
+ strip("TaskInstanceGroups", EMR_GROUP_IN_PLACE_MEMBERS);
1199
+ strip("CoreInstanceFleet", EMR_FLEET_IN_PLACE_MEMBERS);
1200
+ strip("TaskInstanceFleets", EMR_FLEET_IN_PLACE_MEMBERS);
1201
+ return instances;
1202
+ }
1203
+ function elastiCachePreferredAvailabilityZonesMovedToDisjoint(oldValue, newValue) {
1204
+ if (!Array.isArray(oldValue) || !Array.isArray(newValue)) return false;
1205
+ if (oldValue.length === 0 || newValue.length === 0) return false;
1206
+ if (![...oldValue, ...newValue].every((z) => typeof z === "string")) return false;
1207
+ return !newValue.some((z) => oldValue.includes(z));
1208
+ }
1209
+ function elastiCacheLeftSingleAzWithoutZones(siblings) {
1210
+ if (siblings === void 0) return false;
1211
+ const { oldProperties: prev, newProperties: next } = siblings;
1212
+ return prev["Engine"] === "memcached" && next["Engine"] === "memcached" && prev["PreferredAvailabilityZone"] == null && next["PreferredAvailabilityZone"] == null && next["PreferredAvailabilityZones"] == null && (next["AZMode"] == null || next["AZMode"] === "single-az");
1213
+ }
1214
+ function elastiCacheMovedSingleToCrossAz(siblings) {
1215
+ if (siblings === void 0) return false;
1216
+ const { oldProperties: prev, newProperties: next } = siblings;
1217
+ const zones = next["PreferredAvailabilityZones"];
1218
+ return prev["Engine"] === "memcached" && next["Engine"] === "memcached" && prev["AZMode"] === "single-az" && next["AZMode"] === "cross-az" && prev["PreferredAvailabilityZone"] == null && next["PreferredAvailabilityZone"] == null && prev["PreferredAvailabilityZones"] == null && Array.isArray(zones) && zones.every((z) => typeof z === "string") && new Set(zones).size >= 2 && isDeepStrictEqual(prev["NumCacheNodes"], next["NumCacheNodes"]) && zones.length === Number(next["NumCacheNodes"]);
1219
+ }
1220
+ function elastiCacheAzModeRemovedFromSingleAz(oldValue, newValue, siblings) {
1221
+ return oldValue === "single-az" && newValue == null && elastiCacheLeftSingleAzWithoutZones(siblings);
1222
+ }
1223
+ function elastiCachePreferredAvailabilityZonesRemovedFromSingleAz(oldValue, newValue, siblings) {
1224
+ return Array.isArray(oldValue) && oldValue.length > 0 && newValue == null && siblings?.oldProperties["AZMode"] === "single-az" && elastiCacheLeftSingleAzWithoutZones(siblings);
1225
+ }
1226
+ function elastiCachePreferredAvailabilityZonesReplaced(oldValue, newValue, siblings) {
1227
+ return elastiCachePreferredAvailabilityZonesMovedToDisjoint(oldValue, newValue) || elastiCachePreferredAvailabilityZonesRemovedFromSingleAz(oldValue, newValue, siblings) || oldValue == null && newValue != null && elastiCacheMovedSingleToCrossAz(siblings);
1228
+ }
1229
+ function emrClusterInstancesReplaced(oldValue, newValue) {
1230
+ if (oldValue === void 0 && newValue === void 0) return true;
1231
+ return !isDeepStrictEqual(emrInstancesReplacingPart(oldValue), emrInstancesReplacingPart(newValue));
1232
+ }
1233
+ const AURORA = "aurora";
1234
+ const AURORA_MYSQL = "aurora-mysql";
1235
+ const DEPRECATED_ORACLE_SE_ENGINES = /* @__PURE__ */ new Set(["oracle-se", "oracle-se1"]);
1236
+ const ORACLE_SE2 = "oracle-se2";
1237
+ const ORACLE_CDB_CONVERSIONS = /* @__PURE__ */ new Map([["oracle-ee", "oracle-ee-cdb"], ["oracle-se2", "oracle-se2-cdb"]]);
1238
+ const ORACLE_CDB_ENGINES = new Set(ORACLE_CDB_CONVERSIONS.values());
1239
+ function enginePair(oldValue, newValue) {
1240
+ return typeof oldValue === "string" && typeof newValue === "string" ? [oldValue, newValue] : void 0;
1241
+ }
1242
+ function dbClusterEngineChangeReplaces(oldValue, newValue) {
1243
+ const pair = enginePair(oldValue, newValue);
1244
+ if (pair === void 0) return false;
1245
+ const [before, after] = pair;
1246
+ return !(before === after || before === AURORA && after === AURORA_MYSQL);
1247
+ }
1248
+ function dbInstanceEngineChangeIsInPlace(oldValue, newValue) {
1249
+ const pair = enginePair(oldValue, newValue);
1250
+ if (pair === void 0) return false;
1251
+ const [before, after] = pair;
1252
+ const from = before.toLowerCase();
1253
+ const to = after.toLowerCase();
1254
+ return before === after || before === AURORA && after === AURORA_MYSQL || DEPRECATED_ORACLE_SE_ENGINES.has(from) && to === ORACLE_SE2 || ORACLE_CDB_CONVERSIONS.get(from) === to || from === to && ORACLE_CDB_ENGINES.has(to);
1255
+ }
1256
+ function dbInstanceEngineChangeReplaces(oldValue, newValue) {
1257
+ if (enginePair(oldValue, newValue) === void 0) return false;
1258
+ return !dbInstanceEngineChangeIsInPlace(oldValue, newValue);
1259
+ }
1260
+ function recordSetGroupRecordZoneChanged(oldValue, newValue, siblings) {
1261
+ const groupZone = (props) => props?.["HostedZoneId"] !== void 0 || props?.["HostedZoneName"] !== void 0;
1262
+ if (groupZone(siblings?.oldProperties) || groupZone(siblings?.newProperties)) return false;
1263
+ const recordZone = (value) => {
1264
+ if (!Array.isArray(value)) return void 0;
1265
+ for (const record of value) {
1266
+ if (record === null || typeof record !== "object" || Array.isArray(record)) continue;
1267
+ const r = record;
1268
+ if (r["HostedZoneId"] !== void 0 || r["HostedZoneName"] !== void 0) return r;
1269
+ }
1270
+ };
1271
+ const before = recordZone(oldValue);
1272
+ const after = recordZone(newValue);
1273
+ if (before === void 0 || after === void 0) return false;
1274
+ return route53ZoneReferenceChanged(void 0, void 0, {
1275
+ oldProperties: before,
1276
+ newProperties: after
1277
+ });
1278
+ }
1279
+ function route53ZoneReferenceChanged(_oldValue, _newValue, siblings) {
1280
+ if (!siblings) return true;
1281
+ const read = (props) => {
1282
+ const id = props["HostedZoneId"];
1283
+ const name = props["HostedZoneName"];
1284
+ return {
1285
+ id: typeof id === "string" ? id.replace(/^\/hostedzone\//, "") : id,
1286
+ name: typeof name === "string" ? name.replace(/\.$/, "").toLowerCase() : name
1287
+ };
1288
+ };
1289
+ const before = read(siblings.oldProperties);
1290
+ const after = read(siblings.newProperties);
1291
+ const readable = (v) => v === void 0 || typeof v === "string";
1292
+ if (![
1293
+ before.id,
1294
+ before.name,
1295
+ after.id,
1296
+ after.name
1297
+ ].every(readable)) return true;
1298
+ if (before.id !== void 0 && after.id !== void 0) return before.id !== after.id;
1299
+ if (before.id === void 0 && after.id === void 0) return before.name !== after.name;
1300
+ return false;
1301
+ }
1302
+ function ssmDocumentChangeReplaces(_oldValue, _newValue, siblings) {
1303
+ return siblings?.newProperties["UpdateMethod"] !== "NewVersion";
1304
+ }
1305
+ function thingTypeReplacingMemberChanged(oldValue, newValue) {
1306
+ const intrinsic = (value) => value !== null && typeof value === "object" && !Array.isArray(value) && Object.keys(value).some((key) => key === "Ref" || key.startsWith("Fn::"));
1307
+ if (intrinsic(oldValue) || intrinsic(newValue)) return !isDeepStrictEqual(oldValue, newValue);
1308
+ const member = (value, key) => value !== null && typeof value === "object" && !Array.isArray(value) ? value[key] : void 0;
1309
+ const asMultiset = (value) => Array.isArray(value) ? value.map((element) => JSON.stringify(element)).sort() : value;
1310
+ return !isDeepStrictEqual(member(oldValue, "ThingTypeDescription"), member(newValue, "ThingTypeDescription")) || !isDeepStrictEqual(asMultiset(member(oldValue, "SearchableAttributes")), asMultiset(member(newValue, "SearchableAttributes")));
1311
+ }
1312
+
1313
+ // src/deployment/deploy-value-equality.ts
1314
+ function isReplacementCeiling(pc) {
1315
+ return pc.requiresReplacement && (pc.inPlacePropagated === true || pc.replacementPropagated === true);
1316
+ }
1317
+ function keyOrderFreeJson(value) {
1318
+ return JSON.stringify(value, (_key, node) => {
1319
+ if (node === null || typeof node !== "object" || Array.isArray(node)) return node;
1320
+ const sorted = Object.create(null);
1321
+ for (const key of Object.keys(node).sort()) sorted[key] = node[key];
1322
+ return sorted;
1323
+ });
1324
+ }
1325
+ const IAM_ACTION = /^[a-z0-9-]{1,64}:[A-Za-z0-9*]{1,128}$/;
1326
+ const ACTION_IN_MESSAGE = [/\bperform:\s*([a-z0-9-]{1,64}:[A-Za-z0-9*]{1,128})(?=\s|$|[.,;])/, /\ballows the ([a-z0-9-]{1,64}:[A-Za-z0-9*]{1,128}) action\b/];
1327
+ const DENIAL_CLASSES = /* @__PURE__ */ new Set([
1328
+ "AccessDenied",
1329
+ "AccessDeniedException",
1330
+ "AuthorizationError",
1331
+ "UnauthorizedOperation"
1332
+ ]);
1333
+ function readDenialOf(error) {
1334
+ try {
1335
+ const name = error?.name;
1336
+ if (typeof name !== "string" || !DENIAL_CLASSES.has(name)) return void 0;
1337
+ const message = error.message;
1338
+ let action;
1339
+ if (typeof message === "string") for (const pattern of ACTION_IN_MESSAGE) {
1340
+ const found = pattern.exec(message)?.[1];
1341
+ if (found !== void 0 && IAM_ACTION.test(found)) {
1342
+ action = found;
1343
+ break;
1344
+ }
1345
+ }
1346
+ return {
1347
+ ...action !== void 0 && { action },
1348
+ errorClass: name
1349
+ };
1350
+ } catch {
1351
+ return;
1352
+ }
1353
+ }
1354
+ function grantSentence(denied) {
1355
+ const what = denied.action !== void 0 ? `the ${denied.action} permission` : `the read permission the provider's readback of this resource type needs`;
1356
+ return `AWS denied the read${denied.errorClass !== void 0 ? ` (${denied.errorClass})` : ""}, and re-running would be denied the same way: grant ${what} to the credentials cdkd runs with, then re-run`;
1357
+ }
1358
+ function liveHoldsFreshLeaves(live, leaves) {
1359
+ for (const leaf of leaves) {
1360
+ let node = live;
1361
+ for (const segment of leaf.path) {
1362
+ if (typeof segment === "number") {
1363
+ if (!Array.isArray(node) || segment >= node.length) return false;
1364
+ node = node[segment];
1365
+ continue;
1366
+ }
1367
+ if (node === null || typeof node !== "object" || Array.isArray(node)) return false;
1368
+ if (!Object.prototype.hasOwnProperty.call(node, segment)) return false;
1369
+ node = node[segment];
1370
+ }
1371
+ if (typeof leaf.plaintext === "string") {
1372
+ if (typeof node !== "string" || node !== leaf.plaintext) return false;
1373
+ } else if (node === void 0 || keyOrderFreeJson(node) !== keyOrderFreeJson(leaf.plaintext)) return false;
1374
+ }
1375
+ return true;
1376
+ }
1377
+ function outputMapsEqual(a, b) {
1378
+ return deepEqualValue(a, b);
1379
+ }
1380
+ function deepEqualValue(a, b) {
1381
+ if (a === b) return true;
1382
+ if (a == null || b == null) return a === b;
1383
+ if (typeof a !== typeof b) return false;
1384
+ if (typeof a !== "object") return false;
1385
+ if (Array.isArray(a) || Array.isArray(b)) {
1386
+ if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) return false;
1387
+ return a.every((v, i) => deepEqualValue(v, b[i]));
1388
+ }
1389
+ const ao = a;
1390
+ const bo = b;
1391
+ const ak = Object.keys(ao);
1392
+ if (ak.length !== Object.keys(bo).length) return false;
1393
+ for (const k of ak) {
1394
+ if (!Object.prototype.hasOwnProperty.call(bo, k)) return false;
1395
+ if (!deepEqualValue(ao[k], bo[k])) return false;
1396
+ }
1397
+ return true;
1398
+ }
1399
+
1400
+ // src/analyzer/replacement-rules/rds-immutability.ts
1401
+ const UNRESOLVED = Symbol("unresolved");
1402
+ const UNDECIDABLE = Symbol("undecidable");
1403
+ function javaString(value) {
1404
+ if (value === void 0 || value === null) return null;
1405
+ return typeof value === "string" ? value : UNRESOLVED;
1406
+ }
1407
+ function stringChange(oldValue, newValue) {
1408
+ if (oldValue === void 0 && newValue === void 0) return {
1409
+ before: UNRESOLVED,
1410
+ after: UNRESOLVED,
1411
+ equal: false
1412
+ };
1413
+ const before = javaString(oldValue);
1414
+ const after = javaString(newValue);
1415
+ return {
1416
+ before,
1417
+ after,
1418
+ equal: before === UNRESOLVED && after === UNRESOLVED ? keyOrderFreeJson(oldValue) === keyOrderFreeJson(newValue) : before === after
1419
+ };
1420
+ }
1421
+ function javaBoolean(value) {
1422
+ if (value === void 0 || value === null) return null;
1423
+ if (value === true || value === "true") return true;
1424
+ if (value === false || value === "false") return false;
1425
+ return UNDECIDABLE;
1426
+ }
1427
+ const isNullOrEmpty = (value) => value === null || value === "";
1428
+ function dbInstanceRestoreInputChangeReplaces(oldValue, newValue) {
1429
+ const { after, equal } = stringChange(oldValue, newValue);
1430
+ return !equal && !isNullOrEmpty(after);
1431
+ }
1432
+ function dbInstanceUseLatestRestorableTimeChangeReplaces(oldValue, newValue) {
1433
+ if (oldValue === void 0 && newValue === void 0) return true;
1434
+ const before = javaBoolean(oldValue);
1435
+ const after = javaBoolean(newValue);
1436
+ if (before === UNDECIDABLE || after === UNDECIDABLE) return false;
1437
+ return before !== after && after === true;
1438
+ }
1439
+ function dbInstanceReplicaSourceChangeReplaces(oldValue, newValue) {
1440
+ const { before, after, equal } = stringChange(oldValue, newValue);
1441
+ if (equal) return false;
1442
+ return !(!isNullOrEmpty(before) && isNullOrEmpty(after));
1443
+ }
1444
+ function dbInstancePerformanceInsightsKmsKeyChangeReplaces(oldValue, newValue) {
1445
+ const { before, equal } = stringChange(oldValue, newValue);
1446
+ return !isNullOrEmpty(before) && !equal;
1447
+ }
1448
+ function dbInstanceAvailabilityZoneChangeReplaces(oldValue, newValue, siblings) {
1449
+ const { after, equal } = stringChange(oldValue, newValue);
1450
+ if (equal) return false;
1451
+ if (isNullOrEmpty(after)) {
1452
+ if (siblings === void 0) return false;
1453
+ const multiAz = javaBoolean(siblings.newProperties["MultiAZ"]);
1454
+ if (multiAz === UNDECIDABLE || multiAz === true) return false;
1455
+ }
1456
+ return true;
1457
+ }
1458
+ function dbClusterGlobalClusterChangeReplaces(oldValue, newValue) {
1459
+ const { before, after, equal } = stringChange(oldValue, newValue);
1460
+ if (!isNullOrEmpty(before) && isNullOrEmpty(after)) return false;
1461
+ return !equal;
1462
+ }
1463
+
1464
+ // src/analyzer/replacement-rules/rules.ts
1465
+ function initializeRules() {
1466
+ this.rules.set("AWS::S3::Bucket", {
1467
+ replacementProperties: /* @__PURE__ */ new Set([
1468
+ "BucketName",
1469
+ "BucketNamePrefix",
1470
+ "BucketNamespace"
1471
+ ]),
1472
+ updateableProperties: /* @__PURE__ */ new Set([
1473
+ "AbacStatus",
1474
+ "MetadataConfiguration",
1475
+ "Tags",
1476
+ "VersioningConfiguration",
1477
+ "LifecycleConfiguration",
1478
+ "PublicAccessBlockConfiguration",
1479
+ "BucketEncryption",
1480
+ "LoggingConfiguration",
1481
+ "WebsiteConfiguration",
1482
+ "CorsConfiguration",
1483
+ "NotificationConfiguration"
1484
+ ])
1485
+ });
1486
+ this.rules.set("AWS::Lambda::Function", {
1487
+ replacementProperties: /* @__PURE__ */ new Set(["FunctionName", "TenancyConfig"]),
1488
+ updateableProperties: /* @__PURE__ */ new Set([
1489
+ "Code",
1490
+ "Handler",
1491
+ "Runtime",
1492
+ "Description",
1493
+ "Timeout",
1494
+ "MemorySize",
1495
+ "Role",
1496
+ "Environment",
1497
+ "Tags",
1498
+ "VpcConfig",
1499
+ "DeadLetterConfig",
1500
+ "TracingConfig",
1501
+ "Layers",
1502
+ "FileSystemConfigs",
1503
+ "Architectures",
1504
+ "CodeSigningConfigArn",
1505
+ "RuntimeManagementConfig"
1506
+ ]),
1507
+ conditionalReplacements: /* @__PURE__ */ new Map([["DurableConfig", durableConfigPresenceToggled]])
1508
+ });
1509
+ this.rules.set("AWS::Lambda::LayerVersion", { replacementProperties: /* @__PURE__ */ new Set([
1510
+ "Content",
1511
+ "LayerName",
1512
+ "Description",
1513
+ "CompatibleRuntimes",
1514
+ "CompatibleArchitectures",
1515
+ "LicenseInfo"
1516
+ ]) });
1517
+ this.rules.set("AWS::Lambda::Version", { replacementProperties: /* @__PURE__ */ new Set([
1518
+ "CodeSha256",
1519
+ "Description",
1520
+ "FunctionName",
1521
+ "ProvisionedConcurrencyConfig",
1522
+ "RuntimePolicy"
1523
+ ]) });
1524
+ this.rules.set("AWS::Lambda::EventInvokeConfig", {
1525
+ replacementProperties: /* @__PURE__ */ new Set(["Qualifier"]),
1526
+ conditionalReplacements: /* @__PURE__ */ new Map([["FunctionName", eventInvokeConfigFunctionChanged]]),
1527
+ updateableProperties: /* @__PURE__ */ new Set([
1528
+ "MaximumEventAgeInSeconds",
1529
+ "MaximumRetryAttempts",
1530
+ "DestinationConfig"
1531
+ ])
1532
+ });
1533
+ this.rules.set("AWS::Batch::ComputeEnvironment", {
1534
+ replacementProperties: /* @__PURE__ */ new Set(),
1535
+ conditionalReplacements: /* @__PURE__ */ new Map([["ComputeResources", batchComputeResourcesChangeReplaces]])
1536
+ });
1537
+ this.rules.set("AWS::DynamoDB::GlobalTable", {
1538
+ replacementProperties: /* @__PURE__ */ new Set(),
1539
+ conditionalReplacements: /* @__PURE__ */ new Map([["LocalSecondaryIndexes", globalTableLocalSecondaryIndexesRemoved]])
1540
+ });
1541
+ this.rules.set("AWS::DynamoDB::Table", {
1542
+ replacementProperties: /* @__PURE__ */ new Set(["TableName", "KeySchema"]),
1543
+ updateableProperties: /* @__PURE__ */ new Set([
1544
+ "BillingMode",
1545
+ "ProvisionedThroughput",
1546
+ "GlobalSecondaryIndexes",
1547
+ "LocalSecondaryIndexes",
1548
+ "StreamSpecification",
1549
+ "SSESpecification",
1550
+ "Tags",
1551
+ "TimeToLiveSpecification",
1552
+ "PointInTimeRecoverySpecification"
1553
+ ]),
1554
+ conditionalReplacements: /* @__PURE__ */ new Map([["AttributeDefinitions", attributeTypeChangedForSharedAttribute]])
1555
+ });
1556
+ this.rules.set("AWS::SQS::Queue", {
1557
+ replacementProperties: /* @__PURE__ */ new Set(["QueueName", "FifoQueue"]),
1558
+ updateableProperties: /* @__PURE__ */ new Set([
1559
+ "DelaySeconds",
1560
+ "MaximumMessageSize",
1561
+ "MessageRetentionPeriod",
1562
+ "ReceiveMessageWaitTimeSeconds",
1563
+ "VisibilityTimeout",
1564
+ "RedrivePolicy",
1565
+ "Tags",
1566
+ "ContentBasedDeduplication"
1567
+ ])
1568
+ });
1569
+ this.rules.set("AWS::IAM::Role", {
1570
+ replacementProperties: /* @__PURE__ */ new Set(["RoleName"]),
1571
+ updateableProperties: /* @__PURE__ */ new Set([
1572
+ "AssumeRolePolicyDocument",
1573
+ "Description",
1574
+ "ManagedPolicyArns",
1575
+ "MaxSessionDuration",
1576
+ "PermissionsBoundary",
1577
+ "Policies",
1578
+ "Tags"
1579
+ ]),
1580
+ conditionalReplacements: /* @__PURE__ */ new Map([["Path", iamRolePathChanged]])
1581
+ });
1582
+ this.rules.set("AWS::SNS::Topic", {
1583
+ replacementProperties: /* @__PURE__ */ new Set(["TopicName"]),
1584
+ updateableProperties: /* @__PURE__ */ new Set([
1585
+ "DisplayName",
1586
+ "Subscription",
1587
+ "KmsMasterKeyId",
1588
+ "Tags"
1589
+ ])
1590
+ });
1591
+ this.rules.set("AWS::CodeCommit::Repository", {
1592
+ replacementProperties: /* @__PURE__ */ new Set([]),
1593
+ updateableProperties: /* @__PURE__ */ new Set([
1594
+ "RepositoryName",
1595
+ "RepositoryDescription",
1596
+ "KmsKeyId",
1597
+ "Tags"
1598
+ ])
1599
+ });
1600
+ this.rules.set("AWS::ECR::Repository", {
1601
+ replacementProperties: /* @__PURE__ */ new Set(["RepositoryName"]),
1602
+ updateableProperties: /* @__PURE__ */ new Set([
1603
+ "ImageScanningConfiguration",
1604
+ "ImageTagMutability",
1605
+ "LifecyclePolicy",
1606
+ "RepositoryPolicyText",
1607
+ "Tags"
1608
+ ])
1609
+ });
1610
+ this.rules.set("AWS::Logs::LogGroup", {
1611
+ replacementProperties: /* @__PURE__ */ new Set(["LogGroupName"]),
1612
+ updateableProperties: /* @__PURE__ */ new Set(["RetentionInDays", "KmsKeyId"])
1613
+ });
1614
+ this.rules.set("AWS::Kinesis::Stream", {
1615
+ replacementProperties: /* @__PURE__ */ new Set(["Name"]),
1616
+ updateableProperties: /* @__PURE__ */ new Set([
1617
+ "RetentionPeriodHours",
1618
+ "ShardCount",
1619
+ "StreamModeDetails",
1620
+ "StreamEncryption",
1621
+ "Tags"
1622
+ ])
1623
+ });
1624
+ this.rules.set("AWS::SecretsManager::Secret", {
1625
+ replacementProperties: /* @__PURE__ */ new Set(["Name"]),
1626
+ updateableProperties: /* @__PURE__ */ new Set([
1627
+ "Description",
1628
+ "KmsKeyId",
1629
+ "SecretString",
1630
+ "GenerateSecretString",
1631
+ "ReplicaRegions",
1632
+ "Tags"
1633
+ ])
1634
+ });
1635
+ this.rules.set("AWS::StepFunctions::StateMachine", {
1636
+ replacementProperties: /* @__PURE__ */ new Set(["StateMachineName", "StateMachineType"]),
1637
+ updateableProperties: /* @__PURE__ */ new Set([
1638
+ "DefinitionString",
1639
+ "DefinitionS3Location",
1640
+ "Definition",
1641
+ "DefinitionSubstitutions",
1642
+ "RoleArn",
1643
+ "LoggingConfiguration",
1644
+ "TracingConfiguration",
1645
+ "Tags",
1646
+ "EncryptionConfiguration"
1647
+ ])
1648
+ });
1649
+ this.rules.set("AWS::Events::Rule", {
1650
+ replacementProperties: /* @__PURE__ */ new Set(["Name", "EventBusName"]),
1651
+ updateableProperties: /* @__PURE__ */ new Set([
1652
+ "ScheduleExpression",
1653
+ "EventPattern",
1654
+ "State",
1655
+ "Description",
1656
+ "Targets",
1657
+ "RoleArn"
1658
+ ])
1659
+ });
1660
+ this.rules.set("AWS::SSM::Parameter", {
1661
+ replacementProperties: /* @__PURE__ */ new Set(["Name"]),
1662
+ updateableProperties: /* @__PURE__ */ new Set([
1663
+ "Value",
1664
+ "Description",
1665
+ "Type",
1666
+ "Tier",
1667
+ "AllowedPattern",
1668
+ "Policies",
1669
+ "DataType",
1670
+ "Tags"
1671
+ ])
1672
+ });
1673
+ this.rules.set("AWS::SSM::Document", {
1674
+ replacementProperties: /* @__PURE__ */ new Set(["Name", "DocumentType"]),
1675
+ conditionalReplacements: new Map([
1676
+ "Content",
1677
+ "Attachments",
1678
+ "DocumentFormat",
1679
+ "Requires",
1680
+ "TargetType",
1681
+ "VersionName"
1682
+ ].map((prop) => [prop, ssmDocumentChangeReplaces]))
1683
+ });
1684
+ this.rules.set("AWS::Budgets::Budget", {
1685
+ replacementProperties: /* @__PURE__ */ new Set(),
1686
+ updateableProperties: /* @__PURE__ */ new Set(["NotificationsWithSubscribers", "ResourceTags"]),
1687
+ conditionalReplacements: /* @__PURE__ */ new Map([["Budget", budgetNameChanged]])
1688
+ });
1689
+ this.rules.set("AWS::Glue::Table", {
1690
+ replacementProperties: /* @__PURE__ */ new Set(),
1691
+ conditionalReplacements: /* @__PURE__ */ new Map([["TableInput", glueTableNameChanged]])
1692
+ });
1693
+ this.rules.set("AWS::IoT::ThingType", {
1694
+ replacementProperties: /* @__PURE__ */ new Set(),
1695
+ conditionalReplacements: /* @__PURE__ */ new Map([["ThingTypeProperties", thingTypeReplacingMemberChanged]])
1696
+ });
1697
+ this.rules.set("AWS::Route53::RecordSet", {
1698
+ replacementProperties: /* @__PURE__ */ new Set(),
1699
+ conditionalReplacements: /* @__PURE__ */ new Map([["HostedZoneId", route53ZoneReferenceChanged], ["HostedZoneName", route53ZoneReferenceChanged]])
1700
+ });
1701
+ this.rules.set("AWS::Route53::RecordSetGroup", {
1702
+ replacementProperties: /* @__PURE__ */ new Set(),
1703
+ updateableProperties: /* @__PURE__ */ new Set(["Comment"]),
1704
+ conditionalReplacements: /* @__PURE__ */ new Map([
1705
+ ["HostedZoneId", route53ZoneReferenceChanged],
1706
+ ["HostedZoneName", route53ZoneReferenceChanged],
1707
+ ["RecordSets", recordSetGroupRecordZoneChanged]
1708
+ ])
1709
+ });
1710
+ this.rules.set("AWS::CloudWatch::Alarm", {
1711
+ replacementProperties: /* @__PURE__ */ new Set(["AlarmName"]),
1712
+ updateableProperties: /* @__PURE__ */ new Set([
1713
+ "ComparisonOperator",
1714
+ "EvaluationPeriods",
1715
+ "DatapointsToAlarm",
1716
+ "Threshold",
1717
+ "TreatMissingData",
1718
+ "MetricName",
1719
+ "Namespace",
1720
+ "Period",
1721
+ "Statistic",
1722
+ "ExtendedStatistic",
1723
+ "Dimensions",
1724
+ "Metrics",
1725
+ "AlarmDescription",
1726
+ "ActionsEnabled",
1727
+ "AlarmActions",
1728
+ "OKActions",
1729
+ "InsufficientDataActions",
1730
+ "Unit",
1731
+ "EvaluateLowSampleCountPercentile",
1732
+ "ThresholdMetricId",
1733
+ "Tags"
1734
+ ])
1735
+ });
1736
+ this.rules.set("AWS::ApiGateway::RestApi", {
1737
+ replacementProperties: /* @__PURE__ */ new Set(),
1738
+ updateableProperties: /* @__PURE__ */ new Set([
1739
+ "Name",
1740
+ "Description",
1741
+ "Version",
1742
+ "Body",
1743
+ "BodyS3Location",
1744
+ "Mode",
1745
+ "FailOnWarnings",
1746
+ "Parameters",
1747
+ "CloneFrom",
1748
+ "Policy",
1749
+ "EndpointConfiguration",
1750
+ "BinaryMediaTypes",
1751
+ "MinimumCompressionSize",
1752
+ "ApiKeySourceType",
1753
+ "DisableExecuteApiEndpoint",
1754
+ "SecurityPolicy",
1755
+ "EndpointAccessMode",
1756
+ "Tags"
1757
+ ])
1758
+ });
1759
+ this.rules.set("AWS::AppSync::GraphQLApi", {
1760
+ replacementProperties: /* @__PURE__ */ new Set(["ApiType", "Visibility"]),
1761
+ updateableProperties: /* @__PURE__ */ new Set([
1762
+ "AuthenticationType",
1763
+ "LogConfig",
1764
+ "XrayEnabled",
1765
+ "Tags",
1766
+ "UserPoolConfig",
1767
+ "OpenIDConnectConfig",
1768
+ "LambdaAuthorizerConfig",
1769
+ "AdditionalAuthenticationProviders",
1770
+ "EnhancedMetricsConfig",
1771
+ "EnvironmentVariables",
1772
+ "IntrospectionConfig",
1773
+ "QueryDepthLimit",
1774
+ "ResolverCountLimit",
1775
+ "OwnerContact",
1776
+ "MergedApiExecutionRoleArn"
1777
+ ])
1778
+ });
1779
+ this.rules.set("AWS::RDS::DBProxy", { replacementProperties: /* @__PURE__ */ new Set([
1780
+ "DBProxyName",
1781
+ "EngineFamily",
1782
+ "VpcSubnetIds",
1783
+ "EndpointNetworkType",
1784
+ "TargetConnectionNetworkType"
1785
+ ]) });
1786
+ this.rules.set("AWS::RDS::DBProxyEndpoint", { replacementProperties: /* @__PURE__ */ new Set([
1787
+ "DBProxyName",
1788
+ "DBProxyEndpointName",
1789
+ "VpcSubnetIds",
1790
+ "TargetRole",
1791
+ "EndpointNetworkType"
1792
+ ]) });
1793
+ this.rules.set("AWS::S3Tables::Table", { replacementProperties: /* @__PURE__ */ new Set([
1794
+ "TableBucketARN",
1795
+ "OpenTableFormat",
1796
+ "IcebergMetadata",
1797
+ "StorageClassConfiguration",
1798
+ "WithoutMetadata"
1799
+ ]) });
1800
+ this.rules.set("AWS::RDS::DBProxyTargetGroup", { replacementProperties: /* @__PURE__ */ new Set(["DBProxyName", "TargetGroupName"]) });
1801
+ this.rules.set("AWS::EC2::VPC", {
1802
+ replacementProperties: /* @__PURE__ */ new Set([
1803
+ "CidrBlock",
1804
+ "Ipv4IpamPoolId",
1805
+ "Ipv4NetmaskLength",
1806
+ "VpcEncryptionControl"
1807
+ ]),
1808
+ conditionalReplacements: /* @__PURE__ */ new Map([["InstanceTenancy", vpcInstanceTenancyChangeReplaces]])
1809
+ });
1810
+ this.rules.set("AWS::RDS::DBCluster", {
1811
+ replacementProperties: /* @__PURE__ */ new Set(),
1812
+ conditionalReplacements: /* @__PURE__ */ new Map([["Engine", dbClusterEngineChangeReplaces], ["GlobalClusterIdentifier", dbClusterGlobalClusterChangeReplaces]])
1813
+ });
1814
+ this.rules.set("AWS::RDS::DBInstance", {
1815
+ replacementProperties: /* @__PURE__ */ new Set(),
1816
+ conditionalReplacements: /* @__PURE__ */ new Map([
1817
+ ["Engine", dbInstanceEngineChangeReplaces],
1818
+ ["AvailabilityZone", dbInstanceAvailabilityZoneChangeReplaces],
1819
+ ["PerformanceInsightsKMSKeyId", dbInstancePerformanceInsightsKmsKeyChangeReplaces],
1820
+ ["SourceDBInstanceIdentifier", dbInstanceReplicaSourceChangeReplaces],
1821
+ ["SourceDBClusterIdentifier", dbInstanceReplicaSourceChangeReplaces],
1822
+ ["DBSnapshotIdentifier", dbInstanceRestoreInputChangeReplaces],
1823
+ ["DBClusterSnapshotIdentifier", dbInstanceRestoreInputChangeReplaces],
1824
+ ["RestoreTime", dbInstanceRestoreInputChangeReplaces],
1825
+ ["SourceDBInstanceAutomatedBackupsArn", dbInstanceRestoreInputChangeReplaces],
1826
+ ["SourceDbiResourceId", dbInstanceRestoreInputChangeReplaces],
1827
+ ["UseLatestRestorableTime", dbInstanceUseLatestRestorableTimeChangeReplaces]
1828
+ ])
1829
+ });
1830
+ this.rules.set("AWS::EC2::Subnet", {
1831
+ replacementProperties: /* @__PURE__ */ new Set([
1832
+ "VpcId",
1833
+ "CidrBlock",
1834
+ "AvailabilityZone",
1835
+ "AvailabilityZoneId",
1836
+ "Ipv4IpamPoolId",
1837
+ "Ipv4NetmaskLength",
1838
+ "Ipv6IpamPoolId",
1839
+ "Ipv6NetmaskLength",
1840
+ "Ipv6Native"
1841
+ ]),
1842
+ updateableProperties: /* @__PURE__ */ new Set([
1843
+ "MapPublicIpOnLaunch",
1844
+ "EnableDns64",
1845
+ "Ipv6CidrBlock",
1846
+ "Tags"
1847
+ ])
1848
+ });
1849
+ this.rules.set("AWS::EC2::Instance", {
1850
+ replacementProperties: /* @__PURE__ */ new Set([
1851
+ "AvailabilityZone",
1852
+ "ImageId",
1853
+ "SubnetId",
1854
+ "KeyName",
1855
+ "NetworkInterfaces",
1856
+ "CpuOptions",
1857
+ "HibernationOptions",
1858
+ "PlacementGroupName",
1859
+ "PrivateIpAddress",
1860
+ "Ipv6AddressCount",
1861
+ "Ipv6Addresses",
1862
+ "EnclaveOptions",
1863
+ "HostResourceGroupArn",
1864
+ "SecurityGroups"
1865
+ ]),
1866
+ updateableProperties: /* @__PURE__ */ new Set(["EbsOptimized"]),
1867
+ conditionalReplacements: /* @__PURE__ */ new Map([
1868
+ ["SecurityGroupIds", instanceSecurityGroupIdsChangeReplaces],
1869
+ ["BlockDeviceMappings", instanceBlockDeviceMappingsChangeReplaces],
1870
+ ["Tenancy", instanceTenancyChangeReplaces],
1871
+ ["PrivateDnsNameOptions", instancePrivateDnsNameOptionsChangeReplaces]
1872
+ ])
1873
+ });
1874
+ this.rules.set("AWS::EC2::NatGateway", {
1875
+ replacementProperties: /* @__PURE__ */ new Set(),
1876
+ conditionalReplacements: /* @__PURE__ */ new Map([["AvailabilityZoneAddresses", natZoneAddressesAddedToAutomaticGateway]])
1877
+ });
1878
+ this.rules.set("AWS::CertificateManager::Certificate", { replacementProperties: /* @__PURE__ */ new Set(["ValidationMethod"]) });
1879
+ this.rules.set("AWS::EC2::Volume", {
1880
+ replacementProperties: /* @__PURE__ */ new Set([
1881
+ "AvailabilityZone",
1882
+ "AvailabilityZoneId",
1883
+ "Encrypted",
1884
+ "KmsKeyId",
1885
+ "OutpostArn",
1886
+ "SnapshotId"
1887
+ ]),
1888
+ updateableProperties: /* @__PURE__ */ new Set([
1889
+ "AutoEnableIO",
1890
+ "Iops",
1891
+ "Size",
1892
+ "Throughput",
1893
+ "VolumeType",
1894
+ "Tags"
1895
+ ])
1896
+ });
1897
+ this.rules.set("AWS::ECS::TaskDefinition", { replacementProperties: /* @__PURE__ */ new Set([
1898
+ "Family",
1899
+ "ContainerDefinitions",
1900
+ "Cpu",
1901
+ "Memory",
1902
+ "NetworkMode",
1903
+ "RequiresCompatibilities",
1904
+ "ExecutionRoleArn",
1905
+ "TaskRoleArn",
1906
+ "Volumes"
1907
+ ]) });
1908
+ this.rules.set("AWS::ECS::Service", {
1909
+ replacementProperties: /* @__PURE__ */ new Set(),
1910
+ conditionalReplacements: /* @__PURE__ */ new Map([["LaunchType", ecsServiceLaunchTypeSetOrChanged]])
1911
+ });
1912
+ this.rules.set("AWS::ElastiCache::CacheCluster", {
1913
+ replacementProperties: /* @__PURE__ */ new Set(),
1914
+ conditionalReplacements: /* @__PURE__ */ new Map([["AZMode", elastiCacheAzModeRemovedFromSingleAz], ["PreferredAvailabilityZones", elastiCachePreferredAvailabilityZonesReplaced]])
1915
+ });
1916
+ this.rules.set("AWS::EMR::Cluster", {
1917
+ replacementProperties: /* @__PURE__ */ new Set(),
1918
+ conditionalReplacements: /* @__PURE__ */ new Map([["Instances", emrClusterInstancesReplaced]])
1919
+ });
1920
+ this.rules.set("AWS::ElasticLoadBalancingV2::ListenerRule", { replacementProperties: /* @__PURE__ */ new Set(["ListenerArn"]) });
1921
+ this.logger.debug(`Initialized replacement rules for ${this.rules.size} resource types`);
1922
+ }
1923
+
1924
+ // src/analyzer/replacement-rules.ts
1925
+ var ReplacementRulesRegistry = class {
1926
+ logger = getLogger().child("ReplacementRulesRegistry");
1927
+ rules = /* @__PURE__ */ new Map();
1928
+ constructor() {
1929
+ this.initializeRules();
1930
+ }
1931
+ requiresReplacement(resourceType, propertyPath, oldValue, newValue, siblings) {
1932
+ const rule = this.rules.get(resourceType);
1933
+ if (!rule) {
1934
+ this.logger.debug(`No replacement rule for ${resourceType}, conservatively assuming replacement may be required for ${propertyPath}`);
1935
+ return false;
1936
+ }
1937
+ if (rule.replacementProperties.has(propertyPath)) {
1938
+ this.logger.debug(`Property ${propertyPath} of ${resourceType} requires replacement`);
1939
+ return true;
1940
+ }
1941
+ if (rule.updateableProperties?.has(propertyPath)) return false;
1942
+ if (rule.conditionalReplacements?.has(propertyPath)) {
1943
+ const condition = rule.conditionalReplacements.get(propertyPath);
1944
+ if (condition) {
1945
+ const requires = condition(oldValue, newValue, siblings);
1946
+ this.logger.debug(`Conditional replacement for ${propertyPath} of ${resourceType}: ${requires}`);
1947
+ return requires;
1948
+ }
1949
+ }
1950
+ return false;
1951
+ }
1952
+ conditionalReplacementVerdict(resourceType, propertyPath, oldValue, newValue, siblings) {
1953
+ const condition = this.rules.get(resourceType)?.conditionalReplacements?.get(propertyPath);
1954
+ return condition === void 0 ? void 0 : condition(oldValue, newValue, siblings);
1955
+ }
1956
+ isClassified(resourceType, propertyPath) {
1957
+ const rule = this.rules.get(resourceType);
1958
+ if (!rule) return false;
1959
+ return rule.replacementProperties.has(propertyPath) || (rule.updateableProperties?.has(propertyPath) ?? false) || (rule.conditionalReplacements?.has(propertyPath) ?? false);
1960
+ }
1961
+ initializeRules() {
1962
+ return initializeRules.call(this);
1963
+ }
1964
+ };
1965
+
1966
+ export { maskWholeValue as A, readsNoEchoSource as B, withoutObservedMaskedLeaves as C, isStaleNoEchoLeaf as D, isMarkedCoordinate as E, noEchoOutputsComparison as F, witnessNormalize as G, recordedNoEchoValuesOf as H, noEchoParameterNodesAt as I, liveMatchesUnresolvedTokenFrame as K, noEchoParametersReadBy as L, noEchoComparison as M, noEchoCoordinatesOf as N, maskAtCoordinates as O, noEchoLeavesOf as P, passedNoEchoParametersOf as R, withOffTemplateEchoesMasked as S, canonicalJson as T, replaceAtCoordinates as U, recordPassedNoEchoParameters as V, valueAtCoordinate as W, storedRecordFinisher as _, liveHoldsFreshLeaves as a, maskOffTemplateEchoes as b, blockDeviceMappingsDifferOnlyInDeleteOnTermination as c, emrClusterInstancesReplaced as d, canonicalLambdaFunctionName as f, withStoredReferencePositionsMasked as g, sameLambdaFunctionAddress as h, keyOrderFreeJson as i, maskedLeafCoordinatesOf as j, maskReadbackAtCoordinates as k, dbInstanceEngineChangeIsInPlace as l, parseLambdaFunctionAddress as m, grantSentence as n, outputMapsEqual as o, lambdaFunctionNameForMask as p, isReplacementCeiling as r, readDenialOf as s, ReplacementRulesRegistry as t, ecsServiceLaunchTypeSetOrChanged as u, templateGetAttNamesOf as v, canonicalCoordinates as w, observedMaskedLeavesOf as x, withSecretAttributeKeysDropped as y, readbackPathFor as z };
1967
+ //# sourceMappingURL=replacement-rules-roVU6gYR.js.map