@aws-cdk/toolkit-lib 0.1.6 → 0.1.8

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.
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
 
20
30
  // lib/api/shared-public.ts
@@ -23,11 +33,14 @@ __export(shared_public_exports, {
23
33
  AssemblyError: () => AssemblyError,
24
34
  AuthenticationError: () => AuthenticationError,
25
35
  ContextProviderError: () => ContextProviderError,
36
+ DiffFormatter: () => DiffFormatter,
26
37
  ExpandStackSelection: () => ExpandStackSelection,
38
+ NonHotswappableReason: () => NonHotswappableReason,
27
39
  PermissionChangeType: () => PermissionChangeType,
28
40
  RequireApproval: () => RequireApproval,
29
41
  StackSelectionStrategy: () => StackSelectionStrategy,
30
- ToolkitError: () => ToolkitError
42
+ ToolkitError: () => ToolkitError,
43
+ removeNonImportResources: () => removeNonImportResources
31
44
  });
32
45
  module.exports = __toCommonJS(shared_public_exports);
33
46
 
@@ -48,13 +61,19 @@ var ExpandStackSelection = /* @__PURE__ */ ((ExpandStackSelection2) => {
48
61
  return ExpandStackSelection2;
49
62
  })(ExpandStackSelection || {});
50
63
 
51
- // ../tmp-toolkit-helpers/src/api/io/payloads/diff.ts
52
- var PermissionChangeType = /* @__PURE__ */ ((PermissionChangeType2) => {
53
- PermissionChangeType2["NONE"] = "none";
54
- PermissionChangeType2["BROADENING"] = "broadening";
55
- PermissionChangeType2["NON_BROADENING"] = "non-broadening";
56
- return PermissionChangeType2;
57
- })(PermissionChangeType || {});
64
+ // ../tmp-toolkit-helpers/src/api/diff/diff-formatter.ts
65
+ var import_node_util = require("node:util");
66
+ var import_stream = require("stream");
67
+ var cxschema = __toESM(require("@aws-cdk/cloud-assembly-schema"));
68
+ var import_cloudformation_diff = require("@aws-cdk/cloudformation-diff");
69
+ var chalk = __toESM(require("chalk"));
70
+
71
+ // ../tmp-toolkit-helpers/src/api/io/private/span.ts
72
+ var uuid = __toESM(require("uuid"));
73
+
74
+ // ../tmp-toolkit-helpers/src/util/archive.ts
75
+ var glob = __toESM(require("glob"));
76
+ var archiver = require("archiver");
58
77
 
59
78
  // ../tmp-toolkit-helpers/src/api/toolkit-error.ts
60
79
  var TOOLKIT_ERROR_SYMBOL = Symbol.for("@aws-cdk/toolkit-lib.ToolkitError");
@@ -86,6 +105,12 @@ var ToolkitError = class _ToolkitError extends Error {
86
105
  static isContextProviderError(x) {
87
106
  return this.isToolkitError(x) && CONTEXT_PROVIDER_ERROR_SYMBOL in x;
88
107
  }
108
+ /**
109
+ * An AssemblyError with an original error as cause
110
+ */
111
+ static withCause(message2, error2) {
112
+ return new _ToolkitError(message2, "toolkit", error2);
113
+ }
89
114
  /**
90
115
  * The type of the error, defaults to "toolkit".
91
116
  */
@@ -94,13 +119,18 @@ var ToolkitError = class _ToolkitError extends Error {
94
119
  * Denotes the source of the error as the toolkit.
95
120
  */
96
121
  source;
97
- constructor(message, type = "toolkit") {
98
- super(message);
122
+ /**
123
+ * The specific original cause of the error, if available
124
+ */
125
+ cause;
126
+ constructor(message2, type = "toolkit", cause) {
127
+ super(message2);
99
128
  Object.setPrototypeOf(this, _ToolkitError.prototype);
100
129
  Object.defineProperty(this, TOOLKIT_ERROR_SYMBOL, { value: true });
101
130
  this.name = new.target.name;
102
131
  this.type = type;
103
132
  this.source = "toolkit";
133
+ this.cause = cause;
104
134
  }
105
135
  };
106
136
  var AuthenticationError = class _AuthenticationError extends ToolkitError {
@@ -108,8 +138,8 @@ var AuthenticationError = class _AuthenticationError extends ToolkitError {
108
138
  * Denotes the source of the error as user.
109
139
  */
110
140
  source = "user";
111
- constructor(message) {
112
- super(message, "authentication");
141
+ constructor(message2) {
142
+ super(message2, "authentication");
113
143
  Object.setPrototypeOf(this, _AuthenticationError.prototype);
114
144
  Object.defineProperty(this, AUTHENTICATION_ERROR_SYMBOL, { value: true });
115
145
  }
@@ -118,14 +148,14 @@ var AssemblyError = class _AssemblyError extends ToolkitError {
118
148
  /**
119
149
  * An AssemblyError with an original error as cause
120
150
  */
121
- static withCause(message, error) {
122
- return new _AssemblyError(message, void 0, error);
151
+ static withCause(message2, error2) {
152
+ return new _AssemblyError(message2, void 0, error2);
123
153
  }
124
154
  /**
125
155
  * An AssemblyError with a list of stacks as cause
126
156
  */
127
- static withStacks(message, stacks) {
128
- return new _AssemblyError(message, stacks);
157
+ static withStacks(message2, stacks) {
158
+ return new _AssemblyError(message2, stacks);
129
159
  }
130
160
  /**
131
161
  * Denotes the source of the error as user.
@@ -138,16 +168,11 @@ var AssemblyError = class _AssemblyError extends ToolkitError {
138
168
  * Absence indicates synthesis didn't fully complete.
139
169
  */
140
170
  stacks;
141
- /**
142
- * The specific original cause of the error, if available
143
- */
144
- cause;
145
- constructor(message, stacks, cause) {
146
- super(message, "assembly");
171
+ constructor(message2, stacks, cause) {
172
+ super(message2, "assembly", cause);
147
173
  Object.setPrototypeOf(this, _AssemblyError.prototype);
148
174
  Object.defineProperty(this, ASSEMBLY_ERROR_SYMBOL, { value: true });
149
175
  this.stacks = stacks;
150
- this.cause = cause;
151
176
  }
152
177
  };
153
178
  var ContextProviderError = class _ContextProviderError extends ToolkitError {
@@ -155,13 +180,662 @@ var ContextProviderError = class _ContextProviderError extends ToolkitError {
155
180
  * Denotes the source of the error as user.
156
181
  */
157
182
  source = "user";
158
- constructor(message) {
159
- super(message, "context-provider");
183
+ constructor(message2) {
184
+ super(message2, "context-provider");
160
185
  Object.setPrototypeOf(this, _ContextProviderError.prototype);
161
186
  Object.defineProperty(this, CONTEXT_PROVIDER_ERROR_SYMBOL, { value: true });
162
187
  }
163
188
  };
164
189
 
190
+ // ../tmp-toolkit-helpers/src/util/types.ts
191
+ var isArray = Array.isArray;
192
+
193
+ // ../tmp-toolkit-helpers/src/util/yaml-cfn.ts
194
+ var yaml = __toESM(require("yaml"));
195
+ var yaml_types = __toESM(require("yaml/types"));
196
+ function makeTagForCfnIntrinsic(intrinsicName, addFnPrefix) {
197
+ return {
198
+ identify(value) {
199
+ return typeof value === "string";
200
+ },
201
+ tag: `!${intrinsicName}`,
202
+ resolve: (_doc, cstNode) => {
203
+ const ret = {};
204
+ ret[addFnPrefix ? `Fn::${intrinsicName}` : intrinsicName] = // the +1 is to account for the ! the short form begins with
205
+ parseYamlStrWithCfnTags(cstNode.toString().substring(intrinsicName.length + 1));
206
+ return ret;
207
+ }
208
+ };
209
+ }
210
+ var shortForms = [
211
+ "Base64",
212
+ "Cidr",
213
+ "FindInMap",
214
+ "GetAZs",
215
+ "ImportValue",
216
+ "Join",
217
+ "Sub",
218
+ "Select",
219
+ "Split",
220
+ "Transform",
221
+ "And",
222
+ "Equals",
223
+ "If",
224
+ "Not",
225
+ "Or",
226
+ "GetAtt"
227
+ ].map((name) => makeTagForCfnIntrinsic(name, true)).concat(
228
+ makeTagForCfnIntrinsic("Ref", false),
229
+ makeTagForCfnIntrinsic("Condition", false)
230
+ );
231
+ function parseYamlStrWithCfnTags(text) {
232
+ return yaml.parse(text, {
233
+ customTags: shortForms,
234
+ schema: "core"
235
+ });
236
+ }
237
+
238
+ // ../tmp-toolkit-helpers/src/util/version-range.ts
239
+ var semver = __toESM(require("semver"));
240
+
241
+ // ../tmp-toolkit-helpers/src/api/io/private/level-priority.ts
242
+ var levels = [
243
+ "trace",
244
+ "debug",
245
+ "info",
246
+ "warn",
247
+ "result",
248
+ "error"
249
+ ];
250
+ var orderedLevels = Object.fromEntries(Object.entries(levels).map((a) => a.reverse()));
251
+
252
+ // ../tmp-toolkit-helpers/src/api/io/private/message-maker.ts
253
+ function message(level, details) {
254
+ const maker = (text, data) => ({
255
+ time: /* @__PURE__ */ new Date(),
256
+ level,
257
+ code: details.code,
258
+ message: text,
259
+ data
260
+ });
261
+ return {
262
+ ...details,
263
+ level,
264
+ msg: maker,
265
+ is: (m) => m.code === details.code
266
+ };
267
+ }
268
+ var trace = (details) => message("trace", details);
269
+ var debug = (details) => message("debug", details);
270
+ var info = (details) => message("info", details);
271
+ var warn = (details) => message("warn", details);
272
+ var error = (details) => message("error", details);
273
+ var result = (details) => message("result", details);
274
+ function request(level, details) {
275
+ const maker = (text, data) => ({
276
+ time: /* @__PURE__ */ new Date(),
277
+ level,
278
+ code: details.code,
279
+ message: text,
280
+ data,
281
+ defaultResponse: details.defaultResponse
282
+ });
283
+ return {
284
+ ...details,
285
+ level,
286
+ req: maker
287
+ };
288
+ }
289
+ var confirm = (details) => request("info", {
290
+ ...details,
291
+ defaultResponse: true
292
+ });
293
+
294
+ // ../tmp-toolkit-helpers/src/api/io/private/messages.ts
295
+ var IO = {
296
+ // Defaults (0000)
297
+ DEFAULT_TOOLKIT_INFO: info({
298
+ code: "CDK_TOOLKIT_I0000",
299
+ description: "Default info messages emitted from the Toolkit"
300
+ }),
301
+ DEFAULT_TOOLKIT_DEBUG: debug({
302
+ code: "CDK_TOOLKIT_I0000",
303
+ description: "Default debug messages emitted from the Toolkit"
304
+ }),
305
+ DEFAULT_TOOLKIT_WARN: warn({
306
+ code: "CDK_TOOLKIT_W0000",
307
+ description: "Default warning messages emitted from the Toolkit"
308
+ }),
309
+ DEFAULT_TOOLKIT_ERROR: error({
310
+ code: "CDK_TOOLKIT_E0000",
311
+ description: "Default error messages emitted from the Toolkit"
312
+ }),
313
+ DEFAULT_TOOLKIT_TRACE: trace({
314
+ code: "CDK_TOOLKIT_I0000",
315
+ description: "Default trace messages emitted from the Toolkit"
316
+ }),
317
+ // 1: Synth (1xxx)
318
+ CDK_TOOLKIT_I1000: info({
319
+ code: "CDK_TOOLKIT_I1000",
320
+ description: "Provides synthesis times.",
321
+ interface: "Duration"
322
+ }),
323
+ CDK_TOOLKIT_I1001: trace({
324
+ code: "CDK_TOOLKIT_I1001",
325
+ description: "Cloud Assembly synthesis is starting",
326
+ interface: "StackSelectionDetails"
327
+ }),
328
+ CDK_TOOLKIT_I1901: result({
329
+ code: "CDK_TOOLKIT_I1901",
330
+ description: "Provides stack data",
331
+ interface: "StackAndAssemblyData"
332
+ }),
333
+ CDK_TOOLKIT_I1902: result({
334
+ code: "CDK_TOOLKIT_I1902",
335
+ description: "Successfully deployed stacks",
336
+ interface: "AssemblyData"
337
+ }),
338
+ // 2: List (2xxx)
339
+ CDK_TOOLKIT_I2901: result({
340
+ code: "CDK_TOOLKIT_I2901",
341
+ description: "Provides details on the selected stacks and their dependencies",
342
+ interface: "StackDetailsPayload"
343
+ }),
344
+ // 3: Import & Migrate
345
+ CDK_TOOLKIT_E3900: error({
346
+ code: "CDK_TOOLKIT_E3900",
347
+ description: "Resource import failed",
348
+ interface: "ErrorPayload"
349
+ }),
350
+ // 4: Diff (4xxx)
351
+ CDK_TOOLKIT_I4000: trace({
352
+ code: "CDK_TOOLKIT_I4000",
353
+ description: "Diff stacks is starting",
354
+ interface: "StackSelectionDetails"
355
+ }),
356
+ CDK_TOOLKIT_I4001: info({
357
+ code: "CDK_TOOLKIT_I4001",
358
+ description: "Output of the diff command",
359
+ interface: "DiffResult"
360
+ }),
361
+ // 5: Deploy & Watch (5xxx)
362
+ CDK_TOOLKIT_I5000: info({
363
+ code: "CDK_TOOLKIT_I5000",
364
+ description: "Provides deployment times",
365
+ interface: "Duration"
366
+ }),
367
+ CDK_TOOLKIT_I5001: info({
368
+ code: "CDK_TOOLKIT_I5001",
369
+ description: "Provides total time in deploy action, including synth and rollback",
370
+ interface: "Duration"
371
+ }),
372
+ CDK_TOOLKIT_I5002: info({
373
+ code: "CDK_TOOLKIT_I5002",
374
+ description: "Provides time for resource migration",
375
+ interface: "Duration"
376
+ }),
377
+ CDK_TOOLKIT_W5021: warn({
378
+ code: "CDK_TOOLKIT_W5021",
379
+ description: "Empty non-existent stack, deployment is skipped"
380
+ }),
381
+ CDK_TOOLKIT_W5022: warn({
382
+ code: "CDK_TOOLKIT_W5022",
383
+ description: "Empty existing stack, stack will be destroyed"
384
+ }),
385
+ CDK_TOOLKIT_I5031: info({
386
+ code: "CDK_TOOLKIT_I5031",
387
+ description: "Informs about any log groups that are traced as part of the deployment"
388
+ }),
389
+ CDK_TOOLKIT_I5032: debug({
390
+ code: "CDK_TOOLKIT_I5032",
391
+ description: "Start monitoring log groups",
392
+ interface: "CloudWatchLogMonitorControlEvent"
393
+ }),
394
+ CDK_TOOLKIT_I5033: info({
395
+ code: "CDK_TOOLKIT_I5033",
396
+ description: "A log event received from Cloud Watch",
397
+ interface: "CloudWatchLogEvent"
398
+ }),
399
+ CDK_TOOLKIT_I5034: debug({
400
+ code: "CDK_TOOLKIT_I5034",
401
+ description: "Stop monitoring log groups",
402
+ interface: "CloudWatchLogMonitorControlEvent"
403
+ }),
404
+ CDK_TOOLKIT_E5035: error({
405
+ code: "CDK_TOOLKIT_E5035",
406
+ description: "A log monitoring error",
407
+ interface: "ErrorPayload"
408
+ }),
409
+ CDK_TOOLKIT_I5050: confirm({
410
+ code: "CDK_TOOLKIT_I5050",
411
+ description: "Confirm rollback during deployment",
412
+ interface: "ConfirmationRequest"
413
+ }),
414
+ CDK_TOOLKIT_I5060: confirm({
415
+ code: "CDK_TOOLKIT_I5060",
416
+ description: "Confirm deploy security sensitive changes",
417
+ interface: "DeployConfirmationRequest"
418
+ }),
419
+ CDK_TOOLKIT_I5100: info({
420
+ code: "CDK_TOOLKIT_I5100",
421
+ description: "Stack deploy progress",
422
+ interface: "StackDeployProgress"
423
+ }),
424
+ // Assets (52xx)
425
+ CDK_TOOLKIT_I5210: trace({
426
+ code: "CDK_TOOLKIT_I5210",
427
+ description: "Started building a specific asset",
428
+ interface: "BuildAsset"
429
+ }),
430
+ CDK_TOOLKIT_I5211: trace({
431
+ code: "CDK_TOOLKIT_I5211",
432
+ description: "Building the asset has completed",
433
+ interface: "Duration"
434
+ }),
435
+ CDK_TOOLKIT_I5220: trace({
436
+ code: "CDK_TOOLKIT_I5220",
437
+ description: "Started publishing a specific asset",
438
+ interface: "PublishAsset"
439
+ }),
440
+ CDK_TOOLKIT_I5221: trace({
441
+ code: "CDK_TOOLKIT_I5221",
442
+ description: "Publishing the asset has completed",
443
+ interface: "Duration"
444
+ }),
445
+ // Watch (53xx)
446
+ CDK_TOOLKIT_I5310: debug({
447
+ code: "CDK_TOOLKIT_I5310",
448
+ description: "The computed settings used for file watching",
449
+ interface: "WatchSettings"
450
+ }),
451
+ CDK_TOOLKIT_I5311: info({
452
+ code: "CDK_TOOLKIT_I5311",
453
+ description: "File watching started",
454
+ interface: "FileWatchEvent"
455
+ }),
456
+ CDK_TOOLKIT_I5312: info({
457
+ code: "CDK_TOOLKIT_I5312",
458
+ description: "File event detected, starting deployment",
459
+ interface: "FileWatchEvent"
460
+ }),
461
+ CDK_TOOLKIT_I5313: info({
462
+ code: "CDK_TOOLKIT_I5313",
463
+ description: "File event detected during active deployment, changes are queued",
464
+ interface: "FileWatchEvent"
465
+ }),
466
+ CDK_TOOLKIT_I5314: info({
467
+ code: "CDK_TOOLKIT_I5314",
468
+ description: "Initial watch deployment started"
469
+ }),
470
+ CDK_TOOLKIT_I5315: info({
471
+ code: "CDK_TOOLKIT_I5315",
472
+ description: "Queued watch deployment started"
473
+ }),
474
+ // Hotswap (54xx)
475
+ CDK_TOOLKIT_I5400: trace({
476
+ code: "CDK_TOOLKIT_I5400",
477
+ description: "Attempting a hotswap deployment",
478
+ interface: "HotswapDeploymentAttempt"
479
+ }),
480
+ CDK_TOOLKIT_I5401: trace({
481
+ code: "CDK_TOOLKIT_I5401",
482
+ description: "Computed details for the hotswap deployment",
483
+ interface: "HotswapDeploymentDetails"
484
+ }),
485
+ CDK_TOOLKIT_I5402: info({
486
+ code: "CDK_TOOLKIT_I5402",
487
+ description: "A hotswappable change is processed as part of a hotswap deployment",
488
+ interface: "HotswappableChange"
489
+ }),
490
+ CDK_TOOLKIT_I5403: info({
491
+ code: "CDK_TOOLKIT_I5403",
492
+ description: "The hotswappable change has completed processing",
493
+ interface: "HotswappableChange"
494
+ }),
495
+ CDK_TOOLKIT_I5410: info({
496
+ code: "CDK_TOOLKIT_I5410",
497
+ description: "Hotswap deployment has ended, a full deployment might still follow if needed",
498
+ interface: "HotswapResult"
499
+ }),
500
+ // Stack Monitor (55xx)
501
+ CDK_TOOLKIT_I5501: info({
502
+ code: "CDK_TOOLKIT_I5501",
503
+ description: "Stack Monitoring: Start monitoring of a single stack",
504
+ interface: "StackMonitoringControlEvent"
505
+ }),
506
+ CDK_TOOLKIT_I5502: info({
507
+ code: "CDK_TOOLKIT_I5502",
508
+ description: "Stack Monitoring: Activity event for a single stack",
509
+ interface: "StackActivity"
510
+ }),
511
+ CDK_TOOLKIT_I5503: info({
512
+ code: "CDK_TOOLKIT_I5503",
513
+ description: "Stack Monitoring: Finished monitoring of a single stack",
514
+ interface: "StackMonitoringControlEvent"
515
+ }),
516
+ // Success (59xx)
517
+ CDK_TOOLKIT_I5900: result({
518
+ code: "CDK_TOOLKIT_I5900",
519
+ description: "Deployment results on success",
520
+ interface: "SuccessfulDeployStackResult"
521
+ }),
522
+ CDK_TOOLKIT_I5901: info({
523
+ code: "CDK_TOOLKIT_I5901",
524
+ description: "Generic deployment success messages"
525
+ }),
526
+ CDK_TOOLKIT_W5400: warn({
527
+ code: "CDK_TOOLKIT_W5400",
528
+ description: "Hotswap disclosure message"
529
+ }),
530
+ // errors
531
+ CDK_TOOLKIT_E5001: error({
532
+ code: "CDK_TOOLKIT_E5001",
533
+ description: "No stacks found"
534
+ }),
535
+ CDK_TOOLKIT_E5500: error({
536
+ code: "CDK_TOOLKIT_E5500",
537
+ description: "Stack Monitoring error",
538
+ interface: "ErrorPayload"
539
+ }),
540
+ // 6: Rollback (6xxx)
541
+ CDK_TOOLKIT_I6000: info({
542
+ code: "CDK_TOOLKIT_I6000",
543
+ description: "Provides rollback times",
544
+ interface: "Duration"
545
+ }),
546
+ CDK_TOOLKIT_I6100: info({
547
+ code: "CDK_TOOLKIT_I6100",
548
+ description: "Stack rollback progress",
549
+ interface: "StackRollbackProgress"
550
+ }),
551
+ CDK_TOOLKIT_E6001: error({
552
+ code: "CDK_TOOLKIT_E6001",
553
+ description: "No stacks found"
554
+ }),
555
+ CDK_TOOLKIT_E6900: error({
556
+ code: "CDK_TOOLKIT_E6900",
557
+ description: "Rollback failed",
558
+ interface: "ErrorPayload"
559
+ }),
560
+ // 7: Destroy (7xxx)
561
+ CDK_TOOLKIT_I7000: info({
562
+ code: "CDK_TOOLKIT_I7000",
563
+ description: "Provides destroy times",
564
+ interface: "Duration"
565
+ }),
566
+ CDK_TOOLKIT_I7001: trace({
567
+ code: "CDK_TOOLKIT_I7001",
568
+ description: "Provides destroy time for a single stack",
569
+ interface: "Duration"
570
+ }),
571
+ CDK_TOOLKIT_I7010: confirm({
572
+ code: "CDK_TOOLKIT_I7010",
573
+ description: "Confirm destroy stacks",
574
+ interface: "ConfirmationRequest"
575
+ }),
576
+ CDK_TOOLKIT_I7100: info({
577
+ code: "CDK_TOOLKIT_I7100",
578
+ description: "Stack destroy progress",
579
+ interface: "StackDestroyProgress"
580
+ }),
581
+ CDK_TOOLKIT_I7101: trace({
582
+ code: "CDK_TOOLKIT_I7101",
583
+ description: "Start stack destroying",
584
+ interface: "StackDestroy"
585
+ }),
586
+ CDK_TOOLKIT_I7900: result({
587
+ code: "CDK_TOOLKIT_I7900",
588
+ description: "Stack deletion succeeded",
589
+ interface: "cxapi.CloudFormationStackArtifact"
590
+ }),
591
+ CDK_TOOLKIT_E7010: error({
592
+ code: "CDK_TOOLKIT_E7010",
593
+ description: "Action was aborted due to negative confirmation of request"
594
+ }),
595
+ CDK_TOOLKIT_E7900: error({
596
+ code: "CDK_TOOLKIT_E7900",
597
+ description: "Stack deletion failed",
598
+ interface: "ErrorPayload"
599
+ }),
600
+ // 9: Bootstrap (9xxx)
601
+ CDK_TOOLKIT_I9000: info({
602
+ code: "CDK_TOOLKIT_I9000",
603
+ description: "Provides bootstrap times",
604
+ interface: "Duration"
605
+ }),
606
+ CDK_TOOLKIT_I9100: info({
607
+ code: "CDK_TOOLKIT_I9100",
608
+ description: "Bootstrap progress",
609
+ interface: "BootstrapEnvironmentProgress"
610
+ }),
611
+ CDK_TOOLKIT_I9900: result({
612
+ code: "CDK_TOOLKIT_I9900",
613
+ description: "Bootstrap results on success",
614
+ interface: "cxapi.Environment"
615
+ }),
616
+ CDK_TOOLKIT_E9900: error({
617
+ code: "CDK_TOOLKIT_E9900",
618
+ description: "Bootstrap failed",
619
+ interface: "ErrorPayload"
620
+ }),
621
+ // Notices
622
+ CDK_TOOLKIT_I0100: info({
623
+ code: "CDK_TOOLKIT_I0100",
624
+ description: "Notices decoration (the header or footer of a list of notices)"
625
+ }),
626
+ CDK_TOOLKIT_W0101: warn({
627
+ code: "CDK_TOOLKIT_W0101",
628
+ description: "A notice that is marked as a warning"
629
+ }),
630
+ CDK_TOOLKIT_E0101: error({
631
+ code: "CDK_TOOLKIT_E0101",
632
+ description: "A notice that is marked as an error"
633
+ }),
634
+ CDK_TOOLKIT_I0101: info({
635
+ code: "CDK_TOOLKIT_I0101",
636
+ description: "A notice that is marked as informational"
637
+ }),
638
+ // Assembly codes
639
+ DEFAULT_ASSEMBLY_TRACE: trace({
640
+ code: "CDK_ASSEMBLY_I0000",
641
+ description: "Default trace messages emitted from Cloud Assembly operations"
642
+ }),
643
+ DEFAULT_ASSEMBLY_DEBUG: debug({
644
+ code: "CDK_ASSEMBLY_I0000",
645
+ description: "Default debug messages emitted from Cloud Assembly operations"
646
+ }),
647
+ DEFAULT_ASSEMBLY_INFO: info({
648
+ code: "CDK_ASSEMBLY_I0000",
649
+ description: "Default info messages emitted from Cloud Assembly operations"
650
+ }),
651
+ DEFAULT_ASSEMBLY_WARN: warn({
652
+ code: "CDK_ASSEMBLY_W0000",
653
+ description: "Default warning messages emitted from Cloud Assembly operations"
654
+ }),
655
+ CDK_ASSEMBLY_I0010: debug({
656
+ code: "CDK_ASSEMBLY_I0010",
657
+ description: "Generic environment preparation debug messages"
658
+ }),
659
+ CDK_ASSEMBLY_W0010: warn({
660
+ code: "CDK_ASSEMBLY_W0010",
661
+ description: "Emitted if the found framework version does not support context overflow"
662
+ }),
663
+ CDK_ASSEMBLY_I0042: debug({
664
+ code: "CDK_ASSEMBLY_I0042",
665
+ description: "Writing updated context",
666
+ interface: "UpdatedContext"
667
+ }),
668
+ CDK_ASSEMBLY_I0240: debug({
669
+ code: "CDK_ASSEMBLY_I0240",
670
+ description: "Context lookup was stopped as no further progress was made. ",
671
+ interface: "MissingContext"
672
+ }),
673
+ CDK_ASSEMBLY_I0241: debug({
674
+ code: "CDK_ASSEMBLY_I0241",
675
+ description: "Fetching missing context. This is an iterative message that may appear multiple times with different missing keys.",
676
+ interface: "MissingContext"
677
+ }),
678
+ CDK_ASSEMBLY_I1000: debug({
679
+ code: "CDK_ASSEMBLY_I1000",
680
+ description: "Cloud assembly output starts"
681
+ }),
682
+ CDK_ASSEMBLY_I1001: info({
683
+ code: "CDK_ASSEMBLY_I1001",
684
+ description: "Output lines emitted by the cloud assembly to stdout"
685
+ }),
686
+ CDK_ASSEMBLY_E1002: error({
687
+ code: "CDK_ASSEMBLY_E1002",
688
+ description: "Output lines emitted by the cloud assembly to stderr"
689
+ }),
690
+ CDK_ASSEMBLY_I1003: info({
691
+ code: "CDK_ASSEMBLY_I1003",
692
+ description: "Cloud assembly output finished"
693
+ }),
694
+ CDK_ASSEMBLY_E1111: error({
695
+ code: "CDK_ASSEMBLY_E1111",
696
+ description: "Incompatible CDK CLI version. Upgrade needed.",
697
+ interface: "ErrorPayload"
698
+ }),
699
+ CDK_ASSEMBLY_I0150: debug({
700
+ code: "CDK_ASSEMBLY_I0150",
701
+ description: "Indicates the use of a pre-synthesized cloud assembly directory"
702
+ }),
703
+ CDK_ASSEMBLY_I0300: info({
704
+ code: "CDK_ASSEMBLY_I0300",
705
+ description: "An info message emitted by a Context Provider",
706
+ interface: "ContextProviderMessageSource"
707
+ }),
708
+ CDK_ASSEMBLY_I0301: debug({
709
+ code: "CDK_ASSEMBLY_I0301",
710
+ description: "A debug message emitted by a Context Provider",
711
+ interface: "ContextProviderMessageSource"
712
+ }),
713
+ // Assembly Annotations
714
+ CDK_ASSEMBLY_I9999: info({
715
+ code: "CDK_ASSEMBLY_I9999",
716
+ description: "Annotations emitted by the cloud assembly",
717
+ interface: "cxapi.SynthesisMessage"
718
+ }),
719
+ CDK_ASSEMBLY_W9999: warn({
720
+ code: "CDK_ASSEMBLY_W9999",
721
+ description: "Warnings emitted by the cloud assembly",
722
+ interface: "cxapi.SynthesisMessage"
723
+ }),
724
+ CDK_ASSEMBLY_E9999: error({
725
+ code: "CDK_ASSEMBLY_E9999",
726
+ description: "Errors emitted by the cloud assembly",
727
+ interface: "cxapi.SynthesisMessage"
728
+ }),
729
+ // SDK codes
730
+ CDK_SDK_I0000: trace({
731
+ code: "CDK_SDK_I0000",
732
+ description: "An SDK message."
733
+ }),
734
+ CDK_SDK_I0100: trace({
735
+ code: "CDK_SDK_I0100",
736
+ description: "An SDK trace. SDK traces are emitted as traces to the IoHost, but contain the original SDK logging level.",
737
+ interface: "SdkTrace"
738
+ })
739
+ };
740
+ var SPAN = {
741
+ SYNTH_ASSEMBLY: {
742
+ name: "Synthesis",
743
+ start: IO.CDK_TOOLKIT_I1001,
744
+ end: IO.CDK_TOOLKIT_I1000
745
+ },
746
+ DEPLOY_STACK: {
747
+ name: "Deployment",
748
+ start: IO.CDK_TOOLKIT_I5100,
749
+ end: IO.CDK_TOOLKIT_I5001
750
+ },
751
+ ROLLBACK_STACK: {
752
+ name: "Rollback",
753
+ start: IO.CDK_TOOLKIT_I6100,
754
+ end: IO.CDK_TOOLKIT_I6000
755
+ },
756
+ DIFF_STACK: {
757
+ name: "Diff",
758
+ start: IO.CDK_TOOLKIT_I4000,
759
+ end: IO.CDK_TOOLKIT_I4001
760
+ },
761
+ DESTROY_STACK: {
762
+ name: "Destroy",
763
+ start: IO.CDK_TOOLKIT_I7100,
764
+ end: IO.CDK_TOOLKIT_I7001
765
+ },
766
+ DESTROY_ACTION: {
767
+ name: "Destroy",
768
+ start: IO.CDK_TOOLKIT_I7101,
769
+ end: IO.CDK_TOOLKIT_I7000
770
+ },
771
+ BOOTSTRAP_SINGLE: {
772
+ name: "Bootstrap",
773
+ start: IO.CDK_TOOLKIT_I9100,
774
+ end: IO.CDK_TOOLKIT_I9000
775
+ },
776
+ BUILD_ASSET: {
777
+ name: "Build Asset",
778
+ start: IO.CDK_TOOLKIT_I5210,
779
+ end: IO.CDK_TOOLKIT_I5211
780
+ },
781
+ PUBLISH_ASSET: {
782
+ name: "Publish Asset",
783
+ start: IO.CDK_TOOLKIT_I5220,
784
+ end: IO.CDK_TOOLKIT_I5221
785
+ },
786
+ HOTSWAP: {
787
+ name: "hotswap-deployment",
788
+ start: IO.CDK_TOOLKIT_I5400,
789
+ end: IO.CDK_TOOLKIT_I5410
790
+ }
791
+ };
792
+
793
+ // ../tmp-toolkit-helpers/src/api/io/private/io-default-messages.ts
794
+ var util = __toESM(require("util"));
795
+ var IoDefaultMessages = class {
796
+ constructor(ioHelper) {
797
+ this.ioHelper = ioHelper;
798
+ }
799
+ notify(msg) {
800
+ return this.ioHelper.notify(msg);
801
+ }
802
+ requestResponse(msg) {
803
+ return this.ioHelper.requestResponse(msg);
804
+ }
805
+ error(input, ...args) {
806
+ this.emitMessage(IO.DEFAULT_TOOLKIT_ERROR, input, ...args);
807
+ }
808
+ warn(input, ...args) {
809
+ this.emitMessage(IO.DEFAULT_TOOLKIT_WARN, input, ...args);
810
+ }
811
+ warning(input, ...args) {
812
+ this.emitMessage(IO.DEFAULT_TOOLKIT_WARN, input, ...args);
813
+ }
814
+ info(input, ...args) {
815
+ this.emitMessage(IO.DEFAULT_TOOLKIT_INFO, input, ...args);
816
+ }
817
+ debug(input, ...args) {
818
+ this.emitMessage(IO.DEFAULT_TOOLKIT_DEBUG, input, ...args);
819
+ }
820
+ trace(input, ...args) {
821
+ this.emitMessage(IO.DEFAULT_TOOLKIT_TRACE, input, ...args);
822
+ }
823
+ result(input, ...args) {
824
+ const message2 = args.length > 0 ? util.format(input, ...args) : input;
825
+ void this.ioHelper.notify({
826
+ time: /* @__PURE__ */ new Date(),
827
+ code: IO.DEFAULT_TOOLKIT_INFO.code,
828
+ level: "result",
829
+ message: message2,
830
+ data: void 0
831
+ });
832
+ }
833
+ emitMessage(maker, input, ...args) {
834
+ const message2 = args.length > 0 ? util.format(input, ...args) : input;
835
+ void this.ioHelper.notify(maker.msg(message2));
836
+ }
837
+ };
838
+
165
839
  // ../tmp-toolkit-helpers/src/api/require-approval.ts
166
840
  var RequireApproval = /* @__PURE__ */ ((RequireApproval2) => {
167
841
  RequireApproval2["NEVER"] = "never";
@@ -169,15 +843,231 @@ var RequireApproval = /* @__PURE__ */ ((RequireApproval2) => {
169
843
  RequireApproval2["BROADENING"] = "broadening";
170
844
  return RequireApproval2;
171
845
  })(RequireApproval || {});
846
+
847
+ // ../tmp-toolkit-helpers/src/api/diff/diff-formatter.ts
848
+ var StringWriteStream = class extends import_stream.Writable {
849
+ buffer = [];
850
+ constructor() {
851
+ super();
852
+ }
853
+ _write(chunk, _encoding, callback) {
854
+ this.buffer.push(chunk.toString());
855
+ callback();
856
+ }
857
+ toString() {
858
+ return this.buffer.join("");
859
+ }
860
+ };
861
+ var DiffFormatter = class {
862
+ ioHelper;
863
+ oldTemplate;
864
+ newTemplate;
865
+ constructor(props) {
866
+ this.ioHelper = props.ioHelper;
867
+ this.oldTemplate = props.oldTemplate;
868
+ this.newTemplate = props.newTemplate;
869
+ }
870
+ /**
871
+ * Format the stack diff
872
+ */
873
+ formatStackDiff(options) {
874
+ const ioDefaultHelper = new IoDefaultMessages(this.ioHelper);
875
+ return this.formatStackDiffHelper(
876
+ this.oldTemplate,
877
+ options.stackName,
878
+ options.nestedStackTemplates,
879
+ {
880
+ ...options,
881
+ ioDefaultHelper
882
+ }
883
+ );
884
+ }
885
+ formatStackDiffHelper(oldTemplate, stackName, nestedStackTemplates, options) {
886
+ let diff = (0, import_cloudformation_diff.fullDiff)(oldTemplate, this.newTemplate.template, options.changeSet, options.isImport);
887
+ const stream = new StringWriteStream();
888
+ let numStacksWithChanges = 0;
889
+ let formattedDiff = "";
890
+ let filteredChangesCount = 0;
891
+ try {
892
+ if (stackName && (!options.quiet || !diff.isEmpty)) {
893
+ stream.write((0, import_node_util.format)(`Stack ${chalk.bold(stackName)}
894
+ `));
895
+ }
896
+ if (!options.quiet && options.isImport) {
897
+ stream.write("Parameters and rules created during migration do not affect resource configuration.\n");
898
+ }
899
+ if (diff.differenceCount && !options.strict) {
900
+ const mangledNewTemplate = JSON.parse((0, import_cloudformation_diff.mangleLikeCloudFormation)(JSON.stringify(this.newTemplate.template)));
901
+ const mangledDiff = (0, import_cloudformation_diff.fullDiff)(this.oldTemplate, mangledNewTemplate, options.changeSet);
902
+ filteredChangesCount = Math.max(0, diff.differenceCount - mangledDiff.differenceCount);
903
+ if (filteredChangesCount > 0) {
904
+ diff = mangledDiff;
905
+ }
906
+ }
907
+ if (!options.strict) {
908
+ obscureDiff(diff);
909
+ }
910
+ if (!diff.isEmpty) {
911
+ numStacksWithChanges++;
912
+ (0, import_cloudformation_diff.formatDifferences)(stream, diff, {
913
+ ...logicalIdMapFromTemplate(this.oldTemplate),
914
+ ...buildLogicalToPathMap(this.newTemplate)
915
+ }, options.context);
916
+ } else if (!options.quiet) {
917
+ stream.write(chalk.green("There were no differences\n"));
918
+ }
919
+ if (filteredChangesCount > 0) {
920
+ stream.write(chalk.yellow(`Omitted ${filteredChangesCount} changes because they are likely mangled non-ASCII characters. Use --strict to print them.
921
+ `));
922
+ }
923
+ } finally {
924
+ formattedDiff = stream.toString();
925
+ stream.end();
926
+ }
927
+ for (const nestedStackLogicalId of Object.keys(nestedStackTemplates ?? {})) {
928
+ if (!nestedStackTemplates) {
929
+ break;
930
+ }
931
+ const nestedStack = nestedStackTemplates[nestedStackLogicalId];
932
+ this.newTemplate._template = nestedStack.generatedTemplate;
933
+ const nextDiff = this.formatStackDiffHelper(
934
+ nestedStack.deployedTemplate,
935
+ nestedStack.physicalName ?? nestedStackLogicalId,
936
+ nestedStack.nestedStackTemplates,
937
+ options
938
+ );
939
+ numStacksWithChanges += nextDiff.numStacksWithChanges;
940
+ formattedDiff += nextDiff.formattedDiff;
941
+ }
942
+ return {
943
+ numStacksWithChanges,
944
+ formattedDiff
945
+ };
946
+ }
947
+ /**
948
+ * Format the security diff
949
+ */
950
+ formatSecurityDiff(options) {
951
+ const ioDefaultHelper = new IoDefaultMessages(this.ioHelper);
952
+ const diff = (0, import_cloudformation_diff.fullDiff)(this.oldTemplate, this.newTemplate.template, options.changeSet);
953
+ if (diffRequiresApproval(diff, options.requireApproval)) {
954
+ const stream = new StringWriteStream();
955
+ stream.write((0, import_node_util.format)(`Stack ${chalk.bold(options.stackName)}
956
+ `));
957
+ ioDefaultHelper.warning(`This deployment will make potentially sensitive changes according to your current security approval level (--require-approval ${options.requireApproval}).`);
958
+ ioDefaultHelper.warning("Please confirm you intend to make the following modifications:\n");
959
+ try {
960
+ (0, import_cloudformation_diff.formatSecurityChanges)(stream, diff, buildLogicalToPathMap(this.newTemplate));
961
+ } finally {
962
+ stream.end();
963
+ }
964
+ const formattedDiff = stream.toString();
965
+ return { formattedDiff };
966
+ }
967
+ return {};
968
+ }
969
+ };
970
+ function diffRequiresApproval(diff, requireApproval) {
971
+ switch (requireApproval) {
972
+ case "never" /* NEVER */:
973
+ return false;
974
+ case "any-change" /* ANY_CHANGE */:
975
+ return diff.permissionsAnyChanges;
976
+ case "broadening" /* BROADENING */:
977
+ return diff.permissionsBroadened;
978
+ default:
979
+ throw new ToolkitError(`Unrecognized approval level: ${requireApproval}`);
980
+ }
981
+ }
982
+ function buildLogicalToPathMap(stack) {
983
+ const map = {};
984
+ for (const md of stack.findMetadataByType(cxschema.ArtifactMetadataEntryType.LOGICAL_ID)) {
985
+ map[md.data] = md.path;
986
+ }
987
+ return map;
988
+ }
989
+ function logicalIdMapFromTemplate(template) {
990
+ const ret = {};
991
+ for (const [logicalId, resource] of Object.entries(template.Resources ?? {})) {
992
+ const path = resource?.Metadata?.["aws:cdk:path"];
993
+ if (path) {
994
+ ret[logicalId] = path;
995
+ }
996
+ }
997
+ return ret;
998
+ }
999
+ function obscureDiff(diff) {
1000
+ if (diff.unknown) {
1001
+ diff.unknown = diff.unknown.filter((change) => {
1002
+ if (!change) {
1003
+ return true;
1004
+ }
1005
+ if (change.newValue?.CheckBootstrapVersion) {
1006
+ return false;
1007
+ }
1008
+ if (change.oldValue?.CheckBootstrapVersion) {
1009
+ return false;
1010
+ }
1011
+ return true;
1012
+ });
1013
+ }
1014
+ if (diff.resources) {
1015
+ diff.resources = diff.resources.filter((change) => {
1016
+ if (!change) {
1017
+ return true;
1018
+ }
1019
+ if (change.newResourceType === "AWS::CDK::Metadata") {
1020
+ return false;
1021
+ }
1022
+ if (change.oldResourceType === "AWS::CDK::Metadata") {
1023
+ return false;
1024
+ }
1025
+ return true;
1026
+ });
1027
+ }
1028
+ }
1029
+
1030
+ // ../tmp-toolkit-helpers/src/api/io/payloads/diff.ts
1031
+ var PermissionChangeType = /* @__PURE__ */ ((PermissionChangeType2) => {
1032
+ PermissionChangeType2["NONE"] = "none";
1033
+ PermissionChangeType2["BROADENING"] = "broadening";
1034
+ PermissionChangeType2["NON_BROADENING"] = "non-broadening";
1035
+ return PermissionChangeType2;
1036
+ })(PermissionChangeType || {});
1037
+
1038
+ // ../tmp-toolkit-helpers/src/api/io/payloads/hotswap.ts
1039
+ var NonHotswappableReason = /* @__PURE__ */ ((NonHotswappableReason2) => {
1040
+ NonHotswappableReason2["TAGS"] = "tags";
1041
+ NonHotswappableReason2["PROPERTIES"] = "properties";
1042
+ NonHotswappableReason2["OUTPUT"] = "output";
1043
+ NonHotswappableReason2["DEPENDENCY_UNSUPPORTED"] = "dependency-unsupported";
1044
+ NonHotswappableReason2["RESOURCE_UNSUPPORTED"] = "resource-unsupported";
1045
+ NonHotswappableReason2["RESOURCE_CREATION"] = "resource-creation";
1046
+ NonHotswappableReason2["RESOURCE_DELETION"] = "resource-deletion";
1047
+ NonHotswappableReason2["RESOURCE_TYPE_CHANGED"] = "resource-type-changed";
1048
+ NonHotswappableReason2["NESTED_STACK_CREATION"] = "nested-stack-creation";
1049
+ return NonHotswappableReason2;
1050
+ })(NonHotswappableReason || {});
1051
+
1052
+ // ../tmp-toolkit-helpers/src/api/resource-import/importer.ts
1053
+ function removeNonImportResources(stack) {
1054
+ const template = stack.template;
1055
+ delete template.Resources.CDKMetadata;
1056
+ delete template.Outputs;
1057
+ return template;
1058
+ }
172
1059
  // Annotate the CommonJS export names for ESM import in node:
173
1060
  0 && (module.exports = {
174
1061
  AssemblyError,
175
1062
  AuthenticationError,
176
1063
  ContextProviderError,
1064
+ DiffFormatter,
177
1065
  ExpandStackSelection,
1066
+ NonHotswappableReason,
178
1067
  PermissionChangeType,
179
1068
  RequireApproval,
180
1069
  StackSelectionStrategy,
181
- ToolkitError
1070
+ ToolkitError,
1071
+ removeNonImportResources
182
1072
  });
183
1073
  //# sourceMappingURL=shared-public.js.map