@aws-cdk/toolkit-lib 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CODE_REGISTRY.md +19 -12
- package/build-info.json +2 -2
- package/db.json.gz +0 -0
- package/lib/actions/bootstrap/index.d.ts +174 -0
- package/lib/actions/bootstrap/index.js +94 -0
- package/lib/actions/bootstrap/private/helpers.d.ts +5 -0
- package/lib/actions/bootstrap/private/helpers.js +23 -0
- package/lib/actions/bootstrap/private/index.d.ts +1 -0
- package/lib/actions/bootstrap/private/index.js +18 -0
- package/lib/actions/deploy/index.d.ts +4 -4
- package/lib/actions/deploy/index.js +1 -1
- package/lib/actions/destroy/index.d.ts +1 -1
- package/lib/actions/destroy/index.js +1 -1
- package/lib/actions/diff/private/helpers.js +3 -3
- package/lib/actions/index.d.ts +1 -0
- package/lib/actions/index.js +2 -1
- package/lib/actions/list/index.d.ts +4 -0
- package/lib/actions/list/index.js +1 -1
- package/lib/api/aws-cdk.d.ts +3 -7
- package/lib/api/aws-cdk.js +1969 -1336
- package/lib/api/aws-cdk.js.map +4 -4
- package/lib/api/bootstrap/bootstrap-template.yaml +707 -0
- package/lib/api/cloud-assembly/context.d.ts +9 -0
- package/lib/api/cloud-assembly/context.js +3 -0
- package/lib/api/cloud-assembly/private/context-aware-source.js +5 -5
- package/lib/api/cloud-assembly/private/exec.js +3 -3
- package/lib/api/cloud-assembly/private/prepare-source.d.ts +1 -1
- package/lib/api/cloud-assembly/private/prepare-source.js +6 -5
- package/lib/api/cloud-assembly/private/source-builder.js +5 -5
- package/lib/api/cloud-assembly/private/stack-assembly.js +7 -7
- package/lib/api/io/index.d.ts +1 -2
- package/lib/api/io/index.js +1 -17
- package/lib/api/io/private/codes.d.ts +39 -55
- package/lib/api/io/private/codes.js +71 -59
- package/lib/api/io/private/index.d.ts +0 -1
- package/lib/api/io/private/index.js +1 -2
- package/lib/api/io/private/level-priority.d.ts +1 -1
- package/lib/api/io/private/level-priority.js +1 -1
- package/lib/api/io/private/logger.d.ts +3 -12
- package/lib/api/io/private/logger.js +1 -22
- package/lib/api/io/private/messages.d.ts +7 -3
- package/lib/api/io/private/messages.js +1 -2
- package/lib/api/io/private/timer.d.ts +2 -2
- package/lib/api/io/private/timer.js +13 -13
- package/lib/api/shared-private.d.ts +1 -0
- package/lib/api/shared-private.js +82 -0
- package/lib/api/shared-private.js.map +7 -0
- package/lib/api/shared-public.d.ts +130 -0
- package/lib/api/shared-public.js +100 -0
- package/lib/api/shared-public.js.map +7 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +2 -2
- package/lib/private/util.d.ts +1 -0
- package/lib/private/util.js +715 -0
- package/lib/private/util.js.map +7 -0
- package/lib/toolkit/private/index.d.ts +10 -1
- package/lib/toolkit/private/index.js +18 -1
- package/lib/toolkit/toolkit.d.ts +7 -11
- package/lib/toolkit/toolkit.js +139 -118
- package/lib/toolkit/types.d.ts +9 -0
- package/lib/toolkit/types.js +1 -1
- package/lib/util/concurrency.d.ts +5 -0
- package/lib/util/concurrency.js +11 -0
- package/package.json +33 -32
- package/lib/api/errors.d.ts +0 -44
- package/lib/api/errors.js +0 -82
- package/lib/api/io/io-host.d.ts +0 -15
- package/lib/api/io/io-host.js +0 -3
- package/lib/api/io/io-message.d.ts +0 -59
- package/lib/api/io/io-message.js +0 -3
- package/lib/api/io/private/types.d.ts +0 -25
- package/lib/api/io/private/types.js +0 -3
package/lib/api/aws-cdk.js
CHANGED
|
@@ -38,6 +38,7 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
38
38
|
// lib/api/aws-cdk.ts
|
|
39
39
|
var aws_cdk_exports = {};
|
|
40
40
|
__export(aws_cdk_exports, {
|
|
41
|
+
Bootstrapper: () => Bootstrapper,
|
|
41
42
|
CliIoHost: () => CliIoHost,
|
|
42
43
|
CloudAssembly: () => CloudAssembly2,
|
|
43
44
|
CloudWatchLogEventMonitor: () => CloudWatchLogEventMonitor,
|
|
@@ -53,26 +54,19 @@ __export(aws_cdk_exports, {
|
|
|
53
54
|
ResourceMigrator: () => ResourceMigrator,
|
|
54
55
|
SdkProvider: () => SdkProvider,
|
|
55
56
|
Settings: () => Settings,
|
|
56
|
-
StackActivityProgress: () => StackActivityProgress,
|
|
57
57
|
StackCollection: () => StackCollection,
|
|
58
58
|
WorkGraphBuilder: () => WorkGraphBuilder,
|
|
59
59
|
contextproviders: () => context_providers_exports,
|
|
60
60
|
findCloudWatchLogGroups: () => findCloudWatchLogGroups,
|
|
61
|
-
formatErrorMessage: () => formatErrorMessage,
|
|
62
61
|
formatSdkLoggerContent: () => formatSdkLoggerContent,
|
|
63
|
-
formatTime: () => formatTime,
|
|
64
62
|
guessExecutable: () => guessExecutable,
|
|
65
63
|
loadTree: () => loadTree,
|
|
66
|
-
obscureTemplate: () => obscureTemplate,
|
|
67
64
|
prepareContext: () => prepareContext,
|
|
68
65
|
prepareDefaultEnvironment: () => prepareDefaultEnvironment,
|
|
69
66
|
sanitizePatterns: () => sanitizePatterns,
|
|
70
|
-
serializeStructure: () => serializeStructure,
|
|
71
67
|
some: () => some,
|
|
72
68
|
spaceAvailableForContext: () => spaceAvailableForContext,
|
|
73
|
-
splitBySize: () => splitBySize,
|
|
74
69
|
tagsForStack: () => tagsForStack,
|
|
75
|
-
validateSnsTopicArn: () => validateSnsTopicArn,
|
|
76
70
|
versionNumber: () => versionNumber
|
|
77
71
|
});
|
|
78
72
|
module.exports = __toCommonJS(aws_cdk_exports);
|
|
@@ -102,18 +96,18 @@ var import_util_retry = require("@smithy/util-retry");
|
|
|
102
96
|
|
|
103
97
|
// ../../aws-cdk/lib/api/aws-auth/account-cache.ts
|
|
104
98
|
var path2 = __toESM(require("path"));
|
|
105
|
-
var
|
|
99
|
+
var fs3 = __toESM(require("fs-extra"));
|
|
106
100
|
|
|
107
101
|
// ../../aws-cdk/lib/logging.ts
|
|
108
|
-
var
|
|
109
|
-
var
|
|
102
|
+
var util4 = __toESM(require("util"));
|
|
103
|
+
var chalk4 = __toESM(require("chalk"));
|
|
110
104
|
|
|
111
105
|
// ../../aws-cdk/lib/toolkit/cli-io-host.ts
|
|
112
|
-
var
|
|
113
|
-
var
|
|
106
|
+
var util3 = __toESM(require("node:util"));
|
|
107
|
+
var chalk3 = __toESM(require("chalk"));
|
|
114
108
|
var promptly = __toESM(require("promptly"));
|
|
115
109
|
|
|
116
|
-
//
|
|
110
|
+
// ../tmp-toolkit-helpers/src/api/toolkit-error.ts
|
|
117
111
|
var TOOLKIT_ERROR_SYMBOL = Symbol.for("@aws-cdk/toolkit.ToolkitError");
|
|
118
112
|
var AUTHENTICATION_ERROR_SYMBOL = Symbol.for("@aws-cdk/toolkit.AuthenticationError");
|
|
119
113
|
var ASSEMBLY_ERROR_SYMBOL = Symbol.for("@aws-cdk/toolkit.AssemblyError");
|
|
@@ -143,6 +137,10 @@ var ToolkitError = class _ToolkitError extends Error {
|
|
|
143
137
|
static isContextProviderError(x) {
|
|
144
138
|
return this.isToolkitError(x) && CONTEXT_PROVIDER_ERROR_SYMBOL in x;
|
|
145
139
|
}
|
|
140
|
+
/**
|
|
141
|
+
* The type of the error, defaults to "toolkit".
|
|
142
|
+
*/
|
|
143
|
+
type;
|
|
146
144
|
constructor(message, type = "toolkit") {
|
|
147
145
|
super(message);
|
|
148
146
|
Object.setPrototypeOf(this, _ToolkitError.prototype);
|
|
@@ -173,183 +171,1004 @@ var ContextProviderError = class _ContextProviderError extends ToolkitError {
|
|
|
173
171
|
}
|
|
174
172
|
};
|
|
175
173
|
|
|
176
|
-
//
|
|
177
|
-
var
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
};
|
|
185
|
-
var CliIoHost = class _CliIoHost {
|
|
186
|
-
constructor(props = {}) {
|
|
187
|
-
// Corked Logging
|
|
188
|
-
this.corkedCounter = 0;
|
|
189
|
-
this.corkedLoggingBuffer = [];
|
|
190
|
-
this._currentAction = props.currentAction ?? "none";
|
|
191
|
-
this._isTTY = props.isTTY ?? process.stdout.isTTY ?? false;
|
|
192
|
-
this._logLevel = props.logLevel ?? "info";
|
|
193
|
-
this._isCI = props.isCI ?? isCI();
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* Returns the singleton instance
|
|
197
|
-
*/
|
|
198
|
-
static instance(props = {}, forceNew = false) {
|
|
199
|
-
if (forceNew || !_CliIoHost._instance) {
|
|
200
|
-
_CliIoHost._instance = new _CliIoHost(props);
|
|
201
|
-
}
|
|
202
|
-
return _CliIoHost._instance;
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Returns the singleton instance
|
|
206
|
-
*/
|
|
207
|
-
registerIoHost(ioHost) {
|
|
208
|
-
if (ioHost !== this) {
|
|
209
|
-
this._internalIoHost = ioHost;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* The current action being performed by the CLI.
|
|
214
|
-
*/
|
|
215
|
-
get currentAction() {
|
|
216
|
-
return this._currentAction;
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Sets the current action being performed by the CLI.
|
|
220
|
-
*
|
|
221
|
-
* @param action The action being performed by the CLI.
|
|
222
|
-
*/
|
|
223
|
-
set currentAction(action) {
|
|
224
|
-
this._currentAction = action;
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Whether the host can use interactions and message styling.
|
|
228
|
-
*/
|
|
229
|
-
get isTTY() {
|
|
230
|
-
return this._isTTY;
|
|
231
|
-
}
|
|
232
|
-
/**
|
|
233
|
-
* Set TTY mode, i.e can the host use interactions and message styling.
|
|
234
|
-
*
|
|
235
|
-
* @param value set TTY mode
|
|
236
|
-
*/
|
|
237
|
-
set isTTY(value) {
|
|
238
|
-
this._isTTY = value;
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* Whether the CliIoHost is running in CI mode. In CI mode, all non-error output goes to stdout instead of stderr.
|
|
242
|
-
*/
|
|
243
|
-
get isCI() {
|
|
244
|
-
return this._isCI;
|
|
245
|
-
}
|
|
246
|
-
/**
|
|
247
|
-
* Set the CI mode. In CI mode, all non-error output goes to stdout instead of stderr.
|
|
248
|
-
* @param value set the CI mode
|
|
249
|
-
*/
|
|
250
|
-
set isCI(value) {
|
|
251
|
-
this._isCI = value;
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* The current threshold. Messages with a lower priority level will be ignored.
|
|
255
|
-
*/
|
|
256
|
-
get logLevel() {
|
|
257
|
-
return this._logLevel;
|
|
174
|
+
// ../tmp-toolkit-helpers/src/util/archive.ts
|
|
175
|
+
var glob = __toESM(require("glob"));
|
|
176
|
+
|
|
177
|
+
// ../tmp-toolkit-helpers/src/util/format-error.ts
|
|
178
|
+
function formatErrorMessage(error3) {
|
|
179
|
+
if (error3 && Array.isArray(error3.errors)) {
|
|
180
|
+
const innerMessages = error3.errors.map((innerError) => innerError?.message || innerError?.toString()).join("\n");
|
|
181
|
+
return `AggregateError: ${innerMessages}`;
|
|
258
182
|
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
183
|
+
return error3?.message || error3?.toString() || "Unknown error";
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// ../tmp-toolkit-helpers/src/util/archive.ts
|
|
187
|
+
var archiver = require("archiver");
|
|
188
|
+
|
|
189
|
+
// ../tmp-toolkit-helpers/src/util/arrays.ts
|
|
190
|
+
function flatMap(xs, fn) {
|
|
191
|
+
return flatten(xs.map(fn));
|
|
192
|
+
}
|
|
193
|
+
function flatten(xs) {
|
|
194
|
+
return Array.prototype.concat.apply([], xs);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// ../tmp-toolkit-helpers/src/util/bytes.ts
|
|
198
|
+
function formatBytes(bytes, decimals = 2) {
|
|
199
|
+
decimals = decimals < 0 ? 0 : decimals;
|
|
200
|
+
if (bytes === 0) {
|
|
201
|
+
return "0 Bytes";
|
|
265
202
|
}
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
}
|
|
284
|
-
this.corkedLoggingBuffer.splice(0);
|
|
285
|
-
}
|
|
203
|
+
const k = 1024;
|
|
204
|
+
const sizes = ["Bytes", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"];
|
|
205
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
206
|
+
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(decimals))} ${sizes[i]}`;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// ../tmp-toolkit-helpers/src/util/cloudformation.ts
|
|
210
|
+
function stackEventHasErrorMessage(status) {
|
|
211
|
+
return status.endsWith("_FAILED") || status === "ROLLBACK_IN_PROGRESS" || status === "UPDATE_ROLLBACK_IN_PROGRESS";
|
|
212
|
+
}
|
|
213
|
+
function maxResourceTypeLength(template, startWidth = "AWS::CloudFormation::Stack".length) {
|
|
214
|
+
const resources = template && template.Resources || {};
|
|
215
|
+
let maxWidth = startWidth;
|
|
216
|
+
for (const id of Object.keys(resources)) {
|
|
217
|
+
const type = resources[id].Type || "";
|
|
218
|
+
if (type.length > maxWidth) {
|
|
219
|
+
maxWidth = type.length;
|
|
286
220
|
}
|
|
287
221
|
}
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
222
|
+
return maxWidth;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// ../tmp-toolkit-helpers/src/util/content-hash.ts
|
|
226
|
+
var crypto = __toESM(require("crypto"));
|
|
227
|
+
function contentHash(data) {
|
|
228
|
+
return crypto.createHash("sha256").update(data).digest("hex");
|
|
229
|
+
}
|
|
230
|
+
function contentHashAny(value) {
|
|
231
|
+
const ret = crypto.createHash("sha256");
|
|
232
|
+
recurse(value);
|
|
233
|
+
return ret.digest("hex");
|
|
234
|
+
function recurse(x) {
|
|
235
|
+
if (typeof x === "string") {
|
|
236
|
+
ret.update(x);
|
|
237
|
+
return;
|
|
295
238
|
}
|
|
296
|
-
if (
|
|
239
|
+
if (Array.isArray(x)) {
|
|
240
|
+
ret.update("[");
|
|
241
|
+
for (const e of x) {
|
|
242
|
+
recurse(e);
|
|
243
|
+
ret.update("||");
|
|
244
|
+
}
|
|
245
|
+
ret.update("]");
|
|
297
246
|
return;
|
|
298
247
|
}
|
|
299
|
-
if (
|
|
300
|
-
|
|
248
|
+
if (x && typeof x === "object") {
|
|
249
|
+
ret.update("{");
|
|
250
|
+
for (const key of Object.keys(x).sort()) {
|
|
251
|
+
ret.update(key);
|
|
252
|
+
ret.update(":");
|
|
253
|
+
recurse(x[key]);
|
|
254
|
+
}
|
|
255
|
+
ret.update("}");
|
|
301
256
|
return;
|
|
302
257
|
}
|
|
303
|
-
|
|
304
|
-
const stream = this.selectStream(msg.level);
|
|
305
|
-
stream.write(output);
|
|
258
|
+
ret.update(`${x}${typeof x}`);
|
|
306
259
|
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// ../tmp-toolkit-helpers/src/util/directories.ts
|
|
263
|
+
var fs = __toESM(require("fs"));
|
|
264
|
+
var os = __toESM(require("os"));
|
|
265
|
+
var path = __toESM(require("path"));
|
|
266
|
+
function cdkHomeDir() {
|
|
267
|
+
const tmpDir = fs.realpathSync(os.tmpdir());
|
|
268
|
+
let home;
|
|
269
|
+
try {
|
|
270
|
+
let userInfoHome = os.userInfo().homedir;
|
|
271
|
+
if (userInfoHome == "/var/empty") {
|
|
272
|
+
userInfoHome = void 0;
|
|
318
273
|
}
|
|
274
|
+
home = path.join((userInfoHome ?? os.homedir()).trim(), ".cdk");
|
|
275
|
+
} catch {
|
|
319
276
|
}
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
if (!isPromptableRequest(msg)) {
|
|
331
|
-
await this.notify(msg);
|
|
332
|
-
return msg.defaultResponse;
|
|
277
|
+
return process.env.CDK_HOME ? path.resolve(process.env.CDK_HOME) : home || fs.mkdtempSync(path.join(tmpDir, ".cdk")).trim();
|
|
278
|
+
}
|
|
279
|
+
function cdkCacheDir() {
|
|
280
|
+
return path.join(cdkHomeDir(), "cache");
|
|
281
|
+
}
|
|
282
|
+
function bundledPackageRootDir(start, fail) {
|
|
283
|
+
function _rootDir(dirname6) {
|
|
284
|
+
const manifestPath = path.join(dirname6, "package.json");
|
|
285
|
+
if (fs.existsSync(manifestPath)) {
|
|
286
|
+
return dirname6;
|
|
333
287
|
}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
const concurrency = data.concurrency ?? 0;
|
|
338
|
-
if (!this.isTTY) {
|
|
339
|
-
throw new ToolkitError(`${motivation}, but terminal (TTY) is not attached so we are unable to get a confirmation from the user`);
|
|
340
|
-
}
|
|
341
|
-
if (concurrency > 1) {
|
|
342
|
-
throw new ToolkitError(`${motivation}, but concurrency is greater than 1 so we are unable to get a confirmation from the user`);
|
|
288
|
+
if (path.dirname(dirname6) === dirname6) {
|
|
289
|
+
if (fail ?? true) {
|
|
290
|
+
throw new ToolkitError("Unable to find package manifest");
|
|
343
291
|
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
292
|
+
return void 0;
|
|
293
|
+
}
|
|
294
|
+
return _rootDir(path.dirname(dirname6));
|
|
295
|
+
}
|
|
296
|
+
return _rootDir(start);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// ../tmp-toolkit-helpers/src/util/json.ts
|
|
300
|
+
function getResultObj(jsonObject, identifier, propertiesToReturn) {
|
|
301
|
+
const propsObj = {};
|
|
302
|
+
propertiesToReturn.forEach((propName) => {
|
|
303
|
+
Object.assign(propsObj, { [propName]: findJsonValue(jsonObject, propName) });
|
|
304
|
+
});
|
|
305
|
+
Object.assign(propsObj, { ["Identifier"]: identifier });
|
|
306
|
+
return propsObj;
|
|
307
|
+
}
|
|
308
|
+
function findJsonValue(jsonObject, path15) {
|
|
309
|
+
const paths = path15.split(".");
|
|
310
|
+
let obj = jsonObject;
|
|
311
|
+
paths.forEach((p) => {
|
|
312
|
+
obj = obj[p];
|
|
313
|
+
if (obj === void 0) {
|
|
314
|
+
throw new TypeError(`Cannot read field ${path15}. ${p} is not found.`);
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
return obj;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// ../tmp-toolkit-helpers/src/util/types.ts
|
|
321
|
+
function isObject(x) {
|
|
322
|
+
return x !== null && typeof x === "object" && !isArray(x);
|
|
323
|
+
}
|
|
324
|
+
var isArray = Array.isArray;
|
|
325
|
+
|
|
326
|
+
// ../tmp-toolkit-helpers/src/util/objects.ts
|
|
327
|
+
function deepClone(x) {
|
|
328
|
+
if (typeof x === "undefined") {
|
|
329
|
+
return void 0;
|
|
330
|
+
}
|
|
331
|
+
if (x === null) {
|
|
332
|
+
return null;
|
|
333
|
+
}
|
|
334
|
+
if (isArray(x)) {
|
|
335
|
+
return x.map(deepClone);
|
|
336
|
+
}
|
|
337
|
+
if (isObject(x)) {
|
|
338
|
+
return makeObject(mapObject(x, (k, v) => [k, deepClone(v)]));
|
|
339
|
+
}
|
|
340
|
+
return x;
|
|
341
|
+
}
|
|
342
|
+
function mapObject(x, fn) {
|
|
343
|
+
const ret = [];
|
|
344
|
+
Object.keys(x).forEach((key) => {
|
|
345
|
+
ret.push(fn(key, x[key]));
|
|
346
|
+
});
|
|
347
|
+
return ret;
|
|
348
|
+
}
|
|
349
|
+
function makeObject(pairs) {
|
|
350
|
+
const ret = {};
|
|
351
|
+
for (const pair of pairs) {
|
|
352
|
+
ret[pair[0]] = pair[1];
|
|
353
|
+
}
|
|
354
|
+
return ret;
|
|
355
|
+
}
|
|
356
|
+
function deepGet(x, path15) {
|
|
357
|
+
path15 = path15.slice();
|
|
358
|
+
while (path15.length > 0 && isObject(x)) {
|
|
359
|
+
const key = path15.shift();
|
|
360
|
+
x = x[key];
|
|
361
|
+
}
|
|
362
|
+
return path15.length === 0 ? x : void 0;
|
|
363
|
+
}
|
|
364
|
+
function deepSet(x, path15, value) {
|
|
365
|
+
path15 = path15.slice();
|
|
366
|
+
if (path15.length === 0) {
|
|
367
|
+
throw new ToolkitError("Path may not be empty");
|
|
368
|
+
}
|
|
369
|
+
while (path15.length > 1 && isObject(x)) {
|
|
370
|
+
const key = path15.shift();
|
|
371
|
+
if (!(key in x)) {
|
|
372
|
+
x[key] = {};
|
|
373
|
+
}
|
|
374
|
+
x = x[key];
|
|
375
|
+
}
|
|
376
|
+
if (!isObject(x)) {
|
|
377
|
+
throw new ToolkitError(`Expected an object, got '${x}'`);
|
|
378
|
+
}
|
|
379
|
+
if (value !== void 0) {
|
|
380
|
+
x[path15[0]] = value;
|
|
381
|
+
} else {
|
|
382
|
+
delete x[path15[0]];
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
function deepMerge(...objects) {
|
|
386
|
+
function mergeOne(target, source) {
|
|
387
|
+
for (const key of Object.keys(source)) {
|
|
388
|
+
if (key === "__proto__" || key === "constructor") {
|
|
389
|
+
continue;
|
|
390
|
+
}
|
|
391
|
+
const value = source[key];
|
|
392
|
+
if (isObject(value)) {
|
|
393
|
+
if (!isObject(target[key])) {
|
|
394
|
+
target[key] = {};
|
|
395
|
+
}
|
|
396
|
+
mergeOne(target[key], value);
|
|
397
|
+
} else if (typeof value !== "undefined") {
|
|
398
|
+
target[key] = value;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
const others = objects.filter((x) => x != null);
|
|
403
|
+
if (others.length === 0) {
|
|
404
|
+
return {};
|
|
405
|
+
}
|
|
406
|
+
const into = others.splice(0, 1)[0];
|
|
407
|
+
others.forEach((other) => mergeOne(into, other));
|
|
408
|
+
return into;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
// ../tmp-toolkit-helpers/src/util/parallel.ts
|
|
412
|
+
async function parallelPromises(n, promises) {
|
|
413
|
+
const ret = new Array();
|
|
414
|
+
let count = 0;
|
|
415
|
+
let error3;
|
|
416
|
+
const queue = [...promises];
|
|
417
|
+
return new Promise((ok, ko) => {
|
|
418
|
+
tick();
|
|
419
|
+
function tick() {
|
|
420
|
+
if (count === 0 && error3) {
|
|
421
|
+
ko(error3);
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
if (count === 0 && queue.length === 0) {
|
|
425
|
+
ok(ret);
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
while (count < n && queue.length > 0 && !error3) {
|
|
429
|
+
const next = queue.shift();
|
|
430
|
+
if (next !== void 0) {
|
|
431
|
+
start(next);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
function start(fn) {
|
|
436
|
+
count += 1;
|
|
437
|
+
fn().then((result) => {
|
|
438
|
+
ret.push(result);
|
|
439
|
+
}).catch((e) => {
|
|
440
|
+
error3 = e;
|
|
441
|
+
}).finally(() => {
|
|
442
|
+
count -= 1;
|
|
443
|
+
tick();
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
// ../tmp-toolkit-helpers/src/util/serialize.ts
|
|
450
|
+
var fs2 = __toESM(require("fs/promises"));
|
|
451
|
+
|
|
452
|
+
// ../tmp-toolkit-helpers/src/util/yaml-cfn.ts
|
|
453
|
+
var yaml = __toESM(require("yaml"));
|
|
454
|
+
var yaml_types = __toESM(require("yaml/types"));
|
|
455
|
+
function serialize(obj) {
|
|
456
|
+
const oldFold = yaml_types.strOptions.fold.lineWidth;
|
|
457
|
+
try {
|
|
458
|
+
yaml_types.strOptions.fold.lineWidth = 0;
|
|
459
|
+
return yaml.stringify(obj, { schema: "yaml-1.1" });
|
|
460
|
+
} finally {
|
|
461
|
+
yaml_types.strOptions.fold.lineWidth = oldFold;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
function deserialize(str) {
|
|
465
|
+
return parseYamlStrWithCfnTags(str);
|
|
466
|
+
}
|
|
467
|
+
function makeTagForCfnIntrinsic(intrinsicName, addFnPrefix) {
|
|
468
|
+
return {
|
|
469
|
+
identify(value) {
|
|
470
|
+
return typeof value === "string";
|
|
471
|
+
},
|
|
472
|
+
tag: `!${intrinsicName}`,
|
|
473
|
+
resolve: (_doc, cstNode) => {
|
|
474
|
+
const ret = {};
|
|
475
|
+
ret[addFnPrefix ? `Fn::${intrinsicName}` : intrinsicName] = // the +1 is to account for the ! the short form begins with
|
|
476
|
+
parseYamlStrWithCfnTags(cstNode.toString().substring(intrinsicName.length + 1));
|
|
477
|
+
return ret;
|
|
478
|
+
}
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
var shortForms = [
|
|
482
|
+
"Base64",
|
|
483
|
+
"Cidr",
|
|
484
|
+
"FindInMap",
|
|
485
|
+
"GetAZs",
|
|
486
|
+
"ImportValue",
|
|
487
|
+
"Join",
|
|
488
|
+
"Sub",
|
|
489
|
+
"Select",
|
|
490
|
+
"Split",
|
|
491
|
+
"Transform",
|
|
492
|
+
"And",
|
|
493
|
+
"Equals",
|
|
494
|
+
"If",
|
|
495
|
+
"Not",
|
|
496
|
+
"Or",
|
|
497
|
+
"GetAtt"
|
|
498
|
+
].map((name) => makeTagForCfnIntrinsic(name, true)).concat(
|
|
499
|
+
makeTagForCfnIntrinsic("Ref", false),
|
|
500
|
+
makeTagForCfnIntrinsic("Condition", false)
|
|
501
|
+
);
|
|
502
|
+
function parseYamlStrWithCfnTags(text) {
|
|
503
|
+
return yaml.parse(text, {
|
|
504
|
+
customTags: shortForms,
|
|
505
|
+
schema: "core"
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
// ../tmp-toolkit-helpers/src/util/serialize.ts
|
|
510
|
+
function toYAML(obj) {
|
|
511
|
+
return serialize(obj);
|
|
512
|
+
}
|
|
513
|
+
function deserializeStructure(str) {
|
|
514
|
+
return deserialize(str);
|
|
515
|
+
}
|
|
516
|
+
function serializeStructure(object, json) {
|
|
517
|
+
if (json) {
|
|
518
|
+
return JSON.stringify(object, void 0, 2);
|
|
519
|
+
} else {
|
|
520
|
+
return toYAML(object);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
async function loadStructuredFile(fileName) {
|
|
524
|
+
const contents = await fs2.readFile(fileName, { encoding: "utf-8" });
|
|
525
|
+
return deserializeStructure(contents);
|
|
526
|
+
}
|
|
527
|
+
function isJsonBuffer(value) {
|
|
528
|
+
return typeof value === "object" && "type" in value && value.type === "Buffer" && "data" in value && Array.isArray(value.data);
|
|
529
|
+
}
|
|
530
|
+
function replacerBufferWithInfo(_key, value) {
|
|
531
|
+
if (isJsonBuffer(value)) {
|
|
532
|
+
return `<Buffer: ${formatBytes(value.data.length)}>`;
|
|
533
|
+
}
|
|
534
|
+
return value;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
// ../tmp-toolkit-helpers/src/util/string-manipulation.ts
|
|
538
|
+
function padLeft(n, x, char = " ") {
|
|
539
|
+
return char.repeat(Math.max(0, n - x.length)) + x;
|
|
540
|
+
}
|
|
541
|
+
function padRight(n, x, char = " ") {
|
|
542
|
+
return x + char.repeat(Math.max(0, n - x.length));
|
|
543
|
+
}
|
|
544
|
+
function formatTime(num) {
|
|
545
|
+
return roundPercentage(millisecondsToSeconds(num));
|
|
546
|
+
}
|
|
547
|
+
function roundPercentage(num) {
|
|
548
|
+
return Math.round(100 * num) / 100;
|
|
549
|
+
}
|
|
550
|
+
function millisecondsToSeconds(num) {
|
|
551
|
+
return num / 1e3;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
// ../tmp-toolkit-helpers/src/util/version-range.ts
|
|
555
|
+
var semver = __toESM(require("semver"));
|
|
556
|
+
|
|
557
|
+
// ../../aws-cdk/lib/cli/activity-printer/base.ts
|
|
558
|
+
var ActivityPrinterBase = class {
|
|
559
|
+
constructor(props) {
|
|
560
|
+
this.props = props;
|
|
561
|
+
/**
|
|
562
|
+
* The with of the "resource type" column.
|
|
563
|
+
*/
|
|
564
|
+
this.resourceTypeColumnWidth = maxResourceTypeLength({});
|
|
565
|
+
/**
|
|
566
|
+
* A list of resource IDs which are currently being processed
|
|
567
|
+
*/
|
|
568
|
+
this.resourcesInProgress = {};
|
|
569
|
+
this.rollingBack = false;
|
|
570
|
+
this.failures = new Array();
|
|
571
|
+
this.hookFailureMap = /* @__PURE__ */ new Map();
|
|
572
|
+
this.stream = props.stream;
|
|
573
|
+
}
|
|
574
|
+
static {
|
|
575
|
+
this.TIMESTAMP_WIDTH = 12;
|
|
576
|
+
}
|
|
577
|
+
static {
|
|
578
|
+
this.STATUS_WIDTH = 20;
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* Receive a stack activity message
|
|
582
|
+
*/
|
|
583
|
+
notify(msg) {
|
|
584
|
+
switch (msg.code) {
|
|
585
|
+
case "CDK_TOOLKIT_I5501":
|
|
586
|
+
this.start(msg.data);
|
|
587
|
+
break;
|
|
588
|
+
case "CDK_TOOLKIT_I5502":
|
|
589
|
+
this.activity(msg.data);
|
|
590
|
+
break;
|
|
591
|
+
case "CDK_TOOLKIT_I5503":
|
|
592
|
+
this.stop();
|
|
593
|
+
break;
|
|
594
|
+
default:
|
|
595
|
+
break;
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
start({ stack }) {
|
|
599
|
+
this.resourceTypeColumnWidth = maxResourceTypeLength(stack.template);
|
|
600
|
+
}
|
|
601
|
+
activity(activity) {
|
|
602
|
+
this.addActivity(activity);
|
|
603
|
+
this.print();
|
|
604
|
+
}
|
|
605
|
+
stop() {
|
|
606
|
+
this.print();
|
|
607
|
+
}
|
|
608
|
+
addActivity(activity) {
|
|
609
|
+
const status = activity.event.ResourceStatus;
|
|
610
|
+
const hookStatus = activity.event.HookStatus;
|
|
611
|
+
const hookType = activity.event.HookType;
|
|
612
|
+
if (!status || !activity.event.LogicalResourceId) {
|
|
613
|
+
return;
|
|
614
|
+
}
|
|
615
|
+
this.stackProgress = activity.progress;
|
|
616
|
+
if (status === "ROLLBACK_IN_PROGRESS" || status === "UPDATE_ROLLBACK_IN_PROGRESS") {
|
|
617
|
+
this.rollingBack = true;
|
|
618
|
+
}
|
|
619
|
+
if (status.endsWith("_IN_PROGRESS")) {
|
|
620
|
+
this.resourcesInProgress[activity.event.LogicalResourceId] = activity;
|
|
621
|
+
}
|
|
622
|
+
if (stackEventHasErrorMessage(status)) {
|
|
623
|
+
const isCancelled = (activity.event.ResourceStatusReason ?? "").indexOf("cancelled") > -1;
|
|
624
|
+
if (!isCancelled) {
|
|
625
|
+
this.failures.push(activity);
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
if (status.endsWith("_COMPLETE") || status.endsWith("_FAILED")) {
|
|
629
|
+
delete this.resourcesInProgress[activity.event.LogicalResourceId];
|
|
630
|
+
}
|
|
631
|
+
if (hookStatus !== void 0 && hookStatus.endsWith("_COMPLETE_FAILED") && activity.event.LogicalResourceId !== void 0 && hookType !== void 0) {
|
|
632
|
+
if (this.hookFailureMap.has(activity.event.LogicalResourceId)) {
|
|
633
|
+
this.hookFailureMap.get(activity.event.LogicalResourceId)?.set(hookType, activity.event.HookStatusReason ?? "");
|
|
634
|
+
} else {
|
|
635
|
+
this.hookFailureMap.set(activity.event.LogicalResourceId, /* @__PURE__ */ new Map());
|
|
636
|
+
this.hookFailureMap.get(activity.event.LogicalResourceId)?.set(hookType, activity.event.HookStatusReason ?? "");
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
failureReason(activity) {
|
|
641
|
+
const resourceStatusReason = activity.event.ResourceStatusReason ?? "";
|
|
642
|
+
const logicalResourceId = activity.event.LogicalResourceId ?? "";
|
|
643
|
+
const hookFailureReasonMap = this.hookFailureMap.get(logicalResourceId);
|
|
644
|
+
if (hookFailureReasonMap !== void 0) {
|
|
645
|
+
for (const hookType of hookFailureReasonMap.keys()) {
|
|
646
|
+
if (resourceStatusReason.includes(hookType)) {
|
|
647
|
+
return resourceStatusReason + " : " + hookFailureReasonMap.get(hookType);
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
return resourceStatusReason;
|
|
652
|
+
}
|
|
653
|
+
/**
|
|
654
|
+
* Is the activity a meta activity for the stack itself.
|
|
655
|
+
*/
|
|
656
|
+
isActivityForTheStack(activity) {
|
|
657
|
+
return activity.event.PhysicalResourceId === activity.event.StackId;
|
|
658
|
+
}
|
|
659
|
+
};
|
|
660
|
+
|
|
661
|
+
// ../../aws-cdk/lib/cli/activity-printer/history.ts
|
|
662
|
+
var util = __toESM(require("util"));
|
|
663
|
+
var chalk = __toESM(require("chalk"));
|
|
664
|
+
var HistoryActivityPrinter = class _HistoryActivityPrinter extends ActivityPrinterBase {
|
|
665
|
+
constructor(props) {
|
|
666
|
+
super(props);
|
|
667
|
+
/**
|
|
668
|
+
* Last time we printed something to the console.
|
|
669
|
+
*
|
|
670
|
+
* Used to measure timeout for progress reporting.
|
|
671
|
+
*/
|
|
672
|
+
this.lastPrintTime = Date.now();
|
|
673
|
+
/**
|
|
674
|
+
* Number of ms of change absence before we tell the user about the resources that are currently in progress.
|
|
675
|
+
*/
|
|
676
|
+
this.inProgressDelay = 3e4;
|
|
677
|
+
this.printable = new Array();
|
|
678
|
+
}
|
|
679
|
+
activity(activity) {
|
|
680
|
+
this.printable.push(activity);
|
|
681
|
+
super.activity(activity);
|
|
682
|
+
}
|
|
683
|
+
stop() {
|
|
684
|
+
super.stop();
|
|
685
|
+
if (this.failures.length > 0) {
|
|
686
|
+
this.stream.write("\nFailed resources:\n");
|
|
687
|
+
for (const failure of this.failures) {
|
|
688
|
+
if (this.isActivityForTheStack(failure)) {
|
|
689
|
+
continue;
|
|
690
|
+
}
|
|
691
|
+
this.printOne(failure, false);
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
print() {
|
|
696
|
+
for (const activity of this.printable) {
|
|
697
|
+
this.printOne(activity);
|
|
698
|
+
this.lastPrinted = activity;
|
|
699
|
+
}
|
|
700
|
+
this.printable.splice(0, this.printable.length);
|
|
701
|
+
this.printInProgress(this.lastPrinted?.progress.formatted);
|
|
702
|
+
}
|
|
703
|
+
printOne(activity, progress) {
|
|
704
|
+
const event = activity.event;
|
|
705
|
+
const color = colorFromStatusResult(event.ResourceStatus);
|
|
706
|
+
let reasonColor = chalk.cyan;
|
|
707
|
+
let stackTrace = "";
|
|
708
|
+
const metadata = activity.metadata;
|
|
709
|
+
if (event.ResourceStatus && event.ResourceStatus.indexOf("FAILED") !== -1) {
|
|
710
|
+
if (progress == void 0 || progress) {
|
|
711
|
+
event.ResourceStatusReason = event.ResourceStatusReason ? this.failureReason(activity) : "";
|
|
712
|
+
}
|
|
713
|
+
if (metadata) {
|
|
714
|
+
stackTrace = metadata.entry.trace ? `
|
|
715
|
+
${metadata.entry.trace.join("\n \\_ ")}` : "";
|
|
716
|
+
}
|
|
717
|
+
reasonColor = chalk.red;
|
|
718
|
+
}
|
|
719
|
+
const resourceName = metadata ? metadata.constructPath : event.LogicalResourceId || "";
|
|
720
|
+
const logicalId = resourceName !== event.LogicalResourceId ? `(${event.LogicalResourceId}) ` : "";
|
|
721
|
+
this.stream.write(
|
|
722
|
+
util.format(
|
|
723
|
+
"%s | %s%s | %s | %s | %s %s%s%s\n",
|
|
724
|
+
event.StackName,
|
|
725
|
+
progress !== false ? `${activity.progress.formatted} | ` : "",
|
|
726
|
+
new Date(event.Timestamp).toLocaleTimeString(),
|
|
727
|
+
color(padRight(_HistoryActivityPrinter.STATUS_WIDTH, (event.ResourceStatus || "").slice(0, _HistoryActivityPrinter.STATUS_WIDTH))),
|
|
728
|
+
// pad left and trim
|
|
729
|
+
padRight(this.resourceTypeColumnWidth, event.ResourceType || ""),
|
|
730
|
+
color(chalk.bold(resourceName)),
|
|
731
|
+
logicalId,
|
|
732
|
+
reasonColor(chalk.bold(event.ResourceStatusReason ? event.ResourceStatusReason : "")),
|
|
733
|
+
reasonColor(stackTrace)
|
|
734
|
+
)
|
|
735
|
+
);
|
|
736
|
+
this.lastPrintTime = Date.now();
|
|
737
|
+
}
|
|
738
|
+
/**
|
|
739
|
+
* If some resources are taking a while to create, notify the user about what's currently in progress
|
|
740
|
+
*/
|
|
741
|
+
printInProgress(progress) {
|
|
742
|
+
if (!progress || Date.now() < this.lastPrintTime + this.inProgressDelay) {
|
|
743
|
+
return;
|
|
744
|
+
}
|
|
745
|
+
if (Object.keys(this.resourcesInProgress).length > 0) {
|
|
746
|
+
this.stream.write(
|
|
747
|
+
util.format(
|
|
748
|
+
"%s Currently in progress: %s\n",
|
|
749
|
+
progress,
|
|
750
|
+
chalk.bold(Object.keys(this.resourcesInProgress).join(", "))
|
|
751
|
+
)
|
|
752
|
+
);
|
|
753
|
+
}
|
|
754
|
+
this.lastPrintTime = Infinity;
|
|
755
|
+
}
|
|
756
|
+
};
|
|
757
|
+
function colorFromStatusResult(status) {
|
|
758
|
+
if (!status) {
|
|
759
|
+
return chalk.reset;
|
|
760
|
+
}
|
|
761
|
+
if (status.indexOf("FAILED") !== -1) {
|
|
762
|
+
return chalk.red;
|
|
763
|
+
}
|
|
764
|
+
if (status.indexOf("ROLLBACK") !== -1) {
|
|
765
|
+
return chalk.yellow;
|
|
766
|
+
}
|
|
767
|
+
if (status.indexOf("COMPLETE") !== -1) {
|
|
768
|
+
return chalk.green;
|
|
769
|
+
}
|
|
770
|
+
return chalk.reset;
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
// ../../aws-cdk/lib/cli/activity-printer/current.ts
|
|
774
|
+
var util2 = __toESM(require("util"));
|
|
775
|
+
var chalk2 = __toESM(require("chalk"));
|
|
776
|
+
|
|
777
|
+
// ../../aws-cdk/lib/cli/activity-printer/display.ts
|
|
778
|
+
var wrapAnsi = require("wrap-ansi");
|
|
779
|
+
var RewritableBlock = class {
|
|
780
|
+
constructor(stream) {
|
|
781
|
+
this.stream = stream;
|
|
782
|
+
this.lastHeight = 0;
|
|
783
|
+
this.trailingEmptyLines = 0;
|
|
784
|
+
}
|
|
785
|
+
get width() {
|
|
786
|
+
return this.stream.columns;
|
|
787
|
+
}
|
|
788
|
+
get height() {
|
|
789
|
+
return this.stream.rows;
|
|
790
|
+
}
|
|
791
|
+
displayLines(lines) {
|
|
792
|
+
lines = terminalWrap(this.width, expandNewlines(lines));
|
|
793
|
+
lines = lines.slice(0, getMaxBlockHeight(this.height, this.lastHeight, lines));
|
|
794
|
+
this.stream.write(cursorUp(this.lastHeight));
|
|
795
|
+
for (const line of lines) {
|
|
796
|
+
this.stream.write(cll() + line + "\n");
|
|
797
|
+
}
|
|
798
|
+
this.trailingEmptyLines = Math.max(0, this.lastHeight - lines.length);
|
|
799
|
+
for (let i = 0; i < this.trailingEmptyLines; i++) {
|
|
800
|
+
this.stream.write(cll() + "\n");
|
|
801
|
+
}
|
|
802
|
+
this.lastHeight = Math.max(this.lastHeight, lines.length);
|
|
803
|
+
}
|
|
804
|
+
removeEmptyLines() {
|
|
805
|
+
this.stream.write(cursorUp(this.trailingEmptyLines));
|
|
806
|
+
}
|
|
807
|
+
};
|
|
808
|
+
var ESC = "\x1B";
|
|
809
|
+
function cursorUp(n) {
|
|
810
|
+
n = typeof n === "number" ? n : 1;
|
|
811
|
+
return n > 0 ? ESC + "[" + n + "A" : "";
|
|
812
|
+
}
|
|
813
|
+
function cll() {
|
|
814
|
+
return ESC + "[K";
|
|
815
|
+
}
|
|
816
|
+
function terminalWrap(width, lines) {
|
|
817
|
+
if (width === void 0) {
|
|
818
|
+
return lines;
|
|
819
|
+
}
|
|
820
|
+
return lines.flatMap((line) => wrapAnsi(line, width - 1, {
|
|
821
|
+
hard: true,
|
|
822
|
+
trim: true,
|
|
823
|
+
wordWrap: false
|
|
824
|
+
}).split("\n"));
|
|
825
|
+
}
|
|
826
|
+
function expandNewlines(lines) {
|
|
827
|
+
return lines.flatMap((line) => line.split("\n"));
|
|
828
|
+
}
|
|
829
|
+
function getMaxBlockHeight(windowHeight, lastHeight, lines) {
|
|
830
|
+
if (windowHeight === void 0) {
|
|
831
|
+
return Math.max(lines.length, lastHeight);
|
|
832
|
+
}
|
|
833
|
+
return lines.length < windowHeight ? lines.length : windowHeight - 1;
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
// ../../aws-cdk/lib/cli/activity-printer/current.ts
|
|
837
|
+
var CurrentActivityPrinter = class _CurrentActivityPrinter extends ActivityPrinterBase {
|
|
838
|
+
constructor(props) {
|
|
839
|
+
super(props);
|
|
840
|
+
this.block = new RewritableBlock(this.stream);
|
|
841
|
+
}
|
|
842
|
+
print() {
|
|
843
|
+
const lines = [];
|
|
844
|
+
const progressWidth = Math.max(
|
|
845
|
+
Math.min((this.block.width ?? 80) - PROGRESSBAR_EXTRA_SPACE - 1, MAX_PROGRESSBAR_WIDTH),
|
|
846
|
+
MIN_PROGRESSBAR_WIDTH
|
|
847
|
+
);
|
|
848
|
+
const prog = this.progressBar(progressWidth);
|
|
849
|
+
if (prog) {
|
|
850
|
+
lines.push(" " + prog, "");
|
|
851
|
+
}
|
|
852
|
+
const toPrint = [...this.failures, ...Object.values(this.resourcesInProgress)];
|
|
853
|
+
toPrint.sort((a, b) => a.event.Timestamp.getTime() - b.event.Timestamp.getTime());
|
|
854
|
+
lines.push(
|
|
855
|
+
...toPrint.map((res) => {
|
|
856
|
+
const color = colorFromStatusActivity(res.event.ResourceStatus);
|
|
857
|
+
const resourceName = res.metadata?.constructPath ?? res.event.LogicalResourceId ?? "";
|
|
858
|
+
return util2.format(
|
|
859
|
+
"%s | %s | %s | %s%s",
|
|
860
|
+
padLeft(_CurrentActivityPrinter.TIMESTAMP_WIDTH, new Date(res.event.Timestamp).toLocaleTimeString()),
|
|
861
|
+
color(padRight(_CurrentActivityPrinter.STATUS_WIDTH, (res.event.ResourceStatus || "").slice(0, _CurrentActivityPrinter.STATUS_WIDTH))),
|
|
862
|
+
padRight(this.resourceTypeColumnWidth, res.event.ResourceType || ""),
|
|
863
|
+
color(chalk2.bold(shorten(40, resourceName))),
|
|
864
|
+
this.failureReasonOnNextLine(res)
|
|
865
|
+
);
|
|
866
|
+
})
|
|
867
|
+
);
|
|
868
|
+
this.block.displayLines(lines);
|
|
869
|
+
}
|
|
870
|
+
stop() {
|
|
871
|
+
super.stop();
|
|
872
|
+
const lines = new Array();
|
|
873
|
+
for (const failure of this.failures) {
|
|
874
|
+
if (this.isActivityForTheStack(failure)) {
|
|
875
|
+
continue;
|
|
876
|
+
}
|
|
877
|
+
lines.push(
|
|
878
|
+
util2.format(
|
|
879
|
+
chalk2.red("%s | %s | %s | %s%s") + "\n",
|
|
880
|
+
padLeft(_CurrentActivityPrinter.TIMESTAMP_WIDTH, new Date(failure.event.Timestamp).toLocaleTimeString()),
|
|
881
|
+
padRight(_CurrentActivityPrinter.STATUS_WIDTH, (failure.event.ResourceStatus || "").slice(0, _CurrentActivityPrinter.STATUS_WIDTH)),
|
|
882
|
+
padRight(this.resourceTypeColumnWidth, failure.event.ResourceType || ""),
|
|
883
|
+
shorten(40, failure.event.LogicalResourceId ?? ""),
|
|
884
|
+
this.failureReasonOnNextLine(failure)
|
|
885
|
+
)
|
|
886
|
+
);
|
|
887
|
+
const trace3 = failure.metadata?.entry?.trace;
|
|
888
|
+
if (trace3) {
|
|
889
|
+
lines.push(chalk2.red(` ${trace3.join("\n \\_ ")}
|
|
890
|
+
`));
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
this.block.displayLines(lines);
|
|
894
|
+
this.block.removeEmptyLines();
|
|
895
|
+
}
|
|
896
|
+
progressBar(width) {
|
|
897
|
+
if (!this.stackProgress || !this.stackProgress.total) {
|
|
898
|
+
return "";
|
|
899
|
+
}
|
|
900
|
+
const fraction = Math.min(this.stackProgress.completed / this.stackProgress.total, 1);
|
|
901
|
+
const innerWidth = Math.max(1, width - 2);
|
|
902
|
+
const chars = innerWidth * fraction;
|
|
903
|
+
const remainder = chars - Math.floor(chars);
|
|
904
|
+
const fullChars = FULL_BLOCK.repeat(Math.floor(chars));
|
|
905
|
+
const partialChar = PARTIAL_BLOCK[Math.floor(remainder * PARTIAL_BLOCK.length)];
|
|
906
|
+
const filler = "\xB7".repeat(innerWidth - Math.floor(chars) - (partialChar ? 1 : 0));
|
|
907
|
+
const color = this.rollingBack ? chalk2.yellow : chalk2.green;
|
|
908
|
+
return "[" + color(fullChars + partialChar) + filler + `] (${this.stackProgress.completed}/${this.stackProgress.total})`;
|
|
909
|
+
}
|
|
910
|
+
failureReasonOnNextLine(activity) {
|
|
911
|
+
return stackEventHasErrorMessage(activity.event.ResourceStatus ?? "") ? `
|
|
912
|
+
${" ".repeat(_CurrentActivityPrinter.TIMESTAMP_WIDTH + _CurrentActivityPrinter.STATUS_WIDTH + 6)}${chalk2.red(this.failureReason(activity) ?? "")}` : "";
|
|
913
|
+
}
|
|
914
|
+
};
|
|
915
|
+
var FULL_BLOCK = "\u2588";
|
|
916
|
+
var PARTIAL_BLOCK = ["", "\u258F", "\u258E", "\u258D", "\u258C", "\u258B", "\u258A", "\u2589"];
|
|
917
|
+
var MAX_PROGRESSBAR_WIDTH = 60;
|
|
918
|
+
var MIN_PROGRESSBAR_WIDTH = 10;
|
|
919
|
+
var PROGRESSBAR_EXTRA_SPACE = 2 + 2 + 4 + 6;
|
|
920
|
+
function colorFromStatusActivity(status) {
|
|
921
|
+
if (!status) {
|
|
922
|
+
return chalk2.reset;
|
|
923
|
+
}
|
|
924
|
+
if (status.endsWith("_FAILED")) {
|
|
925
|
+
return chalk2.red;
|
|
926
|
+
}
|
|
927
|
+
if (status.startsWith("CREATE_") || status.startsWith("UPDATE_") || status.startsWith("IMPORT_")) {
|
|
928
|
+
return chalk2.green;
|
|
929
|
+
}
|
|
930
|
+
if (status.indexOf("ROLLBACK_") !== -1) {
|
|
931
|
+
return chalk2.yellow;
|
|
932
|
+
}
|
|
933
|
+
if (status.startsWith("DELETE_")) {
|
|
934
|
+
return chalk2.yellow;
|
|
935
|
+
}
|
|
936
|
+
return chalk2.reset;
|
|
937
|
+
}
|
|
938
|
+
function shorten(maxWidth, p) {
|
|
939
|
+
if (p.length <= maxWidth) {
|
|
940
|
+
return p;
|
|
941
|
+
}
|
|
942
|
+
const half = Math.floor((maxWidth - 3) / 2);
|
|
943
|
+
return p.slice(0, half) + "..." + p.slice(-half);
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
// ../../aws-cdk/lib/toolkit/cli-io-host.ts
|
|
947
|
+
var levelPriority = {
|
|
948
|
+
error: 0,
|
|
949
|
+
result: 1,
|
|
950
|
+
warn: 2,
|
|
951
|
+
info: 3,
|
|
952
|
+
debug: 4,
|
|
953
|
+
trace: 5
|
|
954
|
+
};
|
|
955
|
+
var CliIoHost = class _CliIoHost {
|
|
956
|
+
constructor(props = {}) {
|
|
957
|
+
this._progress = "bar" /* BAR */;
|
|
958
|
+
// Corked Logging
|
|
959
|
+
this.corkedCounter = 0;
|
|
960
|
+
this.corkedLoggingBuffer = [];
|
|
961
|
+
this._currentAction = props.currentAction ?? "none";
|
|
962
|
+
this._isTTY = props.isTTY ?? process.stdout.isTTY ?? false;
|
|
963
|
+
this._logLevel = props.logLevel ?? "info";
|
|
964
|
+
this._isCI = props.isCI ?? isCI();
|
|
965
|
+
this.stackProgress = props.stackProgress ?? "bar" /* BAR */;
|
|
966
|
+
}
|
|
967
|
+
/**
|
|
968
|
+
* Returns the singleton instance
|
|
969
|
+
*/
|
|
970
|
+
static instance(props = {}, forceNew = false) {
|
|
971
|
+
if (forceNew || !_CliIoHost._instance) {
|
|
972
|
+
_CliIoHost._instance = new _CliIoHost(props);
|
|
973
|
+
}
|
|
974
|
+
return _CliIoHost._instance;
|
|
975
|
+
}
|
|
976
|
+
/**
|
|
977
|
+
* Returns the singleton instance
|
|
978
|
+
*/
|
|
979
|
+
registerIoHost(ioHost) {
|
|
980
|
+
if (ioHost !== this) {
|
|
981
|
+
this._internalIoHost = ioHost;
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
/**
|
|
985
|
+
* Update the stackProgress preference.
|
|
986
|
+
*/
|
|
987
|
+
set stackProgress(type) {
|
|
988
|
+
this._progress = type;
|
|
989
|
+
}
|
|
990
|
+
/**
|
|
991
|
+
* Gets the stackProgress value.
|
|
992
|
+
*
|
|
993
|
+
* This takes into account other state of the ioHost,
|
|
994
|
+
* like if isTTY and isCI.
|
|
995
|
+
*/
|
|
996
|
+
get stackProgress() {
|
|
997
|
+
if (this._progress === "events" /* EVENTS */) {
|
|
998
|
+
return this._progress;
|
|
999
|
+
}
|
|
1000
|
+
const verboseLogging = levelPriority[this.logLevel] > levelPriority.info;
|
|
1001
|
+
if (verboseLogging) {
|
|
1002
|
+
return "events" /* EVENTS */;
|
|
1003
|
+
}
|
|
1004
|
+
const isWindows = process.platform === "win32";
|
|
1005
|
+
if (isWindows) {
|
|
1006
|
+
return "events" /* EVENTS */;
|
|
1007
|
+
}
|
|
1008
|
+
const fancyOutputAvailable = this.isTTY && !this.isCI;
|
|
1009
|
+
if (!fancyOutputAvailable) {
|
|
1010
|
+
return "events" /* EVENTS */;
|
|
1011
|
+
}
|
|
1012
|
+
return this._progress;
|
|
1013
|
+
}
|
|
1014
|
+
/**
|
|
1015
|
+
* The current action being performed by the CLI.
|
|
1016
|
+
*/
|
|
1017
|
+
get currentAction() {
|
|
1018
|
+
return this._currentAction;
|
|
1019
|
+
}
|
|
1020
|
+
/**
|
|
1021
|
+
* Sets the current action being performed by the CLI.
|
|
1022
|
+
*
|
|
1023
|
+
* @param action The action being performed by the CLI.
|
|
1024
|
+
*/
|
|
1025
|
+
set currentAction(action) {
|
|
1026
|
+
this._currentAction = action;
|
|
1027
|
+
}
|
|
1028
|
+
/**
|
|
1029
|
+
* Whether the host can use interactions and message styling.
|
|
1030
|
+
*/
|
|
1031
|
+
get isTTY() {
|
|
1032
|
+
return this._isTTY;
|
|
1033
|
+
}
|
|
1034
|
+
/**
|
|
1035
|
+
* Set TTY mode, i.e can the host use interactions and message styling.
|
|
1036
|
+
*
|
|
1037
|
+
* @param value set TTY mode
|
|
1038
|
+
*/
|
|
1039
|
+
set isTTY(value) {
|
|
1040
|
+
this._isTTY = value;
|
|
1041
|
+
}
|
|
1042
|
+
/**
|
|
1043
|
+
* Whether the CliIoHost is running in CI mode. In CI mode, all non-error output goes to stdout instead of stderr.
|
|
1044
|
+
*/
|
|
1045
|
+
get isCI() {
|
|
1046
|
+
return this._isCI;
|
|
1047
|
+
}
|
|
1048
|
+
/**
|
|
1049
|
+
* Set the CI mode. In CI mode, all non-error output goes to stdout instead of stderr.
|
|
1050
|
+
* @param value set the CI mode
|
|
1051
|
+
*/
|
|
1052
|
+
set isCI(value) {
|
|
1053
|
+
this._isCI = value;
|
|
1054
|
+
}
|
|
1055
|
+
/**
|
|
1056
|
+
* The current threshold. Messages with a lower priority level will be ignored.
|
|
1057
|
+
*/
|
|
1058
|
+
get logLevel() {
|
|
1059
|
+
return this._logLevel;
|
|
1060
|
+
}
|
|
1061
|
+
/**
|
|
1062
|
+
* Sets the current threshold. Messages with a lower priority level will be ignored.
|
|
1063
|
+
* @param level The new log level threshold
|
|
1064
|
+
*/
|
|
1065
|
+
set logLevel(level) {
|
|
1066
|
+
this._logLevel = level;
|
|
1067
|
+
}
|
|
1068
|
+
/**
|
|
1069
|
+
* Executes a block of code with corked logging. All log messages during execution
|
|
1070
|
+
* are buffered and only written when all nested cork blocks complete (when CORK_COUNTER reaches 0).
|
|
1071
|
+
* The corking is bound to the specific instance of the CliIoHost.
|
|
1072
|
+
*
|
|
1073
|
+
* @param block - Async function to execute with corked logging
|
|
1074
|
+
* @returns Promise that resolves with the block's return value
|
|
1075
|
+
*/
|
|
1076
|
+
async withCorkedLogging(block) {
|
|
1077
|
+
this.corkedCounter++;
|
|
1078
|
+
try {
|
|
1079
|
+
return await block();
|
|
1080
|
+
} finally {
|
|
1081
|
+
this.corkedCounter--;
|
|
1082
|
+
if (this.corkedCounter === 0) {
|
|
1083
|
+
for (const ioMessage of this.corkedLoggingBuffer) {
|
|
1084
|
+
await this.notify(ioMessage);
|
|
1085
|
+
}
|
|
1086
|
+
this.corkedLoggingBuffer.splice(0);
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
/**
|
|
1091
|
+
* Notifies the host of a message.
|
|
1092
|
+
* The caller waits until the notification completes.
|
|
1093
|
+
*/
|
|
1094
|
+
async notify(msg) {
|
|
1095
|
+
if (this._internalIoHost) {
|
|
1096
|
+
return this._internalIoHost.notify(msg);
|
|
1097
|
+
}
|
|
1098
|
+
if (this.isStackActivity(msg)) {
|
|
1099
|
+
if (!this.activityPrinter) {
|
|
1100
|
+
this.activityPrinter = this.makeActivityPrinter();
|
|
1101
|
+
}
|
|
1102
|
+
await this.activityPrinter.notify(msg);
|
|
1103
|
+
return;
|
|
1104
|
+
}
|
|
1105
|
+
if (levelPriority[msg.level] > levelPriority[this.logLevel]) {
|
|
1106
|
+
return;
|
|
1107
|
+
}
|
|
1108
|
+
if (this.corkedCounter > 0) {
|
|
1109
|
+
this.corkedLoggingBuffer.push(msg);
|
|
1110
|
+
return;
|
|
1111
|
+
}
|
|
1112
|
+
const output = this.formatMessage(msg);
|
|
1113
|
+
const stream = this.selectStream(msg.level);
|
|
1114
|
+
stream.write(output);
|
|
1115
|
+
}
|
|
1116
|
+
/**
|
|
1117
|
+
* Detect stack activity messages so they can be send to the printer.
|
|
1118
|
+
*/
|
|
1119
|
+
isStackActivity(msg) {
|
|
1120
|
+
return [
|
|
1121
|
+
"CDK_TOOLKIT_I5501",
|
|
1122
|
+
"CDK_TOOLKIT_I5502",
|
|
1123
|
+
"CDK_TOOLKIT_I5503"
|
|
1124
|
+
].includes(msg.code);
|
|
1125
|
+
}
|
|
1126
|
+
/**
|
|
1127
|
+
* Determines the output stream, based on message level and configuration.
|
|
1128
|
+
*/
|
|
1129
|
+
selectStream(level) {
|
|
1130
|
+
switch (level) {
|
|
1131
|
+
case "error":
|
|
1132
|
+
return process.stderr;
|
|
1133
|
+
case "result":
|
|
1134
|
+
return process.stdout;
|
|
1135
|
+
default:
|
|
1136
|
+
return this.isCI ? process.stdout : process.stderr;
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
/**
|
|
1140
|
+
* Notifies the host of a message that requires a response.
|
|
1141
|
+
*
|
|
1142
|
+
* If the host does not return a response the suggested
|
|
1143
|
+
* default response from the input message will be used.
|
|
1144
|
+
*/
|
|
1145
|
+
async requestResponse(msg) {
|
|
1146
|
+
if (this._internalIoHost) {
|
|
1147
|
+
return this._internalIoHost.requestResponse(msg);
|
|
1148
|
+
}
|
|
1149
|
+
if (!isPromptableRequest(msg)) {
|
|
1150
|
+
await this.notify(msg);
|
|
1151
|
+
return msg.defaultResponse;
|
|
1152
|
+
}
|
|
1153
|
+
const response = await this.withCorkedLogging(async () => {
|
|
1154
|
+
const data = msg.data ?? {};
|
|
1155
|
+
const motivation = data.motivation ?? "User input is needed";
|
|
1156
|
+
const concurrency = data.concurrency ?? 0;
|
|
1157
|
+
if (!this.isTTY) {
|
|
1158
|
+
throw new ToolkitError(`${motivation}, but terminal (TTY) is not attached so we are unable to get a confirmation from the user`);
|
|
1159
|
+
}
|
|
1160
|
+
if (concurrency > 1) {
|
|
1161
|
+
throw new ToolkitError(`${motivation}, but concurrency is greater than 1 so we are unable to get a confirmation from the user`);
|
|
1162
|
+
}
|
|
1163
|
+
if (isConfirmationPrompt(msg)) {
|
|
1164
|
+
const confirmed = await promptly.confirm(`${chalk3.cyan(msg.message)} (y/n)`);
|
|
1165
|
+
if (!confirmed) {
|
|
1166
|
+
throw new ToolkitError("Aborted by user");
|
|
1167
|
+
}
|
|
1168
|
+
return confirmed;
|
|
350
1169
|
}
|
|
351
1170
|
const prompt4 = extractPromptInfo(msg);
|
|
352
|
-
const answer = await promptly.prompt(`${
|
|
1171
|
+
const answer = await promptly.prompt(`${chalk3.cyan(msg.message)} (${prompt4.default})`, {
|
|
353
1172
|
default: prompt4.default
|
|
354
1173
|
});
|
|
355
1174
|
return prompt4.convertAnswer(answer);
|
|
@@ -370,6 +1189,20 @@ var CliIoHost = class _CliIoHost {
|
|
|
370
1189
|
const pad = (n) => n.toString().padStart(2, "0");
|
|
371
1190
|
return `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`;
|
|
372
1191
|
}
|
|
1192
|
+
/**
|
|
1193
|
+
* Get an instance of the ActivityPrinter
|
|
1194
|
+
*/
|
|
1195
|
+
makeActivityPrinter() {
|
|
1196
|
+
const props = {
|
|
1197
|
+
stream: this.selectStream("info")
|
|
1198
|
+
};
|
|
1199
|
+
switch (this.stackProgress) {
|
|
1200
|
+
case "events" /* EVENTS */:
|
|
1201
|
+
return new HistoryActivityPrinter(props);
|
|
1202
|
+
case "bar" /* BAR */:
|
|
1203
|
+
return new CurrentActivityPrinter(props);
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
373
1206
|
};
|
|
374
1207
|
function isPromptableRequest(msg) {
|
|
375
1208
|
return isConfirmationPrompt(msg) || typeof msg.defaultResponse === "string" || typeof msg.defaultResponse === "number";
|
|
@@ -380,17 +1213,17 @@ function isConfirmationPrompt(msg) {
|
|
|
380
1213
|
function extractPromptInfo(msg) {
|
|
381
1214
|
const isNumber = typeof msg.defaultResponse === "number";
|
|
382
1215
|
return {
|
|
383
|
-
default:
|
|
1216
|
+
default: util3.format(msg.defaultResponse),
|
|
384
1217
|
convertAnswer: isNumber ? (v) => Number(v) : (v) => String(v)
|
|
385
1218
|
};
|
|
386
1219
|
}
|
|
387
1220
|
var styleMap = {
|
|
388
|
-
error:
|
|
389
|
-
warn:
|
|
390
|
-
result:
|
|
391
|
-
info:
|
|
392
|
-
debug:
|
|
393
|
-
trace:
|
|
1221
|
+
error: chalk3.red,
|
|
1222
|
+
warn: chalk3.yellow,
|
|
1223
|
+
result: chalk3.white,
|
|
1224
|
+
info: chalk3.white,
|
|
1225
|
+
debug: chalk3.gray,
|
|
1226
|
+
trace: chalk3.gray
|
|
394
1227
|
};
|
|
395
1228
|
function isCI() {
|
|
396
1229
|
return process.env.CI !== void 0 && process.env.CI !== "false" && process.env.CI !== "0";
|
|
@@ -399,7 +1232,7 @@ function isCI() {
|
|
|
399
1232
|
// ../../aws-cdk/lib/logging.ts
|
|
400
1233
|
function formatMessageAndLog(level, input, style, ...args) {
|
|
401
1234
|
const { message, code = getDefaultCode(level) } = typeof input === "object" ? input : { message: input };
|
|
402
|
-
const formattedMessage = args.length > 0 ?
|
|
1235
|
+
const formattedMessage = args.length > 0 ? util4.format(message, ...args) : message;
|
|
403
1236
|
const finalMessage = style ? style(formattedMessage) : formattedMessage;
|
|
404
1237
|
const ioHost = CliIoHost.instance();
|
|
405
1238
|
const ioMessage = {
|
|
@@ -431,43 +1264,6 @@ var trace = (input, ...args) => {
|
|
|
431
1264
|
return formatMessageAndLog("trace", input, void 0, ...args);
|
|
432
1265
|
};
|
|
433
1266
|
|
|
434
|
-
// ../../aws-cdk/lib/util/directories.ts
|
|
435
|
-
var fs = __toESM(require("fs"));
|
|
436
|
-
var os = __toESM(require("os"));
|
|
437
|
-
var path = __toESM(require("path"));
|
|
438
|
-
function cdkHomeDir() {
|
|
439
|
-
const tmpDir = fs.realpathSync(os.tmpdir());
|
|
440
|
-
let home;
|
|
441
|
-
try {
|
|
442
|
-
let userInfoHome = os.userInfo().homedir;
|
|
443
|
-
if (userInfoHome == "/var/empty") {
|
|
444
|
-
userInfoHome = void 0;
|
|
445
|
-
}
|
|
446
|
-
home = path.join((userInfoHome ?? os.homedir()).trim(), ".cdk");
|
|
447
|
-
} catch {
|
|
448
|
-
}
|
|
449
|
-
return process.env.CDK_HOME ? path.resolve(process.env.CDK_HOME) : home || fs.mkdtempSync(path.join(tmpDir, ".cdk")).trim();
|
|
450
|
-
}
|
|
451
|
-
function cdkCacheDir() {
|
|
452
|
-
return path.join(cdkHomeDir(), "cache");
|
|
453
|
-
}
|
|
454
|
-
function rootDir(fail) {
|
|
455
|
-
function _rootDir(dirname5) {
|
|
456
|
-
const manifestPath = path.join(dirname5, "package.json");
|
|
457
|
-
if (fs.existsSync(manifestPath)) {
|
|
458
|
-
return dirname5;
|
|
459
|
-
}
|
|
460
|
-
if (path.dirname(dirname5) === dirname5) {
|
|
461
|
-
if (fail ?? true) {
|
|
462
|
-
throw new ToolkitError("Unable to find package manifest");
|
|
463
|
-
}
|
|
464
|
-
return void 0;
|
|
465
|
-
}
|
|
466
|
-
return _rootDir(path.dirname(dirname5));
|
|
467
|
-
}
|
|
468
|
-
return _rootDir(__dirname);
|
|
469
|
-
}
|
|
470
|
-
|
|
471
1267
|
// ../../aws-cdk/lib/api/aws-auth/account-cache.ts
|
|
472
1268
|
var AccountAccessKeyCache = class _AccountAccessKeyCache {
|
|
473
1269
|
static {
|
|
@@ -521,7 +1317,7 @@ var AccountAccessKeyCache = class _AccountAccessKeyCache {
|
|
|
521
1317
|
}
|
|
522
1318
|
async loadMap() {
|
|
523
1319
|
try {
|
|
524
|
-
return await
|
|
1320
|
+
return await fs3.readJson(this.cacheFile);
|
|
525
1321
|
} catch (e) {
|
|
526
1322
|
if (e.code === "ENOENT" || e.code === "EACCES") {
|
|
527
1323
|
return {};
|
|
@@ -534,8 +1330,8 @@ var AccountAccessKeyCache = class _AccountAccessKeyCache {
|
|
|
534
1330
|
}
|
|
535
1331
|
async saveMap(map) {
|
|
536
1332
|
try {
|
|
537
|
-
await
|
|
538
|
-
await
|
|
1333
|
+
await fs3.ensureFile(this.cacheFile);
|
|
1334
|
+
await fs3.writeJson(this.cacheFile, map, { spaces: 2 });
|
|
539
1335
|
} catch (e) {
|
|
540
1336
|
if (e.code === "ENOENT" || e.code === "EACCES" || e.code === "EROFS") {
|
|
541
1337
|
return;
|
|
@@ -604,13 +1400,13 @@ function traceMemberMethods(constructor) {
|
|
|
604
1400
|
var path3 = __toESM(require("path"));
|
|
605
1401
|
|
|
606
1402
|
// ../../aws-cdk/lib/api/aws-auth/util.ts
|
|
607
|
-
var
|
|
1403
|
+
var fs4 = __toESM(require("fs-extra"));
|
|
608
1404
|
function readIfPossible(filename) {
|
|
609
1405
|
try {
|
|
610
|
-
if (!
|
|
1406
|
+
if (!fs4.pathExistsSync(filename)) {
|
|
611
1407
|
return void 0;
|
|
612
1408
|
}
|
|
613
|
-
return
|
|
1409
|
+
return fs4.readFileSync(filename, { encoding: "utf-8" });
|
|
614
1410
|
} catch (e) {
|
|
615
1411
|
debug(e);
|
|
616
1412
|
return void 0;
|
|
@@ -619,22 +1415,13 @@ function readIfPossible(filename) {
|
|
|
619
1415
|
|
|
620
1416
|
// ../../aws-cdk/lib/api/aws-auth/user-agent.ts
|
|
621
1417
|
function defaultCliUserAgent() {
|
|
622
|
-
const root =
|
|
1418
|
+
const root = bundledPackageRootDir(__dirname, false);
|
|
623
1419
|
const pkg = JSON.parse((root ? readIfPossible(path3.join(root, "package.json")) : void 0) ?? "{}");
|
|
624
1420
|
const name = pkg.name ?? path3.basename(process.argv[1] ?? "cdk-cli");
|
|
625
1421
|
const version = pkg.version ?? "<unknown>";
|
|
626
1422
|
return `${name}/${version}`;
|
|
627
1423
|
}
|
|
628
1424
|
|
|
629
|
-
// ../../aws-cdk/lib/util/format-error.ts
|
|
630
|
-
function formatErrorMessage(error3) {
|
|
631
|
-
if (error3 && Array.isArray(error3.errors)) {
|
|
632
|
-
const innerMessages = error3.errors.map((innerError) => innerError?.message || innerError?.toString()).join("\n");
|
|
633
|
-
return `AggregateError: ${innerMessages}`;
|
|
634
|
-
}
|
|
635
|
-
return error3?.message || error3?.toString() || "Unknown error";
|
|
636
|
-
}
|
|
637
|
-
|
|
638
1425
|
// ../../aws-cdk/lib/api/aws-auth/sdk.ts
|
|
639
1426
|
var SDK = class {
|
|
640
1427
|
constructor(credProvider, region, requestHandler, logger) {
|
|
@@ -1087,10 +1874,10 @@ function getRegionFromIniFile(profile, data) {
|
|
|
1087
1874
|
return data?.[profile]?.region;
|
|
1088
1875
|
}
|
|
1089
1876
|
function tryGetCACert(bundlePath) {
|
|
1090
|
-
const
|
|
1091
|
-
if (
|
|
1092
|
-
debug("Using CA bundle path: %s",
|
|
1093
|
-
return readIfPossible(
|
|
1877
|
+
const path15 = bundlePath || caBundlePathFromEnvironment();
|
|
1878
|
+
if (path15) {
|
|
1879
|
+
debug("Using CA bundle path: %s", path15);
|
|
1880
|
+
return readIfPossible(path15);
|
|
1094
1881
|
}
|
|
1095
1882
|
return void 0;
|
|
1096
1883
|
}
|
|
@@ -1150,11 +1937,11 @@ async function tokenCodeFn(serialArn) {
|
|
|
1150
1937
|
}
|
|
1151
1938
|
|
|
1152
1939
|
// ../../aws-cdk/lib/api/aws-auth/credential-plugins.ts
|
|
1153
|
-
var
|
|
1940
|
+
var import_util10 = require("util");
|
|
1154
1941
|
|
|
1155
1942
|
// ../../aws-cdk/lib/api/plugin/plugin.ts
|
|
1156
|
-
var
|
|
1157
|
-
var
|
|
1943
|
+
var import_util9 = require("util");
|
|
1944
|
+
var chalk5 = __toESM(require("chalk"));
|
|
1158
1945
|
|
|
1159
1946
|
// ../../aws-cdk/lib/api/plugin/context-provider-plugin.ts
|
|
1160
1947
|
function isContextProviderPlugin(x) {
|
|
@@ -1187,14 +1974,14 @@ var PluginHost = class _PluginHost {
|
|
|
1187
1974
|
try {
|
|
1188
1975
|
const plugin = require(moduleSpec);
|
|
1189
1976
|
if (!isPlugin(plugin)) {
|
|
1190
|
-
error(`Module ${
|
|
1977
|
+
error(`Module ${chalk5.green(moduleSpec)} is not a valid plug-in, or has an unsupported version.`);
|
|
1191
1978
|
throw new ToolkitError(`Module ${moduleSpec} does not define a valid plug-in.`);
|
|
1192
1979
|
}
|
|
1193
1980
|
if (plugin.init) {
|
|
1194
1981
|
plugin.init(this);
|
|
1195
1982
|
}
|
|
1196
1983
|
} catch (e) {
|
|
1197
|
-
error(`Unable to load ${
|
|
1984
|
+
error(`Unable to load ${chalk5.green(moduleSpec)}: ${e.stack}`);
|
|
1198
1985
|
throw new ToolkitError(`Unable to load plug-in: ${moduleSpec}: ${e}`);
|
|
1199
1986
|
}
|
|
1200
1987
|
function isPlugin(x) {
|
|
@@ -1243,7 +2030,7 @@ var PluginHost = class _PluginHost {
|
|
|
1243
2030
|
*/
|
|
1244
2031
|
registerContextProviderAlpha(pluginProviderName, provider) {
|
|
1245
2032
|
if (!isContextProviderPlugin(provider)) {
|
|
1246
|
-
throw new ToolkitError(`Object you gave me does not look like a ContextProviderPlugin: ${(0,
|
|
2033
|
+
throw new ToolkitError(`Object you gave me does not look like a ContextProviderPlugin: ${(0, import_util9.inspect)(provider)}`);
|
|
1247
2034
|
}
|
|
1248
2035
|
this.contextProviderPlugins[pluginProviderName] = provider;
|
|
1249
2036
|
}
|
|
@@ -1312,7 +2099,7 @@ async function v3ProviderFromPlugin(producer) {
|
|
|
1312
2099
|
} else if (isV2Credentials(initial)) {
|
|
1313
2100
|
return v3ProviderFromV2Credentials(initial);
|
|
1314
2101
|
} else {
|
|
1315
|
-
throw new AuthenticationError(`Plugin returned a value that doesn't resemble AWS credentials: ${(0,
|
|
2102
|
+
throw new AuthenticationError(`Plugin returned a value that doesn't resemble AWS credentials: ${(0, import_util10.inspect)(initial)}`);
|
|
1316
2103
|
}
|
|
1317
2104
|
}
|
|
1318
2105
|
function v3ProviderFromV2Credentials(x) {
|
|
@@ -1331,7 +2118,7 @@ function refreshFromPluginProvider(current, producer) {
|
|
|
1331
2118
|
if (credentialsAboutToExpire(current)) {
|
|
1332
2119
|
const newCreds = await producer();
|
|
1333
2120
|
if (!isV3Credentials(newCreds)) {
|
|
1334
|
-
throw new AuthenticationError(`Plugin initially returned static V3 credentials but now returned something else: ${(0,
|
|
2121
|
+
throw new AuthenticationError(`Plugin initially returned static V3 credentials but now returned something else: ${(0, import_util10.inspect)(newCreds)}`);
|
|
1335
2122
|
}
|
|
1336
2123
|
current = newCreds;
|
|
1337
2124
|
}
|
|
@@ -1604,133 +2391,23 @@ function fmtObtainedCredentials(obtainResult) {
|
|
|
1604
2391
|
if (obtainResult.unusedPlugins.length > 0) {
|
|
1605
2392
|
msg.push(`, and none of the following plugins provided credentials: ${obtainResult.unusedPlugins.join(", ")}`);
|
|
1606
2393
|
}
|
|
1607
|
-
msg.push(")");
|
|
1608
|
-
return msg.join("");
|
|
1609
|
-
}
|
|
1610
|
-
}
|
|
1611
|
-
async function initContextProviderSdk(aws, options) {
|
|
1612
|
-
const account = options.account;
|
|
1613
|
-
const region = options.region;
|
|
1614
|
-
const creds = {
|
|
1615
|
-
assumeRoleArn: options.lookupRoleArn,
|
|
1616
|
-
assumeRoleExternalId: options.lookupRoleExternalId,
|
|
1617
|
-
assumeRoleAdditionalOptions: options.assumeRoleAdditionalOptions
|
|
1618
|
-
};
|
|
1619
|
-
return (await aws.forEnvironment(import_cx_api.EnvironmentUtils.make(account, region), 0 /* ForReading */, creds)).sdk;
|
|
1620
|
-
}
|
|
1621
|
-
|
|
1622
|
-
// ../../aws-cdk/lib/api/aws-auth/sdk-logger.ts
|
|
1623
|
-
var import_util5 = require("util");
|
|
1624
|
-
|
|
1625
|
-
// ../../aws-cdk/lib/util/serialize.ts
|
|
1626
|
-
var fs4 = __toESM(require("fs-extra"));
|
|
1627
|
-
|
|
1628
|
-
// ../../aws-cdk/lib/util/bytes.ts
|
|
1629
|
-
function formatBytes(bytes, decimals = 2) {
|
|
1630
|
-
decimals = decimals < 0 ? 0 : decimals;
|
|
1631
|
-
if (bytes === 0) {
|
|
1632
|
-
return "0 Bytes";
|
|
1633
|
-
}
|
|
1634
|
-
const k = 1024;
|
|
1635
|
-
const sizes = ["Bytes", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"];
|
|
1636
|
-
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
1637
|
-
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(decimals))} ${sizes[i]}`;
|
|
1638
|
-
}
|
|
1639
|
-
|
|
1640
|
-
// ../../aws-cdk/lib/util/yaml-cfn.ts
|
|
1641
|
-
var yaml = __toESM(require("yaml"));
|
|
1642
|
-
var yaml_types = __toESM(require("yaml/types"));
|
|
1643
|
-
function serialize(obj) {
|
|
1644
|
-
const oldFold = yaml_types.strOptions.fold.lineWidth;
|
|
1645
|
-
try {
|
|
1646
|
-
yaml_types.strOptions.fold.lineWidth = 0;
|
|
1647
|
-
return yaml.stringify(obj, { schema: "yaml-1.1" });
|
|
1648
|
-
} finally {
|
|
1649
|
-
yaml_types.strOptions.fold.lineWidth = oldFold;
|
|
1650
|
-
}
|
|
1651
|
-
}
|
|
1652
|
-
function deserialize(str) {
|
|
1653
|
-
return parseYamlStrWithCfnTags(str);
|
|
1654
|
-
}
|
|
1655
|
-
function makeTagForCfnIntrinsic(intrinsicName, addFnPrefix) {
|
|
1656
|
-
return {
|
|
1657
|
-
identify(value) {
|
|
1658
|
-
return typeof value === "string";
|
|
1659
|
-
},
|
|
1660
|
-
tag: `!${intrinsicName}`,
|
|
1661
|
-
resolve: (_doc, cstNode) => {
|
|
1662
|
-
const ret = {};
|
|
1663
|
-
ret[addFnPrefix ? `Fn::${intrinsicName}` : intrinsicName] = // the +1 is to account for the ! the short form begins with
|
|
1664
|
-
parseYamlStrWithCfnTags(cstNode.toString().substring(intrinsicName.length + 1));
|
|
1665
|
-
return ret;
|
|
1666
|
-
}
|
|
1667
|
-
};
|
|
1668
|
-
}
|
|
1669
|
-
var shortForms = [
|
|
1670
|
-
"Base64",
|
|
1671
|
-
"Cidr",
|
|
1672
|
-
"FindInMap",
|
|
1673
|
-
"GetAZs",
|
|
1674
|
-
"ImportValue",
|
|
1675
|
-
"Join",
|
|
1676
|
-
"Sub",
|
|
1677
|
-
"Select",
|
|
1678
|
-
"Split",
|
|
1679
|
-
"Transform",
|
|
1680
|
-
"And",
|
|
1681
|
-
"Equals",
|
|
1682
|
-
"If",
|
|
1683
|
-
"Not",
|
|
1684
|
-
"Or",
|
|
1685
|
-
"GetAtt"
|
|
1686
|
-
].map((name) => makeTagForCfnIntrinsic(name, true)).concat(
|
|
1687
|
-
makeTagForCfnIntrinsic("Ref", false),
|
|
1688
|
-
makeTagForCfnIntrinsic("Condition", false)
|
|
1689
|
-
);
|
|
1690
|
-
function parseYamlStrWithCfnTags(text) {
|
|
1691
|
-
return yaml.parse(text, {
|
|
1692
|
-
customTags: shortForms,
|
|
1693
|
-
schema: "core"
|
|
1694
|
-
});
|
|
1695
|
-
}
|
|
1696
|
-
|
|
1697
|
-
// ../../aws-cdk/lib/util/serialize.ts
|
|
1698
|
-
function toYAML(obj) {
|
|
1699
|
-
return serialize(obj);
|
|
1700
|
-
}
|
|
1701
|
-
function deserializeStructure(str) {
|
|
1702
|
-
return deserialize(str);
|
|
1703
|
-
}
|
|
1704
|
-
function serializeStructure(object, json) {
|
|
1705
|
-
if (json) {
|
|
1706
|
-
return JSON.stringify(object, void 0, 2);
|
|
1707
|
-
} else {
|
|
1708
|
-
return toYAML(object);
|
|
1709
|
-
}
|
|
1710
|
-
}
|
|
1711
|
-
function obscureTemplate(template = {}) {
|
|
1712
|
-
if (template.Rules) {
|
|
1713
|
-
if (template.Rules.CheckBootstrapVersion) {
|
|
1714
|
-
if (Object.keys(template.Rules).length > 1) {
|
|
1715
|
-
delete template.Rules.CheckBootstrapVersion;
|
|
1716
|
-
} else {
|
|
1717
|
-
delete template.Rules;
|
|
1718
|
-
}
|
|
1719
|
-
}
|
|
2394
|
+
msg.push(")");
|
|
2395
|
+
return msg.join("");
|
|
1720
2396
|
}
|
|
1721
|
-
return template;
|
|
1722
|
-
}
|
|
1723
|
-
function isJsonBuffer(value) {
|
|
1724
|
-
return typeof value === "object" && "type" in value && value.type === "Buffer" && "data" in value && Array.isArray(value.data);
|
|
1725
2397
|
}
|
|
1726
|
-
function
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
2398
|
+
async function initContextProviderSdk(aws, options) {
|
|
2399
|
+
const account = options.account;
|
|
2400
|
+
const region = options.region;
|
|
2401
|
+
const creds = {
|
|
2402
|
+
assumeRoleArn: options.lookupRoleArn,
|
|
2403
|
+
assumeRoleExternalId: options.lookupRoleExternalId,
|
|
2404
|
+
assumeRoleAdditionalOptions: options.assumeRoleAdditionalOptions
|
|
2405
|
+
};
|
|
2406
|
+
return (await aws.forEnvironment(import_cx_api.EnvironmentUtils.make(account, region), 0 /* ForReading */, creds)).sdk;
|
|
1731
2407
|
}
|
|
1732
2408
|
|
|
1733
2409
|
// ../../aws-cdk/lib/api/aws-auth/sdk-logger.ts
|
|
2410
|
+
var import_util13 = require("util");
|
|
1734
2411
|
function formatSdkLoggerContent(content) {
|
|
1735
2412
|
if (content.length === 1) {
|
|
1736
2413
|
const apiFmt = formatApiCall(content[0]);
|
|
@@ -1738,7 +2415,7 @@ function formatSdkLoggerContent(content) {
|
|
|
1738
2415
|
return apiFmt;
|
|
1739
2416
|
}
|
|
1740
2417
|
}
|
|
1741
|
-
return content.map((x) => typeof x === "string" ? x : (0,
|
|
2418
|
+
return content.map((x) => typeof x === "string" ? x : (0, import_util13.inspect)(x)).join("");
|
|
1742
2419
|
}
|
|
1743
2420
|
function formatApiCall(content) {
|
|
1744
2421
|
if (!isSdkApiCallSuccess(content) && !isSdkApiCallError(content)) {
|
|
@@ -1769,122 +2446,6 @@ function isSdkApiCallError(x) {
|
|
|
1769
2446
|
var os3 = __toESM(require("os"));
|
|
1770
2447
|
var fs_path = __toESM(require("path"));
|
|
1771
2448
|
var fs5 = __toESM(require("fs-extra"));
|
|
1772
|
-
|
|
1773
|
-
// ../../aws-cdk/lib/util/types.ts
|
|
1774
|
-
function isObject(x) {
|
|
1775
|
-
return x !== null && typeof x === "object" && !isArray(x);
|
|
1776
|
-
}
|
|
1777
|
-
var isArray = Array.isArray;
|
|
1778
|
-
|
|
1779
|
-
// ../../aws-cdk/lib/util/objects.ts
|
|
1780
|
-
function deepClone(x) {
|
|
1781
|
-
if (typeof x === "undefined") {
|
|
1782
|
-
return void 0;
|
|
1783
|
-
}
|
|
1784
|
-
if (x === null) {
|
|
1785
|
-
return null;
|
|
1786
|
-
}
|
|
1787
|
-
if (isArray(x)) {
|
|
1788
|
-
return x.map(deepClone);
|
|
1789
|
-
}
|
|
1790
|
-
if (isObject(x)) {
|
|
1791
|
-
return makeObject(mapObject(x, (k, v) => [k, deepClone(v)]));
|
|
1792
|
-
}
|
|
1793
|
-
return x;
|
|
1794
|
-
}
|
|
1795
|
-
function mapObject(x, fn) {
|
|
1796
|
-
const ret = [];
|
|
1797
|
-
Object.keys(x).forEach((key) => {
|
|
1798
|
-
ret.push(fn(key, x[key]));
|
|
1799
|
-
});
|
|
1800
|
-
return ret;
|
|
1801
|
-
}
|
|
1802
|
-
function makeObject(pairs) {
|
|
1803
|
-
const ret = {};
|
|
1804
|
-
for (const pair of pairs) {
|
|
1805
|
-
ret[pair[0]] = pair[1];
|
|
1806
|
-
}
|
|
1807
|
-
return ret;
|
|
1808
|
-
}
|
|
1809
|
-
function deepGet(x, path12) {
|
|
1810
|
-
path12 = path12.slice();
|
|
1811
|
-
while (path12.length > 0 && isObject(x)) {
|
|
1812
|
-
const key = path12.shift();
|
|
1813
|
-
x = x[key];
|
|
1814
|
-
}
|
|
1815
|
-
return path12.length === 0 ? x : void 0;
|
|
1816
|
-
}
|
|
1817
|
-
function deepSet(x, path12, value) {
|
|
1818
|
-
path12 = path12.slice();
|
|
1819
|
-
if (path12.length === 0) {
|
|
1820
|
-
throw new ToolkitError("Path may not be empty");
|
|
1821
|
-
}
|
|
1822
|
-
while (path12.length > 1 && isObject(x)) {
|
|
1823
|
-
const key = path12.shift();
|
|
1824
|
-
if (!(key in x)) {
|
|
1825
|
-
x[key] = {};
|
|
1826
|
-
}
|
|
1827
|
-
x = x[key];
|
|
1828
|
-
}
|
|
1829
|
-
if (!isObject(x)) {
|
|
1830
|
-
throw new ToolkitError(`Expected an object, got '${x}'`);
|
|
1831
|
-
}
|
|
1832
|
-
if (value !== void 0) {
|
|
1833
|
-
x[path12[0]] = value;
|
|
1834
|
-
} else {
|
|
1835
|
-
delete x[path12[0]];
|
|
1836
|
-
}
|
|
1837
|
-
}
|
|
1838
|
-
function deepMerge(...objects) {
|
|
1839
|
-
function mergeOne(target, source) {
|
|
1840
|
-
for (const key of Object.keys(source)) {
|
|
1841
|
-
if (key === "__proto__" || key === "constructor") {
|
|
1842
|
-
continue;
|
|
1843
|
-
}
|
|
1844
|
-
const value = source[key];
|
|
1845
|
-
if (isObject(value)) {
|
|
1846
|
-
if (!isObject(target[key])) {
|
|
1847
|
-
target[key] = {};
|
|
1848
|
-
}
|
|
1849
|
-
mergeOne(target[key], value);
|
|
1850
|
-
} else if (typeof value !== "undefined") {
|
|
1851
|
-
target[key] = value;
|
|
1852
|
-
}
|
|
1853
|
-
}
|
|
1854
|
-
}
|
|
1855
|
-
const others = objects.filter((x) => x != null);
|
|
1856
|
-
if (others.length === 0) {
|
|
1857
|
-
return {};
|
|
1858
|
-
}
|
|
1859
|
-
const into = others.splice(0, 1)[0];
|
|
1860
|
-
others.forEach((other) => mergeOne(into, other));
|
|
1861
|
-
return into;
|
|
1862
|
-
}
|
|
1863
|
-
function splitBySize(data, maxSizeBytes) {
|
|
1864
|
-
if (maxSizeBytes < 2) {
|
|
1865
|
-
return [void 0, data];
|
|
1866
|
-
}
|
|
1867
|
-
const entries = Object.entries(data);
|
|
1868
|
-
return recurse(0, 0);
|
|
1869
|
-
function recurse(index, runningTotalSize) {
|
|
1870
|
-
if (index >= entries.length) {
|
|
1871
|
-
return [data, void 0];
|
|
1872
|
-
}
|
|
1873
|
-
const size = runningTotalSize + entrySize(entries[index]);
|
|
1874
|
-
return size > maxSizeBytes ? cutAt(index) : recurse(index + 1, size);
|
|
1875
|
-
}
|
|
1876
|
-
function entrySize(entry) {
|
|
1877
|
-
return Buffer.byteLength(JSON.stringify(Object.fromEntries([entry])));
|
|
1878
|
-
}
|
|
1879
|
-
function cutAt(index) {
|
|
1880
|
-
return [
|
|
1881
|
-
Object.fromEntries(entries.slice(0, index)),
|
|
1882
|
-
Object.fromEntries(entries.slice(index))
|
|
1883
|
-
];
|
|
1884
|
-
}
|
|
1885
|
-
}
|
|
1886
|
-
|
|
1887
|
-
// ../../aws-cdk/lib/api/settings.ts
|
|
1888
2449
|
var TRANSIENT_CONTEXT_KEY = "$dontSaveContext";
|
|
1889
2450
|
var Settings = class _Settings {
|
|
1890
2451
|
constructor(settings = {}, readOnly = false) {
|
|
@@ -1942,22 +2503,22 @@ var Settings = class _Settings {
|
|
|
1942
2503
|
get empty() {
|
|
1943
2504
|
return Object.keys(this.settings).length === 0;
|
|
1944
2505
|
}
|
|
1945
|
-
get(
|
|
1946
|
-
return deepClone(deepGet(this.settings,
|
|
2506
|
+
get(path15) {
|
|
2507
|
+
return deepClone(deepGet(this.settings, path15));
|
|
1947
2508
|
}
|
|
1948
|
-
set(
|
|
2509
|
+
set(path15, value) {
|
|
1949
2510
|
if (this.readOnly) {
|
|
1950
|
-
throw new ToolkitError(`Can't set ${
|
|
2511
|
+
throw new ToolkitError(`Can't set ${path15}: settings object is readonly`);
|
|
1951
2512
|
}
|
|
1952
|
-
if (
|
|
2513
|
+
if (path15.length === 0) {
|
|
1953
2514
|
this.settings = value;
|
|
1954
2515
|
} else {
|
|
1955
|
-
deepSet(this.settings,
|
|
2516
|
+
deepSet(this.settings, path15, value);
|
|
1956
2517
|
}
|
|
1957
2518
|
return this;
|
|
1958
2519
|
}
|
|
1959
|
-
unset(
|
|
1960
|
-
this.set(
|
|
2520
|
+
unset(path15) {
|
|
2521
|
+
this.set(path15, void 0);
|
|
1961
2522
|
}
|
|
1962
2523
|
prohibitContextKey(key, fileName) {
|
|
1963
2524
|
if (!this.settings.context) {
|
|
@@ -2069,7 +2630,7 @@ var Context = class {
|
|
|
2069
2630
|
};
|
|
2070
2631
|
|
|
2071
2632
|
// ../../aws-cdk/lib/api/deployments/cloudformation.ts
|
|
2072
|
-
var
|
|
2633
|
+
var import_util19 = require("util");
|
|
2073
2634
|
var cxapi = __toESM(require("@aws-cdk/cx-api"));
|
|
2074
2635
|
var import_cx_api3 = require("@aws-cdk/cx-api");
|
|
2075
2636
|
var import_client_cloudformation3 = require("@aws-sdk/client-cloudformation");
|
|
@@ -2169,9 +2730,9 @@ var trace2 = (action, message, code, payload) => {
|
|
|
2169
2730
|
};
|
|
2170
2731
|
|
|
2171
2732
|
// ../../aws-cdk/lib/api/stack-events/stack-activity-monitor.ts
|
|
2172
|
-
var
|
|
2733
|
+
var util6 = __toESM(require("util"));
|
|
2173
2734
|
var import_cloud_assembly_schema = require("@aws-cdk/cloud-assembly-schema");
|
|
2174
|
-
var
|
|
2735
|
+
var uuid = __toESM(require("uuid"));
|
|
2175
2736
|
|
|
2176
2737
|
// ../../aws-cdk/lib/api/stack-events/stack-event-poller.ts
|
|
2177
2738
|
var StackEventPoller = class _StackEventPoller {
|
|
@@ -2233,278 +2794,60 @@ var StackEventPoller = class _StackEventPoller {
|
|
|
2233
2794
|
isStackEvent: isParentStackEvent
|
|
2234
2795
|
};
|
|
2235
2796
|
events.push(resEvent);
|
|
2236
|
-
if (!isParentStackEvent && event.ResourceType === "AWS::CloudFormation::Stack" && isStackBeginOperationState(event.ResourceStatus)) {
|
|
2237
|
-
this.trackNestedStack(event, [...this.props.parentStackLogicalIds ?? [], event.LogicalResourceId ?? ""]);
|
|
2238
|
-
}
|
|
2239
|
-
if (isParentStackEvent && isStackTerminalState(event.ResourceStatus)) {
|
|
2240
|
-
this.complete = true;
|
|
2241
|
-
}
|
|
2242
|
-
}
|
|
2243
|
-
nextToken = page?.NextToken;
|
|
2244
|
-
if (nextToken === void 0) {
|
|
2245
|
-
finished = true;
|
|
2246
|
-
}
|
|
2247
|
-
}
|
|
2248
|
-
} catch (e) {
|
|
2249
|
-
if (!(e.name === "ValidationError" && formatErrorMessage(e) === `Stack [${this.props.stackName}] does not exist`)) {
|
|
2250
|
-
throw e;
|
|
2251
|
-
}
|
|
2252
|
-
}
|
|
2253
|
-
return events;
|
|
2254
|
-
}
|
|
2255
|
-
/**
|
|
2256
|
-
* On the CREATE_IN_PROGRESS, UPDATE_IN_PROGRESS, DELETE_IN_PROGRESS event of a nested stack, poll the nested stack updates
|
|
2257
|
-
*/
|
|
2258
|
-
trackNestedStack(event, parentStackLogicalIds) {
|
|
2259
|
-
const logicalId = event.LogicalResourceId;
|
|
2260
|
-
const physicalResourceId = event.PhysicalResourceId;
|
|
2261
|
-
if (!logicalId || !physicalResourceId) {
|
|
2262
|
-
return;
|
|
2263
|
-
}
|
|
2264
|
-
if (!this.nestedStackPollers[logicalId]) {
|
|
2265
|
-
this.nestedStackPollers[logicalId] = new _StackEventPoller(this.cfn, {
|
|
2266
|
-
stackName: physicalResourceId,
|
|
2267
|
-
parentStackLogicalIds,
|
|
2268
|
-
startTime: event.Timestamp.valueOf()
|
|
2269
|
-
});
|
|
2270
|
-
}
|
|
2271
|
-
}
|
|
2272
|
-
};
|
|
2273
|
-
function isStackBeginOperationState(state) {
|
|
2274
|
-
return [
|
|
2275
|
-
"CREATE_IN_PROGRESS",
|
|
2276
|
-
"UPDATE_IN_PROGRESS",
|
|
2277
|
-
"DELETE_IN_PROGRESS",
|
|
2278
|
-
"UPDATE_ROLLBACK_IN_PROGRESS",
|
|
2279
|
-
"ROLLBACK_IN_PROGRESS"
|
|
2280
|
-
].includes(state ?? "");
|
|
2281
|
-
}
|
|
2282
|
-
function isStackTerminalState(state) {
|
|
2283
|
-
return !(state ?? "").endsWith("_IN_PROGRESS");
|
|
2284
|
-
}
|
|
2285
|
-
|
|
2286
|
-
// ../../aws-cdk/lib/api/stack-events/display.ts
|
|
2287
|
-
var wrapAnsi = require("wrap-ansi");
|
|
2288
|
-
var RewritableBlock = class {
|
|
2289
|
-
constructor(stream) {
|
|
2290
|
-
this.stream = stream;
|
|
2291
|
-
this.lastHeight = 0;
|
|
2292
|
-
this.trailingEmptyLines = 0;
|
|
2293
|
-
}
|
|
2294
|
-
get width() {
|
|
2295
|
-
return this.stream.columns;
|
|
2296
|
-
}
|
|
2297
|
-
get height() {
|
|
2298
|
-
return this.stream.rows;
|
|
2299
|
-
}
|
|
2300
|
-
displayLines(lines) {
|
|
2301
|
-
lines = terminalWrap(this.width, expandNewlines(lines));
|
|
2302
|
-
lines = lines.slice(0, getMaxBlockHeight(this.height, this.lastHeight, lines));
|
|
2303
|
-
this.stream.write(cursorUp(this.lastHeight));
|
|
2304
|
-
for (const line of lines) {
|
|
2305
|
-
this.stream.write(cll() + line + "\n");
|
|
2306
|
-
}
|
|
2307
|
-
this.trailingEmptyLines = Math.max(0, this.lastHeight - lines.length);
|
|
2308
|
-
for (let i = 0; i < this.trailingEmptyLines; i++) {
|
|
2309
|
-
this.stream.write(cll() + "\n");
|
|
2310
|
-
}
|
|
2311
|
-
this.lastHeight = Math.max(this.lastHeight, lines.length);
|
|
2312
|
-
}
|
|
2313
|
-
removeEmptyLines() {
|
|
2314
|
-
this.stream.write(cursorUp(this.trailingEmptyLines));
|
|
2315
|
-
}
|
|
2316
|
-
};
|
|
2317
|
-
var ESC = "\x1B";
|
|
2318
|
-
function cursorUp(n) {
|
|
2319
|
-
n = typeof n === "number" ? n : 1;
|
|
2320
|
-
return n > 0 ? ESC + "[" + n + "A" : "";
|
|
2321
|
-
}
|
|
2322
|
-
function cll() {
|
|
2323
|
-
return ESC + "[K";
|
|
2324
|
-
}
|
|
2325
|
-
function terminalWrap(width, lines) {
|
|
2326
|
-
if (width === void 0) {
|
|
2327
|
-
return lines;
|
|
2328
|
-
}
|
|
2329
|
-
return lines.flatMap((line) => wrapAnsi(line, width - 1, {
|
|
2330
|
-
hard: true,
|
|
2331
|
-
trim: true,
|
|
2332
|
-
wordWrap: false
|
|
2333
|
-
}).split("\n"));
|
|
2334
|
-
}
|
|
2335
|
-
function expandNewlines(lines) {
|
|
2336
|
-
return lines.flatMap((line) => line.split("\n"));
|
|
2337
|
-
}
|
|
2338
|
-
function getMaxBlockHeight(windowHeight, lastHeight, lines) {
|
|
2339
|
-
if (windowHeight === void 0) {
|
|
2340
|
-
return Math.max(lines.length, lastHeight);
|
|
2341
|
-
}
|
|
2342
|
-
return lines.length < windowHeight ? lines.length : windowHeight - 1;
|
|
2343
|
-
}
|
|
2344
|
-
|
|
2345
|
-
// ../../aws-cdk/lib/api/stack-events/stack-activity-monitor.ts
|
|
2346
|
-
var StackActivityProgress = /* @__PURE__ */ ((StackActivityProgress3) => {
|
|
2347
|
-
StackActivityProgress3["BAR"] = "bar";
|
|
2348
|
-
StackActivityProgress3["EVENTS"] = "events";
|
|
2349
|
-
return StackActivityProgress3;
|
|
2350
|
-
})(StackActivityProgress || {});
|
|
2351
|
-
var StackActivityMonitor = class _StackActivityMonitor {
|
|
2352
|
-
constructor(cfn, stackName, printer, stack, changeSetCreationTime) {
|
|
2353
|
-
this.stackName = stackName;
|
|
2354
|
-
this.printer = printer;
|
|
2355
|
-
this.stack = stack;
|
|
2356
|
-
this.errors = [];
|
|
2357
|
-
this.active = false;
|
|
2358
|
-
this.poller = new StackEventPoller(cfn, {
|
|
2359
|
-
stackName,
|
|
2360
|
-
startTime: changeSetCreationTime?.getTime() ?? Date.now()
|
|
2361
|
-
});
|
|
2362
|
-
}
|
|
2363
|
-
/**
|
|
2364
|
-
* Create a Stack Activity Monitor using a default printer, based on context clues
|
|
2365
|
-
*/
|
|
2366
|
-
static withDefaultPrinter(cfn, stackName, stackArtifact, options = {}) {
|
|
2367
|
-
const stream = options.ci ? process.stdout : process.stderr;
|
|
2368
|
-
const props = {
|
|
2369
|
-
resourceTypeColumnWidth: calcMaxResourceTypeLength(stackArtifact.template),
|
|
2370
|
-
resourcesTotal: options.resourcesTotal,
|
|
2371
|
-
stream
|
|
2372
|
-
};
|
|
2373
|
-
const isWindows = process.platform === "win32";
|
|
2374
|
-
const verbose = options.logLevel ?? "info";
|
|
2375
|
-
const fancyOutputAvailable = !isWindows && stream.isTTY && !options.ci;
|
|
2376
|
-
const progress = options.progress ?? "bar" /* BAR */;
|
|
2377
|
-
const printer = fancyOutputAvailable && !verbose && progress === "bar" /* BAR */ ? new CurrentActivityPrinter(props) : new HistoryActivityPrinter(props);
|
|
2378
|
-
return new _StackActivityMonitor(cfn, stackName, printer, stackArtifact, options.changeSetCreationTime);
|
|
2379
|
-
}
|
|
2380
|
-
start() {
|
|
2381
|
-
this.active = true;
|
|
2382
|
-
this.printer.start();
|
|
2383
|
-
this.scheduleNextTick();
|
|
2384
|
-
return this;
|
|
2385
|
-
}
|
|
2386
|
-
async stop() {
|
|
2387
|
-
this.active = false;
|
|
2388
|
-
if (this.tickTimer) {
|
|
2389
|
-
clearTimeout(this.tickTimer);
|
|
2390
|
-
}
|
|
2391
|
-
await this.finalPollToEnd();
|
|
2392
|
-
this.printer.stop();
|
|
2393
|
-
}
|
|
2394
|
-
scheduleNextTick() {
|
|
2395
|
-
if (!this.active) {
|
|
2396
|
-
return;
|
|
2397
|
-
}
|
|
2398
|
-
this.tickTimer = setTimeout(() => void this.tick(), this.printer.updateSleep);
|
|
2399
|
-
}
|
|
2400
|
-
async tick() {
|
|
2401
|
-
if (!this.active) {
|
|
2402
|
-
return;
|
|
2403
|
-
}
|
|
2404
|
-
try {
|
|
2405
|
-
this.readPromise = this.readNewEvents();
|
|
2406
|
-
await this.readPromise;
|
|
2407
|
-
this.readPromise = void 0;
|
|
2408
|
-
if (!this.active) {
|
|
2409
|
-
return;
|
|
2797
|
+
if (!isParentStackEvent && event.ResourceType === "AWS::CloudFormation::Stack" && isStackBeginOperationState(event.ResourceStatus)) {
|
|
2798
|
+
this.trackNestedStack(event, [...this.props.parentStackLogicalIds ?? [], event.LogicalResourceId ?? ""]);
|
|
2799
|
+
}
|
|
2800
|
+
if (isParentStackEvent && isStackTerminalState(event.ResourceStatus)) {
|
|
2801
|
+
this.complete = true;
|
|
2802
|
+
}
|
|
2803
|
+
}
|
|
2804
|
+
nextToken = page?.NextToken;
|
|
2805
|
+
if (nextToken === void 0) {
|
|
2806
|
+
finished = true;
|
|
2807
|
+
}
|
|
2410
2808
|
}
|
|
2411
|
-
this.printer.print();
|
|
2412
2809
|
} catch (e) {
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
this.scheduleNextTick();
|
|
2416
|
-
}
|
|
2417
|
-
findMetadataFor(logicalId) {
|
|
2418
|
-
const metadata = this.stack?.manifest?.metadata;
|
|
2419
|
-
if (!logicalId || !metadata) {
|
|
2420
|
-
return void 0;
|
|
2421
|
-
}
|
|
2422
|
-
for (const path12 of Object.keys(metadata)) {
|
|
2423
|
-
const entry = metadata[path12].filter((e) => e.type === import_cloud_assembly_schema.ArtifactMetadataEntryType.LOGICAL_ID).find((e) => e.data === logicalId);
|
|
2424
|
-
if (entry) {
|
|
2425
|
-
return {
|
|
2426
|
-
entry,
|
|
2427
|
-
constructPath: this.simplifyConstructPath(path12)
|
|
2428
|
-
};
|
|
2810
|
+
if (!(e.name === "ValidationError" && formatErrorMessage(e) === `Stack [${this.props.stackName}] does not exist`)) {
|
|
2811
|
+
throw e;
|
|
2429
2812
|
}
|
|
2430
2813
|
}
|
|
2431
|
-
return
|
|
2432
|
-
}
|
|
2433
|
-
/**
|
|
2434
|
-
* Reads all new events from the stack history
|
|
2435
|
-
*
|
|
2436
|
-
* The events are returned in reverse chronological order; we continue to the next page if we
|
|
2437
|
-
* see a next page and the last event in the page is new to us (and within the time window).
|
|
2438
|
-
* haven't seen the final event
|
|
2439
|
-
*/
|
|
2440
|
-
async readNewEvents() {
|
|
2441
|
-
const pollEvents = await this.poller.poll();
|
|
2442
|
-
const activities = pollEvents.map((event) => ({
|
|
2443
|
-
...event,
|
|
2444
|
-
metadata: this.findMetadataFor(event.event.LogicalResourceId)
|
|
2445
|
-
}));
|
|
2446
|
-
for (const activity of activities) {
|
|
2447
|
-
this.checkForErrors(activity);
|
|
2448
|
-
this.printer.addActivity(activity);
|
|
2449
|
-
}
|
|
2814
|
+
return events;
|
|
2450
2815
|
}
|
|
2451
2816
|
/**
|
|
2452
|
-
*
|
|
2453
|
-
*
|
|
2454
|
-
* Finish any poll currently in progress, then do a final one until we've
|
|
2455
|
-
* reached the last page.
|
|
2817
|
+
* On the CREATE_IN_PROGRESS, UPDATE_IN_PROGRESS, DELETE_IN_PROGRESS event of a nested stack, poll the nested stack updates
|
|
2456
2818
|
*/
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
}
|
|
2463
|
-
checkForErrors(activity) {
|
|
2464
|
-
if (hasErrorMessage(activity.event.ResourceStatus ?? "")) {
|
|
2465
|
-
const isCancelled = (activity.event.ResourceStatusReason ?? "").indexOf("cancelled") > -1;
|
|
2466
|
-
if (!isCancelled && activity.event.StackName !== activity.event.LogicalResourceId) {
|
|
2467
|
-
this.errors.push(activity.event.ResourceStatusReason ?? "");
|
|
2468
|
-
}
|
|
2819
|
+
trackNestedStack(event, parentStackLogicalIds) {
|
|
2820
|
+
const logicalId = event.LogicalResourceId;
|
|
2821
|
+
const physicalResourceId = event.PhysicalResourceId;
|
|
2822
|
+
if (!logicalId || !physicalResourceId) {
|
|
2823
|
+
return;
|
|
2469
2824
|
}
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2825
|
+
if (!this.nestedStackPollers[logicalId]) {
|
|
2826
|
+
this.nestedStackPollers[logicalId] = new _StackEventPoller(this.cfn, {
|
|
2827
|
+
stackName: physicalResourceId,
|
|
2828
|
+
parentStackLogicalIds,
|
|
2829
|
+
startTime: event.Timestamp.valueOf()
|
|
2830
|
+
});
|
|
2476
2831
|
}
|
|
2477
|
-
return path12;
|
|
2478
2832
|
}
|
|
2479
2833
|
};
|
|
2480
|
-
function
|
|
2481
|
-
return
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2834
|
+
function isStackBeginOperationState(state) {
|
|
2835
|
+
return [
|
|
2836
|
+
"CREATE_IN_PROGRESS",
|
|
2837
|
+
"UPDATE_IN_PROGRESS",
|
|
2838
|
+
"DELETE_IN_PROGRESS",
|
|
2839
|
+
"UPDATE_ROLLBACK_IN_PROGRESS",
|
|
2840
|
+
"ROLLBACK_IN_PROGRESS"
|
|
2841
|
+
].includes(state ?? "");
|
|
2485
2842
|
}
|
|
2486
|
-
function
|
|
2487
|
-
|
|
2488
|
-
let maxWidth = 0;
|
|
2489
|
-
for (const id of Object.keys(resources)) {
|
|
2490
|
-
const type = resources[id].Type || "";
|
|
2491
|
-
if (type.length > maxWidth) {
|
|
2492
|
-
maxWidth = type.length;
|
|
2493
|
-
}
|
|
2494
|
-
}
|
|
2495
|
-
return maxWidth;
|
|
2843
|
+
function isStackTerminalState(state) {
|
|
2844
|
+
return !(state ?? "").endsWith("_IN_PROGRESS");
|
|
2496
2845
|
}
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
*/
|
|
2503
|
-
this.updateSleep = 5e3;
|
|
2504
|
-
/**
|
|
2505
|
-
* A list of resource IDs which are currently being processed
|
|
2506
|
-
*/
|
|
2507
|
-
this.resourcesInProgress = {};
|
|
2846
|
+
|
|
2847
|
+
// ../../aws-cdk/lib/api/stack-events/stack-progress-monitor.ts
|
|
2848
|
+
var util5 = __toESM(require("util"));
|
|
2849
|
+
var StackProgressMonitor = class {
|
|
2850
|
+
constructor(resourcesTotal) {
|
|
2508
2851
|
/**
|
|
2509
2852
|
* Previous completion state observed by logical ID
|
|
2510
2853
|
*
|
|
@@ -2521,52 +2864,57 @@ var ActivityPrinterBase = class {
|
|
|
2521
2864
|
* How many digits we need to represent the total count (for lining up the status reporting)
|
|
2522
2865
|
*/
|
|
2523
2866
|
this.resourceDigits = 0;
|
|
2524
|
-
this.
|
|
2525
|
-
this.failures = new Array();
|
|
2526
|
-
this.hookFailureMap = /* @__PURE__ */ new Map();
|
|
2527
|
-
this.resourcesTotal = props.resourcesTotal ? props.resourcesTotal + 1 : void 0;
|
|
2867
|
+
this.resourcesTotal = resourcesTotal ? resourcesTotal + 1 : void 0;
|
|
2528
2868
|
this.resourceDigits = this.resourcesTotal ? Math.ceil(Math.log10(this.resourcesTotal)) : 0;
|
|
2529
2869
|
}
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2870
|
+
/**
|
|
2871
|
+
* Report the stack progress
|
|
2872
|
+
*/
|
|
2873
|
+
get progress() {
|
|
2874
|
+
return {
|
|
2875
|
+
total: this.total,
|
|
2876
|
+
completed: this.completed,
|
|
2877
|
+
formatted: this.formatted
|
|
2878
|
+
};
|
|
2879
|
+
}
|
|
2880
|
+
/**
|
|
2881
|
+
* The total number of progress monitored resources.
|
|
2882
|
+
*/
|
|
2883
|
+
get total() {
|
|
2884
|
+
return this.resourcesTotal;
|
|
2885
|
+
}
|
|
2886
|
+
/**
|
|
2887
|
+
* The number of completed resources.
|
|
2888
|
+
*/
|
|
2889
|
+
get completed() {
|
|
2890
|
+
return this.resourcesDone;
|
|
2891
|
+
}
|
|
2892
|
+
/**
|
|
2893
|
+
* Report the current progress as a [34/42] string, or just [34] if the total is unknown
|
|
2894
|
+
*/
|
|
2895
|
+
get formatted() {
|
|
2896
|
+
if (this.resourcesTotal == null) {
|
|
2897
|
+
return padLeft(3, util5.format("%s", this.resourcesDone));
|
|
2540
2898
|
}
|
|
2541
|
-
return
|
|
2899
|
+
return util5.format(
|
|
2900
|
+
"%s/%s",
|
|
2901
|
+
padLeft(this.resourceDigits, this.resourcesDone.toString()),
|
|
2902
|
+
padLeft(this.resourceDigits, this.resourcesTotal.toString())
|
|
2903
|
+
);
|
|
2542
2904
|
}
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2905
|
+
/**
|
|
2906
|
+
* Process as stack event and update the progress state.
|
|
2907
|
+
*/
|
|
2908
|
+
process(event) {
|
|
2909
|
+
const status = event.ResourceStatus;
|
|
2910
|
+
if (!status || !event.LogicalResourceId) {
|
|
2548
2911
|
return;
|
|
2549
2912
|
}
|
|
2550
|
-
if (status === "ROLLBACK_IN_PROGRESS" || status === "UPDATE_ROLLBACK_IN_PROGRESS") {
|
|
2551
|
-
this.rollingBack = true;
|
|
2552
|
-
}
|
|
2553
|
-
if (status.endsWith("_IN_PROGRESS")) {
|
|
2554
|
-
this.resourcesInProgress[activity.event.LogicalResourceId] = activity;
|
|
2555
|
-
}
|
|
2556
|
-
if (hasErrorMessage(status)) {
|
|
2557
|
-
const isCancelled = (activity.event.ResourceStatusReason ?? "").indexOf("cancelled") > -1;
|
|
2558
|
-
if (!isCancelled) {
|
|
2559
|
-
this.failures.push(activity);
|
|
2560
|
-
}
|
|
2561
|
-
}
|
|
2562
|
-
if (status.endsWith("_COMPLETE") || status.endsWith("_FAILED")) {
|
|
2563
|
-
delete this.resourcesInProgress[activity.event.LogicalResourceId];
|
|
2564
|
-
}
|
|
2565
2913
|
if (status.endsWith("_COMPLETE_CLEANUP_IN_PROGRESS")) {
|
|
2566
2914
|
this.resourcesDone++;
|
|
2567
2915
|
}
|
|
2568
2916
|
if (status.endsWith("_COMPLETE")) {
|
|
2569
|
-
const prevState = this.resourcesPrevCompleteState[
|
|
2917
|
+
const prevState = this.resourcesPrevCompleteState[event.LogicalResourceId];
|
|
2570
2918
|
if (!prevState) {
|
|
2571
2919
|
this.resourcesDone++;
|
|
2572
2920
|
} else {
|
|
@@ -2575,265 +2923,175 @@ var ActivityPrinterBase = class {
|
|
|
2575
2923
|
this.resourcesDone = 0;
|
|
2576
2924
|
}
|
|
2577
2925
|
}
|
|
2578
|
-
this.resourcesPrevCompleteState[
|
|
2579
|
-
}
|
|
2580
|
-
if (hookStatus !== void 0 && hookStatus.endsWith("_COMPLETE_FAILED") && activity.event.LogicalResourceId !== void 0 && hookType !== void 0) {
|
|
2581
|
-
if (this.hookFailureMap.has(activity.event.LogicalResourceId)) {
|
|
2582
|
-
this.hookFailureMap.get(activity.event.LogicalResourceId)?.set(hookType, activity.event.HookStatusReason ?? "");
|
|
2583
|
-
} else {
|
|
2584
|
-
this.hookFailureMap.set(activity.event.LogicalResourceId, /* @__PURE__ */ new Map());
|
|
2585
|
-
this.hookFailureMap.get(activity.event.LogicalResourceId)?.set(hookType, activity.event.HookStatusReason ?? "");
|
|
2586
|
-
}
|
|
2926
|
+
this.resourcesPrevCompleteState[event.LogicalResourceId] = status;
|
|
2587
2927
|
}
|
|
2588
2928
|
}
|
|
2589
|
-
start() {
|
|
2590
|
-
}
|
|
2591
|
-
stop() {
|
|
2592
|
-
}
|
|
2593
2929
|
};
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
this.
|
|
2930
|
+
|
|
2931
|
+
// ../../aws-cdk/lib/api/stack-events/stack-activity-monitor.ts
|
|
2932
|
+
var StackActivityMonitor = class {
|
|
2933
|
+
constructor({
|
|
2934
|
+
cfn,
|
|
2935
|
+
ioHost,
|
|
2936
|
+
action,
|
|
2937
|
+
stack,
|
|
2938
|
+
stackName,
|
|
2939
|
+
resourcesTotal,
|
|
2940
|
+
changeSetCreationTime,
|
|
2941
|
+
pollingInterval = 2e3
|
|
2942
|
+
}) {
|
|
2943
|
+
this.errors = [];
|
|
2944
|
+
this.ioHost = ioHost;
|
|
2945
|
+
this.action = action;
|
|
2946
|
+
this.stack = stack;
|
|
2947
|
+
this.stackName = stackName;
|
|
2948
|
+
this.progressMonitor = new StackProgressMonitor(resourcesTotal);
|
|
2949
|
+
this.pollingInterval = pollingInterval;
|
|
2950
|
+
this.poller = new StackEventPoller(cfn, {
|
|
2951
|
+
stackName,
|
|
2952
|
+
startTime: changeSetCreationTime?.getTime() ?? Date.now()
|
|
2953
|
+
});
|
|
2608
2954
|
}
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
this.
|
|
2612
|
-
|
|
2955
|
+
async start() {
|
|
2956
|
+
this.monitorId = uuid.v4();
|
|
2957
|
+
await this.ioHost.notify(debug2(this.action, `Deploying ${this.stackName}`, "CDK_TOOLKIT_I5501", {
|
|
2958
|
+
deployment: this.monitorId,
|
|
2959
|
+
stack: this.stack,
|
|
2960
|
+
stackName: this.stackName,
|
|
2961
|
+
resourcesTotal: this.progressMonitor.total
|
|
2962
|
+
}));
|
|
2963
|
+
this.scheduleNextTick();
|
|
2964
|
+
return this;
|
|
2613
2965
|
}
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2966
|
+
async stop() {
|
|
2967
|
+
const oldMonitorId = this.monitorId;
|
|
2968
|
+
this.monitorId = void 0;
|
|
2969
|
+
if (this.tickTimer) {
|
|
2970
|
+
clearTimeout(this.tickTimer);
|
|
2617
2971
|
}
|
|
2618
|
-
this.
|
|
2619
|
-
this.
|
|
2972
|
+
await this.finalPollToEnd(oldMonitorId);
|
|
2973
|
+
await this.ioHost.notify(debug2(this.action, `Completed ${this.stackName}`, "CDK_TOOLKIT_I5503", {
|
|
2974
|
+
deployment: oldMonitorId,
|
|
2975
|
+
stack: this.stack,
|
|
2976
|
+
stackName: this.stackName,
|
|
2977
|
+
resourcesTotal: this.progressMonitor.total
|
|
2978
|
+
}));
|
|
2620
2979
|
}
|
|
2621
|
-
|
|
2622
|
-
if (this.
|
|
2623
|
-
|
|
2624
|
-
for (const failure of this.failures) {
|
|
2625
|
-
if (failure.isStackEvent) {
|
|
2626
|
-
continue;
|
|
2627
|
-
}
|
|
2628
|
-
this.printOne(failure, false);
|
|
2629
|
-
}
|
|
2980
|
+
scheduleNextTick() {
|
|
2981
|
+
if (!this.monitorId) {
|
|
2982
|
+
return;
|
|
2630
2983
|
}
|
|
2984
|
+
this.tickTimer = setTimeout(() => void this.tick(), this.pollingInterval);
|
|
2631
2985
|
}
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2986
|
+
async tick() {
|
|
2987
|
+
if (!this.monitorId) {
|
|
2988
|
+
return;
|
|
2989
|
+
}
|
|
2990
|
+
try {
|
|
2991
|
+
this.readPromise = this.readNewEvents(this.monitorId);
|
|
2992
|
+
await this.readPromise;
|
|
2993
|
+
this.readPromise = void 0;
|
|
2994
|
+
if (!this.monitorId) {
|
|
2995
|
+
return;
|
|
2641
2996
|
}
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2997
|
+
} catch (e) {
|
|
2998
|
+
await this.ioHost.notify(error2(
|
|
2999
|
+
this.action,
|
|
3000
|
+
util6.format("Error occurred while monitoring stack: %s", e),
|
|
3001
|
+
"CDK_TOOLKIT_E5500",
|
|
3002
|
+
{ error: e }
|
|
3003
|
+
));
|
|
3004
|
+
}
|
|
3005
|
+
this.scheduleNextTick();
|
|
3006
|
+
}
|
|
3007
|
+
findMetadataFor(logicalId) {
|
|
3008
|
+
const metadata = this.stack.manifest?.metadata;
|
|
3009
|
+
if (!logicalId || !metadata) {
|
|
3010
|
+
return void 0;
|
|
3011
|
+
}
|
|
3012
|
+
for (const path15 of Object.keys(metadata)) {
|
|
3013
|
+
const entry = metadata[path15].filter((e) => e.type === import_cloud_assembly_schema.ArtifactMetadataEntryType.LOGICAL_ID).find((e) => e.data === logicalId);
|
|
3014
|
+
if (entry) {
|
|
3015
|
+
return {
|
|
3016
|
+
entry,
|
|
3017
|
+
constructPath: this.simplifyConstructPath(path15)
|
|
3018
|
+
};
|
|
2645
3019
|
}
|
|
2646
|
-
reasonColor = chalk4.red;
|
|
2647
3020
|
}
|
|
2648
|
-
|
|
2649
|
-
const logicalId = resourceName !== event.LogicalResourceId ? `(${event.LogicalResourceId}) ` : "";
|
|
2650
|
-
info(
|
|
2651
|
-
util3.format(
|
|
2652
|
-
"%s | %s%s | %s | %s | %s %s%s%s",
|
|
2653
|
-
event.StackName,
|
|
2654
|
-
progress !== false ? `${this.progress()} | ` : "",
|
|
2655
|
-
new Date(event.Timestamp).toLocaleTimeString(),
|
|
2656
|
-
color(padRight(STATUS_WIDTH, (event.ResourceStatus || "").slice(0, STATUS_WIDTH))),
|
|
2657
|
-
// pad left and trim
|
|
2658
|
-
padRight(this.props.resourceTypeColumnWidth, event.ResourceType || ""),
|
|
2659
|
-
color(chalk4.bold(resourceName)),
|
|
2660
|
-
logicalId,
|
|
2661
|
-
reasonColor(chalk4.bold(event.ResourceStatusReason ? event.ResourceStatusReason : "")),
|
|
2662
|
-
reasonColor(stackTrace)
|
|
2663
|
-
)
|
|
2664
|
-
);
|
|
2665
|
-
this.lastPrintTime = Date.now();
|
|
3021
|
+
return void 0;
|
|
2666
3022
|
}
|
|
2667
3023
|
/**
|
|
2668
|
-
*
|
|
3024
|
+
* Reads all new events from the stack history
|
|
3025
|
+
*
|
|
3026
|
+
* The events are returned in reverse chronological order; we continue to the next page if we
|
|
3027
|
+
* see a next page and the last event in the page is new to us (and within the time window).
|
|
3028
|
+
* haven't seen the final event
|
|
2669
3029
|
*/
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
3030
|
+
async readNewEvents(monitorId) {
|
|
3031
|
+
const pollEvents = await this.poller.poll();
|
|
3032
|
+
for (const resourceEvent of pollEvents) {
|
|
3033
|
+
this.progressMonitor.process(resourceEvent.event);
|
|
3034
|
+
const activity = {
|
|
3035
|
+
deployment: monitorId,
|
|
3036
|
+
event: resourceEvent.event,
|
|
3037
|
+
metadata: this.findMetadataFor(resourceEvent.event.LogicalResourceId),
|
|
3038
|
+
progress: this.progressMonitor.progress
|
|
3039
|
+
};
|
|
3040
|
+
this.checkForErrors(activity);
|
|
3041
|
+
await this.ioHost.notify(info2(this.action, this.formatActivity(activity, true), "CDK_TOOLKIT_I5502", activity));
|
|
2673
3042
|
}
|
|
2674
|
-
return util3.format(
|
|
2675
|
-
"%s/%s",
|
|
2676
|
-
padLeft(this.resourceDigits, this.resourcesDone.toString()),
|
|
2677
|
-
padLeft(this.resourceDigits, this.resourcesTotal != null ? this.resourcesTotal.toString() : "?")
|
|
2678
|
-
);
|
|
2679
3043
|
}
|
|
2680
3044
|
/**
|
|
2681
|
-
*
|
|
3045
|
+
* Perform a final poll to the end and flush out all events to the printer
|
|
3046
|
+
*
|
|
3047
|
+
* Finish any poll currently in progress, then do a final one until we've
|
|
3048
|
+
* reached the last page.
|
|
2682
3049
|
*/
|
|
2683
|
-
|
|
2684
|
-
if (
|
|
2685
|
-
|
|
2686
|
-
}
|
|
2687
|
-
if (Object.keys(this.resourcesInProgress).length > 0) {
|
|
2688
|
-
info(
|
|
2689
|
-
util3.format(
|
|
2690
|
-
"%s Currently in progress: %s",
|
|
2691
|
-
this.progress(),
|
|
2692
|
-
chalk4.bold(Object.keys(this.resourcesInProgress).join(", "))
|
|
2693
|
-
)
|
|
2694
|
-
);
|
|
3050
|
+
async finalPollToEnd(monitorId) {
|
|
3051
|
+
if (this.readPromise) {
|
|
3052
|
+
await this.readPromise;
|
|
2695
3053
|
}
|
|
2696
|
-
this.
|
|
2697
|
-
}
|
|
2698
|
-
};
|
|
2699
|
-
var CurrentActivityPrinter = class extends ActivityPrinterBase {
|
|
2700
|
-
constructor(props) {
|
|
2701
|
-
super(props);
|
|
2702
|
-
/**
|
|
2703
|
-
* This looks very disorienting sleeping for 5 seconds. Update quicker.
|
|
2704
|
-
*/
|
|
2705
|
-
this.updateSleep = 2e3;
|
|
2706
|
-
this.oldLogThreshold = CliIoHost.instance().logLevel;
|
|
2707
|
-
this.stream = props.stream;
|
|
2708
|
-
this.block = new RewritableBlock(this.stream);
|
|
3054
|
+
await this.readNewEvents(monitorId);
|
|
2709
3055
|
}
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
const
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
padRight(this.props.resourceTypeColumnWidth, res.event.ResourceType || ""),
|
|
2731
|
-
color(chalk4.bold(shorten(40, resourceName))),
|
|
2732
|
-
this.failureReasonOnNextLine(res)
|
|
2733
|
-
);
|
|
2734
|
-
})
|
|
3056
|
+
/**
|
|
3057
|
+
* Formats a stack activity into a basic string
|
|
3058
|
+
*/
|
|
3059
|
+
formatActivity(activity, progress) {
|
|
3060
|
+
const event = activity.event;
|
|
3061
|
+
const metadata = activity.metadata;
|
|
3062
|
+
const resourceName = metadata ? metadata.constructPath : event.LogicalResourceId || "";
|
|
3063
|
+
const logicalId = resourceName !== event.LogicalResourceId ? `(${event.LogicalResourceId}) ` : "";
|
|
3064
|
+
return util6.format(
|
|
3065
|
+
"%s | %s%s | %s | %s | %s %s%s%s",
|
|
3066
|
+
event.StackName,
|
|
3067
|
+
progress !== false ? `${activity.progress.formatted} | ` : "",
|
|
3068
|
+
new Date(event.Timestamp).toLocaleTimeString(),
|
|
3069
|
+
event.ResourceStatus || "",
|
|
3070
|
+
event.ResourceType,
|
|
3071
|
+
resourceName,
|
|
3072
|
+
logicalId,
|
|
3073
|
+
event.ResourceStatusReason ? event.ResourceStatusReason : "",
|
|
3074
|
+
metadata?.entry.trace ? `
|
|
3075
|
+
${metadata.entry.trace.join("\n \\_ ")}` : ""
|
|
2735
3076
|
);
|
|
2736
|
-
this.block.displayLines(lines);
|
|
2737
3077
|
}
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
CliIoHost.instance().logLevel = this.oldLogThreshold;
|
|
2744
|
-
const lines = new Array();
|
|
2745
|
-
for (const failure of this.failures) {
|
|
2746
|
-
if (failure.isStackEvent) {
|
|
2747
|
-
continue;
|
|
2748
|
-
}
|
|
2749
|
-
lines.push(
|
|
2750
|
-
util3.format(
|
|
2751
|
-
chalk4.red("%s | %s | %s | %s%s") + "\n",
|
|
2752
|
-
padLeft(TIMESTAMP_WIDTH, new Date(failure.event.Timestamp).toLocaleTimeString()),
|
|
2753
|
-
padRight(STATUS_WIDTH, (failure.event.ResourceStatus || "").slice(0, STATUS_WIDTH)),
|
|
2754
|
-
padRight(this.props.resourceTypeColumnWidth, failure.event.ResourceType || ""),
|
|
2755
|
-
shorten(40, failure.event.LogicalResourceId ?? ""),
|
|
2756
|
-
this.failureReasonOnNextLine(failure)
|
|
2757
|
-
)
|
|
2758
|
-
);
|
|
2759
|
-
const trace3 = failure.metadata?.entry?.trace;
|
|
2760
|
-
if (trace3) {
|
|
2761
|
-
lines.push(chalk4.red(` ${trace3.join("\n \\_ ")}
|
|
2762
|
-
`));
|
|
3078
|
+
checkForErrors(activity) {
|
|
3079
|
+
if (stackEventHasErrorMessage(activity.event.ResourceStatus ?? "")) {
|
|
3080
|
+
const isCancelled = (activity.event.ResourceStatusReason ?? "").indexOf("cancelled") > -1;
|
|
3081
|
+
if (!isCancelled && activity.event.StackName !== activity.event.LogicalResourceId) {
|
|
3082
|
+
this.errors.push(activity.event.ResourceStatusReason ?? "");
|
|
2763
3083
|
}
|
|
2764
3084
|
}
|
|
2765
|
-
this.block.displayLines(lines);
|
|
2766
|
-
this.block.removeEmptyLines();
|
|
2767
3085
|
}
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
3086
|
+
simplifyConstructPath(path15) {
|
|
3087
|
+
path15 = path15.replace(/\/Resource$/, "");
|
|
3088
|
+
path15 = path15.replace(/^\//, "");
|
|
3089
|
+
if (path15.startsWith(this.stackName + "/")) {
|
|
3090
|
+
path15 = path15.slice(this.stackName.length + 1);
|
|
2771
3091
|
}
|
|
2772
|
-
|
|
2773
|
-
const innerWidth = Math.max(1, width - 2);
|
|
2774
|
-
const chars = innerWidth * fraction;
|
|
2775
|
-
const remainder = chars - Math.floor(chars);
|
|
2776
|
-
const fullChars = FULL_BLOCK.repeat(Math.floor(chars));
|
|
2777
|
-
const partialChar = PARTIAL_BLOCK[Math.floor(remainder * PARTIAL_BLOCK.length)];
|
|
2778
|
-
const filler = "\xB7".repeat(innerWidth - Math.floor(chars) - (partialChar ? 1 : 0));
|
|
2779
|
-
const color = this.rollingBack ? chalk4.yellow : chalk4.green;
|
|
2780
|
-
return "[" + color(fullChars + partialChar) + filler + `] (${this.resourcesDone}/${this.resourcesTotal})`;
|
|
2781
|
-
}
|
|
2782
|
-
failureReasonOnNextLine(activity) {
|
|
2783
|
-
return hasErrorMessage(activity.event.ResourceStatus ?? "") ? `
|
|
2784
|
-
${" ".repeat(TIMESTAMP_WIDTH + STATUS_WIDTH + 6)}${chalk4.red(this.failureReason(activity) ?? "")}` : "";
|
|
3092
|
+
return path15;
|
|
2785
3093
|
}
|
|
2786
3094
|
};
|
|
2787
|
-
var FULL_BLOCK = "\u2588";
|
|
2788
|
-
var PARTIAL_BLOCK = ["", "\u258F", "\u258E", "\u258D", "\u258C", "\u258B", "\u258A", "\u2589"];
|
|
2789
|
-
var MAX_PROGRESSBAR_WIDTH = 60;
|
|
2790
|
-
var MIN_PROGRESSBAR_WIDTH = 10;
|
|
2791
|
-
var PROGRESSBAR_EXTRA_SPACE = 2 + 2 + 4 + 6;
|
|
2792
|
-
function hasErrorMessage(status) {
|
|
2793
|
-
return status.endsWith("_FAILED") || status === "ROLLBACK_IN_PROGRESS" || status === "UPDATE_ROLLBACK_IN_PROGRESS";
|
|
2794
|
-
}
|
|
2795
|
-
function colorFromStatusResult(status) {
|
|
2796
|
-
if (!status) {
|
|
2797
|
-
return chalk4.reset;
|
|
2798
|
-
}
|
|
2799
|
-
if (status.indexOf("FAILED") !== -1) {
|
|
2800
|
-
return chalk4.red;
|
|
2801
|
-
}
|
|
2802
|
-
if (status.indexOf("ROLLBACK") !== -1) {
|
|
2803
|
-
return chalk4.yellow;
|
|
2804
|
-
}
|
|
2805
|
-
if (status.indexOf("COMPLETE") !== -1) {
|
|
2806
|
-
return chalk4.green;
|
|
2807
|
-
}
|
|
2808
|
-
return chalk4.reset;
|
|
2809
|
-
}
|
|
2810
|
-
function colorFromStatusActivity(status) {
|
|
2811
|
-
if (!status) {
|
|
2812
|
-
return chalk4.reset;
|
|
2813
|
-
}
|
|
2814
|
-
if (status.endsWith("_FAILED")) {
|
|
2815
|
-
return chalk4.red;
|
|
2816
|
-
}
|
|
2817
|
-
if (status.startsWith("CREATE_") || status.startsWith("UPDATE_") || status.startsWith("IMPORT_")) {
|
|
2818
|
-
return chalk4.green;
|
|
2819
|
-
}
|
|
2820
|
-
if (status.indexOf("ROLLBACK_") !== -1) {
|
|
2821
|
-
return chalk4.yellow;
|
|
2822
|
-
}
|
|
2823
|
-
if (status.startsWith("DELETE_")) {
|
|
2824
|
-
return chalk4.yellow;
|
|
2825
|
-
}
|
|
2826
|
-
return chalk4.reset;
|
|
2827
|
-
}
|
|
2828
|
-
function shorten(maxWidth, p) {
|
|
2829
|
-
if (p.length <= maxWidth) {
|
|
2830
|
-
return p;
|
|
2831
|
-
}
|
|
2832
|
-
const half = Math.floor((maxWidth - 3) / 2);
|
|
2833
|
-
return p.slice(0, half) + "..." + p.slice(-half);
|
|
2834
|
-
}
|
|
2835
|
-
var TIMESTAMP_WIDTH = 12;
|
|
2836
|
-
var STATUS_WIDTH = 20;
|
|
2837
3095
|
|
|
2838
3096
|
// ../../aws-cdk/lib/api/stack-events/stack-status.ts
|
|
2839
3097
|
var import_client_cloudformation2 = require("@aws-sdk/client-cloudformation");
|
|
@@ -2900,47 +3158,8 @@ var path4 = __toESM(require("path"));
|
|
|
2900
3158
|
var import_cx_api2 = require("@aws-cdk/cx-api");
|
|
2901
3159
|
var import_client_s32 = require("@aws-sdk/client-s3");
|
|
2902
3160
|
var import_middleware_endpoint2 = require("@smithy/middleware-endpoint");
|
|
2903
|
-
var
|
|
3161
|
+
var chalk6 = __toESM(require("chalk"));
|
|
2904
3162
|
var fs6 = __toESM(require("fs-extra"));
|
|
2905
|
-
|
|
2906
|
-
// ../../aws-cdk/lib/util/content-hash.ts
|
|
2907
|
-
var crypto = __toESM(require("crypto"));
|
|
2908
|
-
function contentHash(data) {
|
|
2909
|
-
return crypto.createHash("sha256").update(data).digest("hex");
|
|
2910
|
-
}
|
|
2911
|
-
function contentHashAny(value) {
|
|
2912
|
-
const ret = crypto.createHash("sha256");
|
|
2913
|
-
recurse(value);
|
|
2914
|
-
return ret.digest("hex");
|
|
2915
|
-
function recurse(x) {
|
|
2916
|
-
if (typeof x === "string") {
|
|
2917
|
-
ret.update(x);
|
|
2918
|
-
return;
|
|
2919
|
-
}
|
|
2920
|
-
if (Array.isArray(x)) {
|
|
2921
|
-
ret.update("[");
|
|
2922
|
-
for (const e of x) {
|
|
2923
|
-
recurse(e);
|
|
2924
|
-
ret.update("||");
|
|
2925
|
-
}
|
|
2926
|
-
ret.update("]");
|
|
2927
|
-
return;
|
|
2928
|
-
}
|
|
2929
|
-
if (x && typeof x === "object") {
|
|
2930
|
-
ret.update("{");
|
|
2931
|
-
for (const key of Object.keys(x).sort()) {
|
|
2932
|
-
ret.update(key);
|
|
2933
|
-
ret.update(":");
|
|
2934
|
-
recurse(x[key]);
|
|
2935
|
-
}
|
|
2936
|
-
ret.update("}");
|
|
2937
|
-
return;
|
|
2938
|
-
}
|
|
2939
|
-
ret.update(`${x}${typeof x}`);
|
|
2940
|
-
}
|
|
2941
|
-
}
|
|
2942
|
-
|
|
2943
|
-
// ../../aws-cdk/lib/api/util/template-body-parameter.ts
|
|
2944
3163
|
var LARGE_TEMPLATE_SIZE_KB = 50;
|
|
2945
3164
|
async function makeBodyParameter(stack, resolvedEnvironment, assetManifest, resources, overrideTemplate) {
|
|
2946
3165
|
if (stack.stackTemplateAssetObjectUrl && !overrideTemplate) {
|
|
@@ -2959,7 +3178,7 @@ async function makeBodyParameter(stack, resolvedEnvironment, assetManifest, reso
|
|
|
2959
3178
|
Run the following command in order to setup an S3 bucket in this environment, and then re-deploy:
|
|
2960
3179
|
|
|
2961
3180
|
`,
|
|
2962
|
-
|
|
3181
|
+
chalk6.blue(` $ cdk bootstrap ${resolvedEnvironment.name}
|
|
2963
3182
|
`)
|
|
2964
3183
|
);
|
|
2965
3184
|
throw new ToolkitError('Template too large to deploy ("cdk bootstrap" is required)');
|
|
@@ -3185,13 +3404,13 @@ async function waitFor(valueProvider, timeout = 5e3) {
|
|
|
3185
3404
|
}
|
|
3186
3405
|
}
|
|
3187
3406
|
async function waitForChangeSet(cfn, { ioHost, action }, stackName, changeSetName, { fetchAll }) {
|
|
3188
|
-
await ioHost.notify(debug2(action, (0,
|
|
3407
|
+
await ioHost.notify(debug2(action, (0, import_util19.format)("Waiting for changeset %s on stack %s to finish creating...", changeSetName, stackName)));
|
|
3189
3408
|
const ret = await waitFor(async () => {
|
|
3190
3409
|
const description = await describeChangeSet(cfn, stackName, changeSetName, {
|
|
3191
3410
|
fetchAll
|
|
3192
3411
|
});
|
|
3193
3412
|
if (description.Status === "CREATE_PENDING" || description.Status === "CREATE_IN_PROGRESS") {
|
|
3194
|
-
await ioHost.notify(debug2(action, (0,
|
|
3413
|
+
await ioHost.notify(debug2(action, (0, import_util19.format)("Changeset %s on stack %s is still creating", changeSetName, stackName)));
|
|
3195
3414
|
return void 0;
|
|
3196
3415
|
}
|
|
3197
3416
|
if (description.Status === import_client_cloudformation3.ChangeSetStatus.CREATE_COMPLETE || changeSetHasNoChanges(description)) {
|
|
@@ -3276,19 +3495,19 @@ async function waitForStackDeploy(cfn, { ioHost, action }, stackName) {
|
|
|
3276
3495
|
return stack;
|
|
3277
3496
|
}
|
|
3278
3497
|
async function stabilizeStack(cfn, { ioHost, action }, stackName) {
|
|
3279
|
-
await ioHost.notify(debug2(action, (0,
|
|
3498
|
+
await ioHost.notify(debug2(action, (0, import_util19.format)("Waiting for stack %s to finish creating or updating...", stackName)));
|
|
3280
3499
|
return waitFor(async () => {
|
|
3281
3500
|
const stack = await CloudFormationStack.lookup(cfn, stackName);
|
|
3282
3501
|
if (!stack.exists) {
|
|
3283
|
-
await ioHost.notify(debug2(action, (0,
|
|
3502
|
+
await ioHost.notify(debug2(action, (0, import_util19.format)("Stack %s does not exist", stackName)));
|
|
3284
3503
|
return null;
|
|
3285
3504
|
}
|
|
3286
3505
|
const status = stack.stackStatus;
|
|
3287
3506
|
if (status.isInProgress) {
|
|
3288
|
-
await ioHost.notify(debug2(action, (0,
|
|
3507
|
+
await ioHost.notify(debug2(action, (0, import_util19.format)("Stack %s has an ongoing operation in progress and is not stable (%s)", stackName, status)));
|
|
3289
3508
|
return void 0;
|
|
3290
3509
|
} else if (status.isReviewInProgress) {
|
|
3291
|
-
await ioHost.notify(debug2(action, (0,
|
|
3510
|
+
await ioHost.notify(debug2(action, (0, import_util19.format)("Stack %s is in REVIEW_IN_PROGRESS state. Considering this is a stable status (%s)", stackName, status)));
|
|
3292
3511
|
}
|
|
3293
3512
|
return stack;
|
|
3294
3513
|
});
|
|
@@ -3380,7 +3599,7 @@ var ParameterValues = class {
|
|
|
3380
3599
|
// ../../aws-cdk/lib/api/deployments/deployments.ts
|
|
3381
3600
|
var import_crypto = require("crypto");
|
|
3382
3601
|
var cdk_assets = __toESM(require("cdk-assets"));
|
|
3383
|
-
var
|
|
3602
|
+
var chalk12 = __toESM(require("chalk"));
|
|
3384
3603
|
|
|
3385
3604
|
// ../../aws-cdk/lib/api/deployments/asset-publishing.ts
|
|
3386
3605
|
var import_cx_api4 = require("@aws-cdk/cx-api");
|
|
@@ -3557,15 +3776,15 @@ async function getBootstrapStackInfo(sdk, stackName) {
|
|
|
3557
3776
|
}
|
|
3558
3777
|
|
|
3559
3778
|
// ../../aws-cdk/lib/api/deployments/deploy-stack.ts
|
|
3560
|
-
var
|
|
3561
|
-
var
|
|
3562
|
-
var
|
|
3779
|
+
var import_util25 = require("util");
|
|
3780
|
+
var chalk9 = __toESM(require("chalk"));
|
|
3781
|
+
var uuid2 = __toESM(require("uuid"));
|
|
3563
3782
|
|
|
3564
3783
|
// ../../aws-cdk/lib/api/deployments/assets.ts
|
|
3565
3784
|
var path5 = __toESM(require("path"));
|
|
3566
3785
|
var cxschema2 = __toESM(require("@aws-cdk/cloud-assembly-schema"));
|
|
3567
3786
|
var cxapi2 = __toESM(require("@aws-cdk/cx-api"));
|
|
3568
|
-
var
|
|
3787
|
+
var chalk7 = __toESM(require("chalk"));
|
|
3569
3788
|
async function addMetadataAssetsToManifest({ ioHost, action }, stack, assetManifest, envResources, reuse) {
|
|
3570
3789
|
reuse = reuse || [];
|
|
3571
3790
|
const assets = stack.assets;
|
|
@@ -3574,7 +3793,7 @@ async function addMetadataAssetsToManifest({ ioHost, action }, stack, assetManif
|
|
|
3574
3793
|
}
|
|
3575
3794
|
const toolkitInfo = await envResources.lookupToolkit();
|
|
3576
3795
|
if (!toolkitInfo.found) {
|
|
3577
|
-
throw new ToolkitError(`This stack uses assets, so the toolkit stack must be deployed to the environment (Run "${
|
|
3796
|
+
throw new ToolkitError(`This stack uses assets, so the toolkit stack must be deployed to the environment (Run "${chalk7.blue("cdk bootstrap " + stack.environment.name)}")`);
|
|
3578
3797
|
}
|
|
3579
3798
|
const params = {};
|
|
3580
3799
|
for (const asset of assets) {
|
|
@@ -3655,9 +3874,9 @@ async function prepareDockerImageAsset(asset, assetManifest, envResources) {
|
|
|
3655
3874
|
}
|
|
3656
3875
|
|
|
3657
3876
|
// ../../aws-cdk/lib/api/deployments/hotswap-deployments.ts
|
|
3658
|
-
var
|
|
3877
|
+
var import_util23 = require("util");
|
|
3659
3878
|
var cfn_diff = __toESM(require("@aws-cdk/cloudformation-diff"));
|
|
3660
|
-
var
|
|
3879
|
+
var chalk8 = __toESM(require("chalk"));
|
|
3661
3880
|
|
|
3662
3881
|
// ../../aws-cdk/lib/api/deployments/nested-stack-helpers.ts
|
|
3663
3882
|
var path6 = __toESM(require("path"));
|
|
@@ -4548,101 +4767,30 @@ async function prepareTaskDefinitionChange(evaluateCfnTemplate, logicalId, chang
|
|
|
4548
4767
|
const familyNameOrArn = await evaluateCfnTemplate.establishResourcePhysicalName(
|
|
4549
4768
|
logicalId,
|
|
4550
4769
|
taskDefinitionResource?.Family
|
|
4551
|
-
);
|
|
4552
|
-
if (!familyNameOrArn) {
|
|
4553
|
-
return;
|
|
4554
|
-
}
|
|
4555
|
-
const familyNameOrArnParts = familyNameOrArn.split(":");
|
|
4556
|
-
const family = familyNameOrArnParts.length > 1 ? (
|
|
4557
|
-
// familyNameOrArn is actually an ARN, of the format 'arn:aws:ecs:region:account:task-definition/<family-name>:<revision-nr>'
|
|
4558
|
-
// so, take the 6th element, at index 5, and split it on '/'
|
|
4559
|
-
familyNameOrArnParts[5].split("/")[1]
|
|
4560
|
-
) : (
|
|
4561
|
-
// otherwise, familyNameOrArn is just the simple name evaluated from the CloudFormation template
|
|
4562
|
-
familyNameOrArn
|
|
4563
|
-
);
|
|
4564
|
-
return {
|
|
4565
|
-
...await evaluateCfnTemplate.evaluateCfnExpression({
|
|
4566
|
-
...taskDefinitionResource ?? {},
|
|
4567
|
-
Family: void 0
|
|
4568
|
-
}),
|
|
4569
|
-
Family: family
|
|
4570
|
-
};
|
|
4571
|
-
}
|
|
4572
|
-
|
|
4573
|
-
// ../../aws-cdk/lib/api/hotswap/lambda-functions.ts
|
|
4574
|
-
var import_stream = require("stream");
|
|
4575
|
-
|
|
4576
|
-
// ../../aws-cdk/lib/util/archive.ts
|
|
4577
|
-
var glob = __toESM(require("glob"));
|
|
4578
|
-
var archiver = require("archiver");
|
|
4579
|
-
|
|
4580
|
-
// ../../aws-cdk/lib/util/arrays.ts
|
|
4581
|
-
function flatMap(xs, fn) {
|
|
4582
|
-
return flatten(xs.map(fn));
|
|
4583
|
-
}
|
|
4584
|
-
function flatten(xs) {
|
|
4585
|
-
return Array.prototype.concat.apply([], xs);
|
|
4586
|
-
}
|
|
4587
|
-
|
|
4588
|
-
// ../../aws-cdk/lib/util/cloudformation.ts
|
|
4589
|
-
function validateSnsTopicArn(arn) {
|
|
4590
|
-
return /^arn:aws:sns:[a-z0-9\-]+:[0-9]+:[a-z0-9\-\_]+$/i.test(arn);
|
|
4591
|
-
}
|
|
4592
|
-
|
|
4593
|
-
// ../../aws-cdk/lib/util/parallel.ts
|
|
4594
|
-
async function parallelPromises(n, promises) {
|
|
4595
|
-
const ret = new Array();
|
|
4596
|
-
let count = 0;
|
|
4597
|
-
let error3;
|
|
4598
|
-
const queue = [...promises];
|
|
4599
|
-
return new Promise((ok, ko) => {
|
|
4600
|
-
tick();
|
|
4601
|
-
function tick() {
|
|
4602
|
-
if (count === 0 && error3) {
|
|
4603
|
-
ko(error3);
|
|
4604
|
-
return;
|
|
4605
|
-
}
|
|
4606
|
-
if (count === 0 && queue.length === 0) {
|
|
4607
|
-
ok(ret);
|
|
4608
|
-
return;
|
|
4609
|
-
}
|
|
4610
|
-
while (count < n && queue.length > 0 && !error3) {
|
|
4611
|
-
const next = queue.shift();
|
|
4612
|
-
if (next !== void 0) {
|
|
4613
|
-
start(next);
|
|
4614
|
-
}
|
|
4615
|
-
}
|
|
4616
|
-
}
|
|
4617
|
-
function start(fn) {
|
|
4618
|
-
count += 1;
|
|
4619
|
-
fn().then((result) => {
|
|
4620
|
-
ret.push(result);
|
|
4621
|
-
}).catch((e) => {
|
|
4622
|
-
error3 = e;
|
|
4623
|
-
}).finally(() => {
|
|
4624
|
-
count -= 1;
|
|
4625
|
-
tick();
|
|
4626
|
-
});
|
|
4627
|
-
}
|
|
4628
|
-
});
|
|
4629
|
-
}
|
|
4630
|
-
|
|
4631
|
-
// ../../aws-cdk/lib/util/string-manipulation.ts
|
|
4632
|
-
function formatTime(num) {
|
|
4633
|
-
return roundPercentage(millisecondsToSeconds(num));
|
|
4634
|
-
}
|
|
4635
|
-
function roundPercentage(num) {
|
|
4636
|
-
return Math.round(100 * num) / 100;
|
|
4637
|
-
}
|
|
4638
|
-
function millisecondsToSeconds(num) {
|
|
4639
|
-
return num / 1e3;
|
|
4770
|
+
);
|
|
4771
|
+
if (!familyNameOrArn) {
|
|
4772
|
+
return;
|
|
4773
|
+
}
|
|
4774
|
+
const familyNameOrArnParts = familyNameOrArn.split(":");
|
|
4775
|
+
const family = familyNameOrArnParts.length > 1 ? (
|
|
4776
|
+
// familyNameOrArn is actually an ARN, of the format 'arn:aws:ecs:region:account:task-definition/<family-name>:<revision-nr>'
|
|
4777
|
+
// so, take the 6th element, at index 5, and split it on '/'
|
|
4778
|
+
familyNameOrArnParts[5].split("/")[1]
|
|
4779
|
+
) : (
|
|
4780
|
+
// otherwise, familyNameOrArn is just the simple name evaluated from the CloudFormation template
|
|
4781
|
+
familyNameOrArn
|
|
4782
|
+
);
|
|
4783
|
+
return {
|
|
4784
|
+
...await evaluateCfnTemplate.evaluateCfnExpression({
|
|
4785
|
+
...taskDefinitionResource ?? {},
|
|
4786
|
+
Family: void 0
|
|
4787
|
+
}),
|
|
4788
|
+
Family: family
|
|
4789
|
+
};
|
|
4640
4790
|
}
|
|
4641
4791
|
|
|
4642
|
-
// ../../aws-cdk/lib/util/version-range.ts
|
|
4643
|
-
var semver = __toESM(require("semver"));
|
|
4644
|
-
|
|
4645
4792
|
// ../../aws-cdk/lib/api/hotswap/lambda-functions.ts
|
|
4793
|
+
var import_stream = require("stream");
|
|
4646
4794
|
var archiver2 = require("archiver");
|
|
4647
4795
|
async function isHotswappableLambdaFunctionChange(logicalId, change, evaluateCfnTemplate) {
|
|
4648
4796
|
if (change.newValue.Type === "AWS::Lambda::Version") {
|
|
@@ -5263,7 +5411,7 @@ async function applyHotswappableChange(sdk, { ioHost, action }, hotswapOperation
|
|
|
5263
5411
|
const customUserAgent = `cdk-hotswap/success-${hotswapOperation.service}`;
|
|
5264
5412
|
sdk.appendCustomUserAgent(customUserAgent);
|
|
5265
5413
|
for (const name of hotswapOperation.resourceNames) {
|
|
5266
|
-
await ioHost.notify(info2(action, (0,
|
|
5414
|
+
await ioHost.notify(info2(action, (0, import_util23.format)(` ${ICON} %s`, chalk8.bold(name))));
|
|
5267
5415
|
}
|
|
5268
5416
|
try {
|
|
5269
5417
|
await hotswapOperation.apply(sdk);
|
|
@@ -5277,7 +5425,7 @@ async function applyHotswappableChange(sdk, { ioHost, action }, hotswapOperation
|
|
|
5277
5425
|
throw e;
|
|
5278
5426
|
}
|
|
5279
5427
|
for (const name of hotswapOperation.resourceNames) {
|
|
5280
|
-
await ioHost.notify(info2(action, (0,
|
|
5428
|
+
await ioHost.notify(info2(action, (0, import_util23.format)(`${ICON} %s %s`, chalk8.bold(name), chalk8.green("hotswapped!"))));
|
|
5281
5429
|
}
|
|
5282
5430
|
sdk.removeCustomUserAgent(customUserAgent);
|
|
5283
5431
|
}
|
|
@@ -5305,25 +5453,25 @@ async function logNonHotswappableChanges({ ioHost, action }, nonHotswappableChan
|
|
|
5305
5453
|
}
|
|
5306
5454
|
const messages = [""];
|
|
5307
5455
|
if (hotswapMode === "hotswap-only" /* HOTSWAP_ONLY */) {
|
|
5308
|
-
messages.push((0,
|
|
5456
|
+
messages.push((0, import_util23.format)("%s %s", chalk8.red("\u26A0\uFE0F"), chalk8.red("The following non-hotswappable changes were found. To reconcile these using CloudFormation, specify --hotswap-fallback")));
|
|
5309
5457
|
} else {
|
|
5310
|
-
messages.push((0,
|
|
5458
|
+
messages.push((0, import_util23.format)("%s %s", chalk8.red("\u26A0\uFE0F"), chalk8.red("The following non-hotswappable changes were found:")));
|
|
5311
5459
|
}
|
|
5312
5460
|
for (const change of nonHotswappableChanges) {
|
|
5313
5461
|
if (change.rejectedChanges.length > 0) {
|
|
5314
|
-
messages.push((0,
|
|
5462
|
+
messages.push((0, import_util23.format)(
|
|
5315
5463
|
" logicalID: %s, type: %s, rejected changes: %s, reason: %s",
|
|
5316
|
-
|
|
5317
|
-
|
|
5318
|
-
|
|
5319
|
-
|
|
5464
|
+
chalk8.bold(change.logicalId),
|
|
5465
|
+
chalk8.bold(change.resourceType),
|
|
5466
|
+
chalk8.bold(change.rejectedChanges),
|
|
5467
|
+
chalk8.red(change.reason)
|
|
5320
5468
|
));
|
|
5321
5469
|
} else {
|
|
5322
|
-
messages.push((0,
|
|
5470
|
+
messages.push((0, import_util23.format)(
|
|
5323
5471
|
" logicalID: %s, type: %s, reason: %s",
|
|
5324
|
-
|
|
5325
|
-
|
|
5326
|
-
|
|
5472
|
+
chalk8.bold(change.logicalId),
|
|
5473
|
+
chalk8.bold(change.resourceType),
|
|
5474
|
+
chalk8.red(change.reason)
|
|
5327
5475
|
));
|
|
5328
5476
|
}
|
|
5329
5477
|
}
|
|
@@ -5371,11 +5519,11 @@ async function deployStack(options, { ioHost, action }) {
|
|
|
5371
5519
|
if (hotswapMode !== "full-deployment" /* FULL_DEPLOYMENT */) {
|
|
5372
5520
|
await ioHost.notify(info2(
|
|
5373
5521
|
action,
|
|
5374
|
-
(0,
|
|
5522
|
+
(0, import_util25.format)(
|
|
5375
5523
|
`
|
|
5376
5524
|
${ICON} %s
|
|
5377
5525
|
`,
|
|
5378
|
-
|
|
5526
|
+
chalk9.bold("hotswap deployment skipped - no changes were detected (use --force to override)")
|
|
5379
5527
|
)
|
|
5380
5528
|
));
|
|
5381
5529
|
}
|
|
@@ -5419,7 +5567,7 @@ async function deployStack(options, { ioHost, action }) {
|
|
|
5419
5567
|
if (hotswapDeploymentResult) {
|
|
5420
5568
|
return hotswapDeploymentResult;
|
|
5421
5569
|
}
|
|
5422
|
-
await ioHost.notify(info2(action, (0,
|
|
5570
|
+
await ioHost.notify(info2(action, (0, import_util25.format)(
|
|
5423
5571
|
"Could not perform a hotswap deployment, as the stack %s contains non-Asset changes",
|
|
5424
5572
|
stackArtifact.displayName
|
|
5425
5573
|
)));
|
|
@@ -5427,7 +5575,7 @@ async function deployStack(options, { ioHost, action }) {
|
|
|
5427
5575
|
if (!(e instanceof CfnEvaluationException)) {
|
|
5428
5576
|
throw e;
|
|
5429
5577
|
}
|
|
5430
|
-
await ioHost.notify(info2(action, (0,
|
|
5578
|
+
await ioHost.notify(info2(action, (0, import_util25.format)(
|
|
5431
5579
|
"Could not perform a hotswap deployment, because the CloudFormation template could not be resolved: %s",
|
|
5432
5580
|
formatErrorMessage(e)
|
|
5433
5581
|
)));
|
|
@@ -5468,7 +5616,7 @@ var FullCloudFormationDeployment = class {
|
|
|
5468
5616
|
this.stackName = options.deployName ?? stackArtifact.stackName;
|
|
5469
5617
|
this.update = cloudFormationStack.exists && cloudFormationStack.stackStatus.name !== "REVIEW_IN_PROGRESS";
|
|
5470
5618
|
this.verb = this.update ? "update" : "create";
|
|
5471
|
-
this.uuid =
|
|
5619
|
+
this.uuid = uuid2.v4();
|
|
5472
5620
|
}
|
|
5473
5621
|
async performDeployment() {
|
|
5474
5622
|
const deploymentMethod = this.options.deploymentMethod ?? {
|
|
@@ -5491,9 +5639,9 @@ var FullCloudFormationDeployment = class {
|
|
|
5491
5639
|
const changeSetDescription = await this.createChangeSet(changeSetName, execute, importExistingResources);
|
|
5492
5640
|
await this.updateTerminationProtection();
|
|
5493
5641
|
if (changeSetHasNoChanges(changeSetDescription)) {
|
|
5494
|
-
debug2(this.action, (0,
|
|
5642
|
+
await this.ioHost.notify(debug2(this.action, (0, import_util25.format)("No changes are to be performed on %s.", this.stackName)));
|
|
5495
5643
|
if (execute) {
|
|
5496
|
-
debug2(this.action, (0,
|
|
5644
|
+
await this.ioHost.notify(debug2(this.action, (0, import_util25.format)("Deleting empty change set %s", changeSetDescription.ChangeSetId)));
|
|
5497
5645
|
await this.cfn.deleteChangeSet({
|
|
5498
5646
|
StackName: this.stackName,
|
|
5499
5647
|
ChangeSetName: changeSetName
|
|
@@ -5519,10 +5667,10 @@ var FullCloudFormationDeployment = class {
|
|
|
5519
5667
|
};
|
|
5520
5668
|
}
|
|
5521
5669
|
if (!execute) {
|
|
5522
|
-
info2(this.action, (0,
|
|
5670
|
+
await this.ioHost.notify(info2(this.action, (0, import_util25.format)(
|
|
5523
5671
|
"Changeset %s created and waiting in review for manual execution (--no-execute)",
|
|
5524
5672
|
changeSetDescription.ChangeSetId
|
|
5525
|
-
));
|
|
5673
|
+
)));
|
|
5526
5674
|
return {
|
|
5527
5675
|
type: "did-deploy-stack",
|
|
5528
5676
|
noOp: false,
|
|
@@ -5547,7 +5695,7 @@ var FullCloudFormationDeployment = class {
|
|
|
5547
5695
|
async createChangeSet(changeSetName, willExecute, importExistingResources) {
|
|
5548
5696
|
await this.cleanupOldChangeset(changeSetName);
|
|
5549
5697
|
await this.ioHost.notify(debug2(this.action, `Attempting to create ChangeSet with name ${changeSetName} to ${this.verb} stack ${this.stackName}`));
|
|
5550
|
-
await this.ioHost.notify(info2(this.action, (0,
|
|
5698
|
+
await this.ioHost.notify(info2(this.action, (0, import_util25.format)("%s: creating CloudFormation changeset...", chalk9.bold(this.stackName))));
|
|
5551
5699
|
const changeSet = await this.cfn.createChangeSet({
|
|
5552
5700
|
StackName: this.stackName,
|
|
5553
5701
|
ChangeSetName: changeSetName,
|
|
@@ -5558,13 +5706,13 @@ var FullCloudFormationDeployment = class {
|
|
|
5558
5706
|
ImportExistingResources: importExistingResources,
|
|
5559
5707
|
...this.commonPrepareOptions()
|
|
5560
5708
|
});
|
|
5561
|
-
await this.ioHost.notify(debug2(this.action, (0,
|
|
5709
|
+
await this.ioHost.notify(debug2(this.action, (0, import_util25.format)("Initiated creation of changeset: %s; waiting for it to finish creating...", changeSet.Id)));
|
|
5562
5710
|
return waitForChangeSet(this.cfn, { ioHost: this.ioHost, action: this.action }, this.stackName, changeSetName, {
|
|
5563
5711
|
fetchAll: willExecute
|
|
5564
5712
|
});
|
|
5565
5713
|
}
|
|
5566
5714
|
async executeChangeSet(changeSet) {
|
|
5567
|
-
await this.ioHost.notify(debug2(this.action, (0,
|
|
5715
|
+
await this.ioHost.notify(debug2(this.action, (0, import_util25.format)("Initiating execution of changeset %s on stack %s", changeSet.ChangeSetId, this.stackName)));
|
|
5568
5716
|
await this.cfn.executeChangeSet({
|
|
5569
5717
|
StackName: this.stackName,
|
|
5570
5718
|
ChangeSetName: changeSet.ChangeSetName,
|
|
@@ -5573,7 +5721,7 @@ var FullCloudFormationDeployment = class {
|
|
|
5573
5721
|
});
|
|
5574
5722
|
await this.ioHost.notify(debug2(
|
|
5575
5723
|
this.action,
|
|
5576
|
-
(0,
|
|
5724
|
+
(0, import_util25.format)(
|
|
5577
5725
|
"Execution of changeset %s on stack %s has started; waiting for the update to complete...",
|
|
5578
5726
|
changeSet.ChangeSetId,
|
|
5579
5727
|
this.stackName
|
|
@@ -5596,7 +5744,7 @@ var FullCloudFormationDeployment = class {
|
|
|
5596
5744
|
if (!!this.cloudFormationStack.terminationProtection !== terminationProtection) {
|
|
5597
5745
|
await this.ioHost.notify(debug2(
|
|
5598
5746
|
this.action,
|
|
5599
|
-
(0,
|
|
5747
|
+
(0, import_util25.format)(
|
|
5600
5748
|
"Updating termination protection from %s to %s for stack %s",
|
|
5601
5749
|
this.cloudFormationStack.terminationProtection,
|
|
5602
5750
|
terminationProtection,
|
|
@@ -5607,11 +5755,11 @@ var FullCloudFormationDeployment = class {
|
|
|
5607
5755
|
StackName: this.stackName,
|
|
5608
5756
|
EnableTerminationProtection: terminationProtection
|
|
5609
5757
|
});
|
|
5610
|
-
await this.ioHost.notify(debug2(this.action, (0,
|
|
5758
|
+
await this.ioHost.notify(debug2(this.action, (0, import_util25.format)("Termination protection updated to %s for stack %s", terminationProtection, this.stackName)));
|
|
5611
5759
|
}
|
|
5612
5760
|
}
|
|
5613
5761
|
async directDeployment() {
|
|
5614
|
-
await this.ioHost.notify(info2(this.action, (0,
|
|
5762
|
+
await this.ioHost.notify(info2(this.action, (0, import_util25.format)("%s: %s stack...", chalk9.bold(this.stackName), this.update ? "updating" : "creating")));
|
|
5615
5763
|
const startTime = /* @__PURE__ */ new Date();
|
|
5616
5764
|
if (this.update) {
|
|
5617
5765
|
await this.updateTerminationProtection();
|
|
@@ -5624,7 +5772,7 @@ var FullCloudFormationDeployment = class {
|
|
|
5624
5772
|
});
|
|
5625
5773
|
} catch (err) {
|
|
5626
5774
|
if (err.message === "No updates are to be performed.") {
|
|
5627
|
-
await this.ioHost.notify(debug2(this.action, (0,
|
|
5775
|
+
await this.ioHost.notify(debug2(this.action, (0, import_util25.format)("No updates are to be performed for stack %s", this.stackName)));
|
|
5628
5776
|
return {
|
|
5629
5777
|
type: "did-deploy-stack",
|
|
5630
5778
|
noOp: true,
|
|
@@ -5648,12 +5796,16 @@ var FullCloudFormationDeployment = class {
|
|
|
5648
5796
|
}
|
|
5649
5797
|
}
|
|
5650
5798
|
async monitorDeployment(startTime, expectedChanges) {
|
|
5651
|
-
const monitor =
|
|
5799
|
+
const monitor = new StackActivityMonitor({
|
|
5800
|
+
cfn: this.cfn,
|
|
5801
|
+
stack: this.stackArtifact,
|
|
5802
|
+
stackName: this.stackName,
|
|
5652
5803
|
resourcesTotal: expectedChanges,
|
|
5653
|
-
|
|
5654
|
-
|
|
5655
|
-
|
|
5656
|
-
})
|
|
5804
|
+
ioHost: this.ioHost,
|
|
5805
|
+
action: this.action,
|
|
5806
|
+
changeSetCreationTime: startTime
|
|
5807
|
+
});
|
|
5808
|
+
await monitor.start();
|
|
5657
5809
|
let finalState = this.cloudFormationStack;
|
|
5658
5810
|
try {
|
|
5659
5811
|
const successStack = await waitForStackDeploy(this.cfn, { ioHost: this.ioHost, action: this.action }, this.stackName);
|
|
@@ -5662,11 +5814,11 @@ var FullCloudFormationDeployment = class {
|
|
|
5662
5814
|
}
|
|
5663
5815
|
finalState = successStack;
|
|
5664
5816
|
} catch (e) {
|
|
5665
|
-
throw new ToolkitError(suffixWithErrors(formatErrorMessage(e), monitor
|
|
5817
|
+
throw new ToolkitError(suffixWithErrors(formatErrorMessage(e), monitor.errors));
|
|
5666
5818
|
} finally {
|
|
5667
|
-
await monitor
|
|
5819
|
+
await monitor.stop();
|
|
5668
5820
|
}
|
|
5669
|
-
debug2(this.action, (0,
|
|
5821
|
+
debug2(this.action, (0, import_util25.format)("Stack %s has completed updating", this.stackName));
|
|
5670
5822
|
return {
|
|
5671
5823
|
type: "did-deploy-stack",
|
|
5672
5824
|
noOp: false,
|
|
@@ -5709,9 +5861,14 @@ async function destroyStack(options, { ioHost, action }) {
|
|
|
5709
5861
|
if (!currentStack.exists) {
|
|
5710
5862
|
return;
|
|
5711
5863
|
}
|
|
5712
|
-
const monitor =
|
|
5713
|
-
|
|
5714
|
-
|
|
5864
|
+
const monitor = new StackActivityMonitor({
|
|
5865
|
+
cfn,
|
|
5866
|
+
stack: options.stack,
|
|
5867
|
+
stackName: deployName,
|
|
5868
|
+
ioHost,
|
|
5869
|
+
action
|
|
5870
|
+
});
|
|
5871
|
+
await monitor.start();
|
|
5715
5872
|
try {
|
|
5716
5873
|
await cfn.deleteStack({ StackName: deployName, RoleARN: options.roleArn });
|
|
5717
5874
|
const destroyedStack = await waitForStackDelete(cfn, { ioHost, action }, deployName);
|
|
@@ -5719,7 +5876,7 @@ async function destroyStack(options, { ioHost, action }) {
|
|
|
5719
5876
|
throw new ToolkitError(`Failed to destroy ${deployName}: ${destroyedStack.stackStatus}`);
|
|
5720
5877
|
}
|
|
5721
5878
|
} catch (e) {
|
|
5722
|
-
throw new ToolkitError(suffixWithErrors(formatErrorMessage(e), monitor
|
|
5879
|
+
throw new ToolkitError(suffixWithErrors(formatErrorMessage(e), monitor.errors));
|
|
5723
5880
|
} finally {
|
|
5724
5881
|
if (monitor) {
|
|
5725
5882
|
await monitor.stop();
|
|
@@ -5798,34 +5955,54 @@ function hasReplacement(cs) {
|
|
|
5798
5955
|
|
|
5799
5956
|
// ../../aws-cdk/lib/notices.ts
|
|
5800
5957
|
var https = __toESM(require("node:https"));
|
|
5801
|
-
var
|
|
5802
|
-
var
|
|
5958
|
+
var path10 = __toESM(require("path"));
|
|
5959
|
+
var fs11 = __toESM(require("fs-extra"));
|
|
5803
5960
|
var semver4 = __toESM(require("semver"));
|
|
5804
5961
|
|
|
5805
5962
|
// ../../aws-cdk/lib/cli/version.ts
|
|
5806
|
-
var
|
|
5807
|
-
var
|
|
5808
|
-
var
|
|
5963
|
+
var path8 = __toESM(require("path"));
|
|
5964
|
+
var chalk10 = __toESM(require("chalk"));
|
|
5965
|
+
var fs9 = __toESM(require("fs-extra"));
|
|
5809
5966
|
var semver3 = __toESM(require("semver"));
|
|
5810
5967
|
|
|
5968
|
+
// ../../aws-cdk/lib/cli/root-dir.ts
|
|
5969
|
+
var fs8 = __toESM(require("fs"));
|
|
5970
|
+
var path7 = __toESM(require("path"));
|
|
5971
|
+
function cliRootDir(fail) {
|
|
5972
|
+
function _rootDir(dirname6) {
|
|
5973
|
+
const manifestPath = path7.join(dirname6, "package.json");
|
|
5974
|
+
if (fs8.existsSync(manifestPath)) {
|
|
5975
|
+
return dirname6;
|
|
5976
|
+
}
|
|
5977
|
+
if (path7.dirname(dirname6) === dirname6) {
|
|
5978
|
+
if (fail ?? true) {
|
|
5979
|
+
throw new ToolkitError("Unable to find package manifest");
|
|
5980
|
+
}
|
|
5981
|
+
return void 0;
|
|
5982
|
+
}
|
|
5983
|
+
return _rootDir(path7.dirname(dirname6));
|
|
5984
|
+
}
|
|
5985
|
+
return _rootDir(__dirname);
|
|
5986
|
+
}
|
|
5987
|
+
|
|
5811
5988
|
// ../../aws-cdk/lib/cli/util/console-formatters.ts
|
|
5812
5989
|
var stripAnsi = require("strip-ansi");
|
|
5813
5990
|
|
|
5814
5991
|
// ../../aws-cdk/lib/cli/util/npm.ts
|
|
5815
5992
|
var import_child_process = require("child_process");
|
|
5816
|
-
var
|
|
5993
|
+
var import_util27 = require("util");
|
|
5817
5994
|
var semver2 = __toESM(require("semver"));
|
|
5818
|
-
var exec = (0,
|
|
5995
|
+
var exec = (0, import_util27.promisify)(import_child_process.exec);
|
|
5819
5996
|
|
|
5820
5997
|
// ../../aws-cdk/lib/cli/version.ts
|
|
5821
5998
|
var ONE_DAY_IN_SECONDS = 1 * 24 * 60 * 60;
|
|
5822
5999
|
function versionNumber() {
|
|
5823
|
-
return require(
|
|
6000
|
+
return require(path8.join(cliRootDir(), "package.json")).version.replace(/\+[0-9a-f]+$/, "");
|
|
5824
6001
|
}
|
|
5825
6002
|
|
|
5826
6003
|
// ../../aws-cdk/lib/tree.ts
|
|
5827
|
-
var
|
|
5828
|
-
var
|
|
6004
|
+
var path9 = __toESM(require("path"));
|
|
6005
|
+
var fs10 = __toESM(require("fs-extra"));
|
|
5829
6006
|
function some(node, predicate) {
|
|
5830
6007
|
return node != null && (predicate(node) || findInChildren());
|
|
5831
6008
|
function findInChildren() {
|
|
@@ -5836,7 +6013,7 @@ function loadTree(assembly) {
|
|
|
5836
6013
|
try {
|
|
5837
6014
|
const outdir = assembly.directory;
|
|
5838
6015
|
const fileName = assembly.tree()?.file;
|
|
5839
|
-
return fileName ?
|
|
6016
|
+
return fileName ? fs10.readJSONSync(path9.join(outdir, fileName)).tree : {};
|
|
5840
6017
|
} catch (e) {
|
|
5841
6018
|
trace(`Failed to get tree.json file: ${e}. Proceeding with empty tree.`);
|
|
5842
6019
|
return void 0;
|
|
@@ -5844,7 +6021,7 @@ function loadTree(assembly) {
|
|
|
5844
6021
|
}
|
|
5845
6022
|
function loadTreeFromDir(outdir) {
|
|
5846
6023
|
try {
|
|
5847
|
-
return
|
|
6024
|
+
return fs10.readJSONSync(path9.join(outdir, "tree.json")).tree;
|
|
5848
6025
|
} catch (e) {
|
|
5849
6026
|
trace(`Failed to get tree.json file: ${e}. Proceeding with empty tree.`);
|
|
5850
6027
|
return void 0;
|
|
@@ -5852,7 +6029,7 @@ function loadTreeFromDir(outdir) {
|
|
|
5852
6029
|
}
|
|
5853
6030
|
|
|
5854
6031
|
// ../../aws-cdk/lib/notices.ts
|
|
5855
|
-
var CACHE_FILE_PATH =
|
|
6032
|
+
var CACHE_FILE_PATH = path10.join(cdkCacheDir(), "notices.json");
|
|
5856
6033
|
var NoticesFilter = class _NoticesFilter {
|
|
5857
6034
|
static filter(options) {
|
|
5858
6035
|
const components = [
|
|
@@ -5901,7 +6078,7 @@ var NoticesFilter = class _NoticesFilter {
|
|
|
5901
6078
|
return data.flatMap((notice) => {
|
|
5902
6079
|
const ors = this.resolveAliases(normalizeComponents(notice.components));
|
|
5903
6080
|
for (const ands of ors) {
|
|
5904
|
-
const matched = ands.map((affected) => actualComponents.filter((actual) => _NoticesFilter.componentNameMatches(affected, actual) && semver4.satisfies(actual.version, affected.version)));
|
|
6081
|
+
const matched = ands.map((affected) => actualComponents.filter((actual) => _NoticesFilter.componentNameMatches(affected, actual) && semver4.satisfies(actual.version, affected.version, { includePrerelease: true })));
|
|
5905
6082
|
if (matched.every((xs) => xs.length > 0)) {
|
|
5906
6083
|
const ret = new FilteredNotice(notice);
|
|
5907
6084
|
_NoticesFilter.addDynamicValues(matched.flatMap((x) => x), ret);
|
|
@@ -6209,7 +6386,7 @@ var CachedDataSource = class {
|
|
|
6209
6386
|
notices: []
|
|
6210
6387
|
};
|
|
6211
6388
|
try {
|
|
6212
|
-
return
|
|
6389
|
+
return fs11.existsSync(this.fileName) ? await fs11.readJSON(this.fileName) : defaultValue;
|
|
6213
6390
|
} catch (e) {
|
|
6214
6391
|
debug(`Failed to load notices from cache: ${e}`);
|
|
6215
6392
|
return defaultValue;
|
|
@@ -6217,7 +6394,7 @@ var CachedDataSource = class {
|
|
|
6217
6394
|
}
|
|
6218
6395
|
async save(cached2) {
|
|
6219
6396
|
try {
|
|
6220
|
-
await
|
|
6397
|
+
await fs11.writeJSON(this.fileName, cached2);
|
|
6221
6398
|
} catch (e) {
|
|
6222
6399
|
debug(`Failed to store notices in the cache: ${e}`);
|
|
6223
6400
|
}
|
|
@@ -6225,14 +6402,15 @@ var CachedDataSource = class {
|
|
|
6225
6402
|
};
|
|
6226
6403
|
|
|
6227
6404
|
// ../../aws-cdk/lib/api/toolkit-info.ts
|
|
6228
|
-
var
|
|
6229
|
-
var
|
|
6405
|
+
var import_util30 = require("util");
|
|
6406
|
+
var chalk11 = __toESM(require("chalk"));
|
|
6230
6407
|
|
|
6231
6408
|
// ../../aws-cdk/lib/api/bootstrap/bootstrap-props.ts
|
|
6232
6409
|
var BUCKET_NAME_OUTPUT = "BucketName";
|
|
6233
6410
|
var REPOSITORY_NAME_OUTPUT = "ImageRepositoryName";
|
|
6234
6411
|
var BUCKET_DOMAIN_NAME_OUTPUT = "BucketDomainName";
|
|
6235
6412
|
var BOOTSTRAP_VERSION_OUTPUT = "BootstrapVersion";
|
|
6413
|
+
var BOOTSTRAP_VERSION_RESOURCE = "CdkBootstrapVersion";
|
|
6236
6414
|
var BOOTSTRAP_VARIANT_PARAMETER = "BootstrapVariant";
|
|
6237
6415
|
var DEFAULT_BOOTSTRAP_VARIANT = "AWS CDK: Default Resources";
|
|
6238
6416
|
|
|
@@ -6250,11 +6428,11 @@ var ToolkitInfo = class _ToolkitInfo {
|
|
|
6250
6428
|
if (!stack) {
|
|
6251
6429
|
await ioHost.notify(debug2(
|
|
6252
6430
|
action,
|
|
6253
|
-
(0,
|
|
6431
|
+
(0, import_util30.format)(
|
|
6254
6432
|
"The environment %s doesn't have the CDK toolkit stack (%s) installed. Use %s to setup your environment for use with the toolkit.",
|
|
6255
6433
|
environment.name,
|
|
6256
6434
|
stackName,
|
|
6257
|
-
|
|
6435
|
+
chalk11.blue(`cdk bootstrap "${environment.name}"`)
|
|
6258
6436
|
)
|
|
6259
6437
|
));
|
|
6260
6438
|
return _ToolkitInfo.bootstrapStackNotFoundInfo(stackName);
|
|
@@ -6262,11 +6440,11 @@ var ToolkitInfo = class _ToolkitInfo {
|
|
|
6262
6440
|
if (stack.stackStatus.isCreationFailure) {
|
|
6263
6441
|
await ioHost.notify(debug2(
|
|
6264
6442
|
action,
|
|
6265
|
-
(0,
|
|
6443
|
+
(0, import_util30.format)(
|
|
6266
6444
|
"The environment %s has a CDK toolkit stack (%s) that failed to create. Use %s to try provisioning it again.",
|
|
6267
6445
|
environment.name,
|
|
6268
6446
|
stackName,
|
|
6269
|
-
|
|
6447
|
+
chalk11.blue(`cdk bootstrap "${environment.name}"`)
|
|
6270
6448
|
)
|
|
6271
6449
|
));
|
|
6272
6450
|
return _ToolkitInfo.bootstrapStackNotFoundInfo(stackName);
|
|
@@ -6513,6 +6691,19 @@ var EnvironmentResources = class {
|
|
|
6513
6691
|
return { repositoryUri };
|
|
6514
6692
|
}
|
|
6515
6693
|
};
|
|
6694
|
+
var NoBootstrapStackEnvironmentResources = class extends EnvironmentResources {
|
|
6695
|
+
constructor(environment, sdk, msg) {
|
|
6696
|
+
super(environment, sdk, msg, emptyCache());
|
|
6697
|
+
}
|
|
6698
|
+
/**
|
|
6699
|
+
* Look up the toolkit for a given environment, using a given SDK
|
|
6700
|
+
*/
|
|
6701
|
+
async lookupToolkit() {
|
|
6702
|
+
throw new ToolkitError(
|
|
6703
|
+
"Trying to perform an operation that requires a bootstrap stack; you should not see this error, this is a bug in the CDK CLI."
|
|
6704
|
+
);
|
|
6705
|
+
}
|
|
6706
|
+
};
|
|
6516
6707
|
function emptyCache() {
|
|
6517
6708
|
return {
|
|
6518
6709
|
ssmParameters: /* @__PURE__ */ new Map(),
|
|
@@ -6800,7 +6991,6 @@ var Deployments = class {
|
|
|
6800
6991
|
resolvedEnvironment: env.resolvedEnvironment,
|
|
6801
6992
|
deployName: options.deployName,
|
|
6802
6993
|
notificationArns: options.notificationArns,
|
|
6803
|
-
quiet: options.quiet,
|
|
6804
6994
|
sdk: env.sdk,
|
|
6805
6995
|
sdkProvider: this.deployStackSdkProvider,
|
|
6806
6996
|
roleArn: executionRoleArn,
|
|
@@ -6811,8 +7001,6 @@ var Deployments = class {
|
|
|
6811
7001
|
force: options.force,
|
|
6812
7002
|
parameters: options.parameters,
|
|
6813
7003
|
usePreviousParameters: options.usePreviousParameters,
|
|
6814
|
-
progress: options.progress,
|
|
6815
|
-
ci: options.ci,
|
|
6816
7004
|
rollback: options.rollback,
|
|
6817
7005
|
hotswap: options.hotswap,
|
|
6818
7006
|
hotswapPropertyOverrides: options.hotswapPropertyOverrides,
|
|
@@ -6883,9 +7071,14 @@ var Deployments = class {
|
|
|
6883
7071
|
default:
|
|
6884
7072
|
throw new ToolkitError(`Unexpected rollback choice: ${cloudFormationStack.stackStatus.rollbackChoice}`);
|
|
6885
7073
|
}
|
|
6886
|
-
const monitor =
|
|
6887
|
-
|
|
6888
|
-
|
|
7074
|
+
const monitor = new StackActivityMonitor({
|
|
7075
|
+
cfn,
|
|
7076
|
+
stack: options.stack,
|
|
7077
|
+
stackName: deployName,
|
|
7078
|
+
ioHost: this.ioHost,
|
|
7079
|
+
action: this.action
|
|
7080
|
+
});
|
|
7081
|
+
await monitor.start();
|
|
6889
7082
|
let stackErrorMessage = void 0;
|
|
6890
7083
|
let finalStackState = cloudFormationStack;
|
|
6891
7084
|
try {
|
|
@@ -6894,14 +7087,14 @@ var Deployments = class {
|
|
|
6894
7087
|
throw new ToolkitError("Stack deploy failed (the stack disappeared while we were rolling it back)");
|
|
6895
7088
|
}
|
|
6896
7089
|
finalStackState = successStack;
|
|
6897
|
-
const errors = monitor
|
|
7090
|
+
const errors = monitor.errors.join(", ");
|
|
6898
7091
|
if (errors) {
|
|
6899
7092
|
stackErrorMessage = errors;
|
|
6900
7093
|
}
|
|
6901
7094
|
} catch (e) {
|
|
6902
|
-
stackErrorMessage = suffixWithErrors2(formatErrorMessage(e), monitor
|
|
7095
|
+
stackErrorMessage = suffixWithErrors2(formatErrorMessage(e), monitor.errors);
|
|
6903
7096
|
} finally {
|
|
6904
|
-
await monitor
|
|
7097
|
+
await monitor.stop();
|
|
6905
7098
|
}
|
|
6906
7099
|
if (finalStackState.stackStatus.isRollbackSuccess || !stackErrorMessage) {
|
|
6907
7100
|
return { success: true };
|
|
@@ -6924,9 +7117,7 @@ var Deployments = class {
|
|
|
6924
7117
|
sdk: env.sdk,
|
|
6925
7118
|
roleArn: executionRoleArn,
|
|
6926
7119
|
stack: options.stack,
|
|
6927
|
-
deployName: options.deployName
|
|
6928
|
-
quiet: options.quiet,
|
|
6929
|
-
ci: options.ci
|
|
7120
|
+
deployName: options.deployName
|
|
6930
7121
|
}, { ioHost: this.ioHost, action: this.action });
|
|
6931
7122
|
}
|
|
6932
7123
|
async stackExists(options) {
|
|
@@ -6961,7 +7152,7 @@ var Deployments = class {
|
|
|
6961
7152
|
const publisher = this.cachedPublisher(assetManifest, resolvedEnvironment, options.stackName);
|
|
6962
7153
|
await publisher.buildEntry(asset);
|
|
6963
7154
|
if (publisher.hasFailures) {
|
|
6964
|
-
throw new ToolkitError(`Failed to build asset ${asset.
|
|
7155
|
+
throw new ToolkitError(`Failed to build asset ${asset.displayName(false)}`);
|
|
6965
7156
|
}
|
|
6966
7157
|
}
|
|
6967
7158
|
/**
|
|
@@ -6972,7 +7163,7 @@ var Deployments = class {
|
|
|
6972
7163
|
const publisher = this.cachedPublisher(assetManifest, stackEnv, options.stackName);
|
|
6973
7164
|
await publisher.publishEntry(asset, { allowCrossAccount: await this.allowCrossAccountAssetPublishingForEnv(options.stack) });
|
|
6974
7165
|
if (publisher.hasFailures) {
|
|
6975
|
-
throw new ToolkitError(`Failed to publish asset ${asset.
|
|
7166
|
+
throw new ToolkitError(`Failed to publish asset ${asset.displayName(true)}`);
|
|
6976
7167
|
}
|
|
6977
7168
|
}
|
|
6978
7169
|
async allowCrossAccountAssetPublishingForEnv(stack) {
|
|
@@ -7010,7 +7201,7 @@ var Deployments = class {
|
|
|
7010
7201
|
if (existing) {
|
|
7011
7202
|
return existing;
|
|
7012
7203
|
}
|
|
7013
|
-
const prefix = stackName ? `${
|
|
7204
|
+
const prefix = stackName ? `${chalk12.bold(stackName)}: ` : "";
|
|
7014
7205
|
const publisher = new cdk_assets.AssetPublishing(assetManifest, {
|
|
7015
7206
|
// The AssetPublishing class takes care of role assuming etc, so it's okay to
|
|
7016
7207
|
// give it a direct `SdkProvider`.
|
|
@@ -7047,10 +7238,10 @@ function tagsForStack(stack) {
|
|
|
7047
7238
|
}
|
|
7048
7239
|
|
|
7049
7240
|
// ../../aws-cdk/lib/api/resource-import/importer.ts
|
|
7050
|
-
var
|
|
7241
|
+
var import_util34 = require("util");
|
|
7051
7242
|
var cfnDiff = __toESM(require("@aws-cdk/cloudformation-diff"));
|
|
7052
|
-
var
|
|
7053
|
-
var
|
|
7243
|
+
var chalk13 = __toESM(require("chalk"));
|
|
7244
|
+
var fs12 = __toESM(require("fs-extra"));
|
|
7054
7245
|
var promptly3 = __toESM(require("promptly"));
|
|
7055
7246
|
var ResourceImporter = class {
|
|
7056
7247
|
constructor(stack, props) {
|
|
@@ -7079,18 +7270,18 @@ var ResourceImporter = class {
|
|
|
7079
7270
|
* Load the resources to import from a file
|
|
7080
7271
|
*/
|
|
7081
7272
|
async loadResourceIdentifiers(available, filename) {
|
|
7082
|
-
const contents = await
|
|
7273
|
+
const contents = await fs12.readJson(filename);
|
|
7083
7274
|
const ret = { importResources: [], resourceMap: {} };
|
|
7084
7275
|
for (const resource of available) {
|
|
7085
7276
|
const descr = this.describeResource(resource.logicalId);
|
|
7086
7277
|
const idProps = contents[resource.logicalId];
|
|
7087
7278
|
if (idProps) {
|
|
7088
|
-
await this.ioHost.notify(info2(this.action, (0,
|
|
7279
|
+
await this.ioHost.notify(info2(this.action, (0, import_util34.format)("%s: importing using %s", chalk13.blue(descr), chalk13.blue(fmtdict(idProps)))));
|
|
7089
7280
|
ret.importResources.push(resource);
|
|
7090
7281
|
ret.resourceMap[resource.logicalId] = idProps;
|
|
7091
7282
|
delete contents[resource.logicalId];
|
|
7092
7283
|
} else {
|
|
7093
|
-
await this.ioHost.notify(info2(this.action, (0,
|
|
7284
|
+
await this.ioHost.notify(info2(this.action, (0, import_util34.format)("%s: skipping", chalk13.blue(descr))));
|
|
7094
7285
|
}
|
|
7095
7286
|
}
|
|
7096
7287
|
const unknown = Object.keys(contents);
|
|
@@ -7134,9 +7325,9 @@ var ResourceImporter = class {
|
|
|
7134
7325
|
});
|
|
7135
7326
|
assertIsSuccessfulDeployStackResult(result);
|
|
7136
7327
|
const message = result.noOp ? " \u2705 %s (no changes)" : " \u2705 %s";
|
|
7137
|
-
await this.ioHost.notify(info2(this.action, "\n" +
|
|
7328
|
+
await this.ioHost.notify(info2(this.action, "\n" + chalk13.green((0, import_util34.format)(message, this.stack.displayName))));
|
|
7138
7329
|
} catch (e) {
|
|
7139
|
-
await this.ioHost.notify(error2(this.action, (0,
|
|
7330
|
+
await this.ioHost.notify(error2(this.action, (0, import_util34.format)("\n \u274C %s failed: %s", chalk13.bold(this.stack.displayName), e), "CDK_TOOLKIT_E3900"));
|
|
7140
7331
|
throw e;
|
|
7141
7332
|
}
|
|
7142
7333
|
}
|
|
@@ -7238,21 +7429,21 @@ var ResourceImporter = class {
|
|
|
7238
7429
|
const candidateProps = Object.fromEntries(satisfiedPropSet.map((p) => [p, resourceProps[p]]));
|
|
7239
7430
|
const displayCandidateProps = fmtdict(candidateProps);
|
|
7240
7431
|
if (await promptly3.confirm(
|
|
7241
|
-
`${
|
|
7432
|
+
`${chalk13.blue(resourceName)} (${resourceType}): import with ${chalk13.yellow(displayCandidateProps)} (yes/no) [default: yes]? `,
|
|
7242
7433
|
{ default: "yes" }
|
|
7243
7434
|
)) {
|
|
7244
7435
|
return candidateProps;
|
|
7245
7436
|
}
|
|
7246
7437
|
}
|
|
7247
7438
|
if (satisfiedPropSets.length > 0) {
|
|
7248
|
-
await this.ioHost.notify(info2(this.action,
|
|
7439
|
+
await this.ioHost.notify(info2(this.action, chalk13.grey(`Skipping import of ${resourceName}`)));
|
|
7249
7440
|
return void 0;
|
|
7250
7441
|
}
|
|
7251
|
-
const prefix = `${
|
|
7442
|
+
const prefix = `${chalk13.blue(resourceName)} (${resourceType})`;
|
|
7252
7443
|
let preamble;
|
|
7253
7444
|
let promptPattern;
|
|
7254
7445
|
if (idPropSets.length > 1) {
|
|
7255
|
-
preamble = `${prefix}: enter one of ${idPropSets.map((x) =>
|
|
7446
|
+
preamble = `${prefix}: enter one of ${idPropSets.map((x) => chalk13.blue(x.join("+"))).join(", ")} to import (all empty to skip)`;
|
|
7256
7447
|
promptPattern = `${prefix}: enter %`;
|
|
7257
7448
|
} else {
|
|
7258
7449
|
promptPattern = `${prefix}: enter %`;
|
|
@@ -7265,7 +7456,7 @@ var ResourceImporter = class {
|
|
|
7265
7456
|
for (const idProp of idProps) {
|
|
7266
7457
|
const defaultValue = resourceProps[idProp] ?? "";
|
|
7267
7458
|
const prompt4 = [
|
|
7268
|
-
promptPattern.replace(/%/g,
|
|
7459
|
+
promptPattern.replace(/%/g, chalk13.blue(idProp)),
|
|
7269
7460
|
defaultValue ? `[${defaultValue}]` : "(empty to skip)"
|
|
7270
7461
|
].join(" ") + ":";
|
|
7271
7462
|
const response = await promptly3.prompt(
|
|
@@ -7282,7 +7473,7 @@ var ResourceImporter = class {
|
|
|
7282
7473
|
return input;
|
|
7283
7474
|
}
|
|
7284
7475
|
}
|
|
7285
|
-
await this.ioHost.notify(info2(this.action,
|
|
7476
|
+
await this.ioHost.notify(info2(this.action, chalk13.grey(`Skipping import of ${resourceName}`)));
|
|
7286
7477
|
return void 0;
|
|
7287
7478
|
}
|
|
7288
7479
|
/**
|
|
@@ -7332,8 +7523,8 @@ function addDefaultDeletionPolicy(resource) {
|
|
|
7332
7523
|
}
|
|
7333
7524
|
|
|
7334
7525
|
// ../../aws-cdk/lib/api/resource-import/migrator.ts
|
|
7335
|
-
var
|
|
7336
|
-
var
|
|
7526
|
+
var chalk14 = __toESM(require("chalk"));
|
|
7527
|
+
var fs13 = __toESM(require("fs-extra"));
|
|
7337
7528
|
var ResourceMigrator = class {
|
|
7338
7529
|
constructor(props) {
|
|
7339
7530
|
this.props = props;
|
|
@@ -7355,11 +7546,11 @@ var ResourceMigrator = class {
|
|
|
7355
7546
|
});
|
|
7356
7547
|
const resourcesToImport = await this.tryGetResources(await migrateDeployment.resolveEnvironment());
|
|
7357
7548
|
if (resourcesToImport) {
|
|
7358
|
-
await this.ioHost.notify(info2(this.action, `${
|
|
7359
|
-
await this.ioHost.notify(info2(this.action, `${
|
|
7549
|
+
await this.ioHost.notify(info2(this.action, `${chalk14.bold(stack.displayName)}: creating stack for resource migration...`));
|
|
7550
|
+
await this.ioHost.notify(info2(this.action, `${chalk14.bold(stack.displayName)}: importing resources into stack...`));
|
|
7360
7551
|
await this.performResourceMigration(migrateDeployment, resourcesToImport, options);
|
|
7361
|
-
|
|
7362
|
-
await this.ioHost.notify(info2(this.action, `${
|
|
7552
|
+
fs13.rmSync("migrate.json");
|
|
7553
|
+
await this.ioHost.notify(info2(this.action, `${chalk14.bold(stack.displayName)}: applying CDKMetadata and Outputs to stack (if applicable)...`));
|
|
7363
7554
|
}
|
|
7364
7555
|
}
|
|
7365
7556
|
/**
|
|
@@ -7372,7 +7563,6 @@ var ResourceMigrator = class {
|
|
|
7372
7563
|
roleArn: options.roleArn,
|
|
7373
7564
|
deploymentMethod: options.deploymentMethod,
|
|
7374
7565
|
usePreviousParameters: true,
|
|
7375
|
-
progress: options.progress,
|
|
7376
7566
|
rollback: options.rollback
|
|
7377
7567
|
});
|
|
7378
7568
|
elapsedDeployTime = (/* @__PURE__ */ new Date()).getTime() - startDeployTime;
|
|
@@ -7384,7 +7574,7 @@ var ResourceMigrator = class {
|
|
|
7384
7574
|
}
|
|
7385
7575
|
async tryGetResources(environment) {
|
|
7386
7576
|
try {
|
|
7387
|
-
const migrateFile =
|
|
7577
|
+
const migrateFile = fs13.readJsonSync("migrate.json", {
|
|
7388
7578
|
encoding: "utf-8"
|
|
7389
7579
|
});
|
|
7390
7580
|
const sourceEnv = migrateFile.Source.split(":");
|
|
@@ -7398,8 +7588,8 @@ var ResourceMigrator = class {
|
|
|
7398
7588
|
};
|
|
7399
7589
|
|
|
7400
7590
|
// ../../aws-cdk/lib/api/logs/logs-monitor.ts
|
|
7401
|
-
var
|
|
7402
|
-
var
|
|
7591
|
+
var util7 = __toESM(require("util"));
|
|
7592
|
+
var chalk15 = __toESM(require("chalk"));
|
|
7403
7593
|
var SLEEP = 2e3;
|
|
7404
7594
|
var CloudWatchLogEventMonitor = class {
|
|
7405
7595
|
constructor(startTime) {
|
|
@@ -7490,10 +7680,10 @@ var CloudWatchLogEventMonitor = class {
|
|
|
7490
7680
|
*/
|
|
7491
7681
|
print(event) {
|
|
7492
7682
|
info(
|
|
7493
|
-
|
|
7683
|
+
util7.format(
|
|
7494
7684
|
"[%s] %s %s",
|
|
7495
|
-
|
|
7496
|
-
|
|
7685
|
+
chalk15.blue(event.logGroupName),
|
|
7686
|
+
chalk15.yellow(event.timestamp.toLocaleTimeString()),
|
|
7497
7687
|
event.message.trim()
|
|
7498
7688
|
)
|
|
7499
7689
|
);
|
|
@@ -7882,17 +8072,17 @@ var WorkGraph = class {
|
|
|
7882
8072
|
}
|
|
7883
8073
|
}
|
|
7884
8074
|
return void 0;
|
|
7885
|
-
function recurse(nodeId,
|
|
8075
|
+
function recurse(nodeId, path15) {
|
|
7886
8076
|
if (seen.has(nodeId)) {
|
|
7887
8077
|
return void 0;
|
|
7888
8078
|
}
|
|
7889
8079
|
try {
|
|
7890
8080
|
for (const dep of self.nodes[nodeId].dependencies ?? []) {
|
|
7891
|
-
const index =
|
|
8081
|
+
const index = path15.indexOf(dep);
|
|
7892
8082
|
if (index > -1) {
|
|
7893
|
-
return [...
|
|
8083
|
+
return [...path15.slice(index), dep];
|
|
7894
8084
|
}
|
|
7895
|
-
const cycle = recurse(dep, [...
|
|
8085
|
+
const cycle = recurse(dep, [...path15, dep]);
|
|
7896
8086
|
if (cycle) {
|
|
7897
8087
|
return cycle;
|
|
7898
8088
|
}
|
|
@@ -7994,7 +8184,7 @@ var WorkGraphBuilder = class _WorkGraphBuilder {
|
|
|
7994
8184
|
const node = {
|
|
7995
8185
|
type: "asset-build",
|
|
7996
8186
|
id: buildId,
|
|
7997
|
-
note:
|
|
8187
|
+
note: asset.displayName(false),
|
|
7998
8188
|
dependencies: /* @__PURE__ */ new Set([
|
|
7999
8189
|
...this.stackArtifactIds(assetManifestArtifact.dependencies),
|
|
8000
8190
|
// If we disable prebuild, then assets inherit (stack) dependencies from their parent stack
|
|
@@ -8014,7 +8204,7 @@ var WorkGraphBuilder = class _WorkGraphBuilder {
|
|
|
8014
8204
|
this.graph.addNodes({
|
|
8015
8205
|
type: "asset-publish",
|
|
8016
8206
|
id: publishId,
|
|
8017
|
-
note:
|
|
8207
|
+
note: asset.displayName(true),
|
|
8018
8208
|
dependencies: /* @__PURE__ */ new Set([
|
|
8019
8209
|
buildId
|
|
8020
8210
|
]),
|
|
@@ -8086,8 +8276,8 @@ var WorkGraphBuilder = class _WorkGraphBuilder {
|
|
|
8086
8276
|
};
|
|
8087
8277
|
function stacksFromAssets(artifacts) {
|
|
8088
8278
|
const ret = /* @__PURE__ */ new Map();
|
|
8089
|
-
for (const stack of artifacts.filter(cxapi3.CloudFormationStackArtifact.isCloudFormationStackArtifact)) {
|
|
8090
|
-
const assetArtifacts = stack.dependencies.filter(cxapi3.AssetManifestArtifact.isAssetManifestArtifact);
|
|
8279
|
+
for (const stack of artifacts.filter((x) => cxapi3.CloudFormationStackArtifact.isCloudFormationStackArtifact(x))) {
|
|
8280
|
+
const assetArtifacts = stack.dependencies.filter((x) => cxapi3.AssetManifestArtifact.isAssetManifestArtifact(x));
|
|
8091
8281
|
for (const art of assetArtifacts) {
|
|
8092
8282
|
ret.set(art, stack);
|
|
8093
8283
|
}
|
|
@@ -8095,7 +8285,477 @@ function stacksFromAssets(artifacts) {
|
|
|
8095
8285
|
return ret;
|
|
8096
8286
|
}
|
|
8097
8287
|
function onlyStacks(artifacts) {
|
|
8098
|
-
return artifacts.filter(cxapi3.CloudFormationStackArtifact.isCloudFormationStackArtifact);
|
|
8288
|
+
return artifacts.filter((x) => cxapi3.CloudFormationStackArtifact.isCloudFormationStackArtifact(x));
|
|
8289
|
+
}
|
|
8290
|
+
|
|
8291
|
+
// ../../aws-cdk/lib/api/bootstrap/bootstrap-environment.ts
|
|
8292
|
+
var import_console = require("console");
|
|
8293
|
+
var path12 = __toESM(require("path"));
|
|
8294
|
+
|
|
8295
|
+
// ../../aws-cdk/lib/api/bootstrap/deploy-bootstrap.ts
|
|
8296
|
+
var os4 = __toESM(require("os"));
|
|
8297
|
+
var path11 = __toESM(require("path"));
|
|
8298
|
+
var import_cloud_assembly_schema2 = require("@aws-cdk/cloud-assembly-schema");
|
|
8299
|
+
var import_cx_api6 = require("@aws-cdk/cx-api");
|
|
8300
|
+
var fs14 = __toESM(require("fs-extra"));
|
|
8301
|
+
var BootstrapStack = class _BootstrapStack {
|
|
8302
|
+
constructor(sdkProvider, sdk, resolvedEnvironment, toolkitStackName, currentToolkitInfo, msg) {
|
|
8303
|
+
this.sdkProvider = sdkProvider;
|
|
8304
|
+
this.sdk = sdk;
|
|
8305
|
+
this.resolvedEnvironment = resolvedEnvironment;
|
|
8306
|
+
this.toolkitStackName = toolkitStackName;
|
|
8307
|
+
this.currentToolkitInfo = currentToolkitInfo;
|
|
8308
|
+
this.msg = msg;
|
|
8309
|
+
}
|
|
8310
|
+
static async lookup(sdkProvider, environment, toolkitStackName, msg) {
|
|
8311
|
+
toolkitStackName = toolkitStackName ?? DEFAULT_TOOLKIT_STACK_NAME;
|
|
8312
|
+
const resolvedEnvironment = await sdkProvider.resolveEnvironment(environment);
|
|
8313
|
+
const sdk = (await sdkProvider.forEnvironment(resolvedEnvironment, 1 /* ForWriting */)).sdk;
|
|
8314
|
+
const currentToolkitInfo = await ToolkitInfo.lookup(resolvedEnvironment, sdk, msg, toolkitStackName);
|
|
8315
|
+
return new _BootstrapStack(sdkProvider, sdk, resolvedEnvironment, toolkitStackName, currentToolkitInfo, msg);
|
|
8316
|
+
}
|
|
8317
|
+
get parameters() {
|
|
8318
|
+
return this.currentToolkitInfo.found ? this.currentToolkitInfo.bootstrapStack.parameters : {};
|
|
8319
|
+
}
|
|
8320
|
+
get terminationProtection() {
|
|
8321
|
+
return this.currentToolkitInfo.found ? this.currentToolkitInfo.bootstrapStack.terminationProtection : void 0;
|
|
8322
|
+
}
|
|
8323
|
+
async partition() {
|
|
8324
|
+
return (await this.sdk.currentAccount()).partition;
|
|
8325
|
+
}
|
|
8326
|
+
/**
|
|
8327
|
+
* Perform the actual deployment of a bootstrap stack, given a template and some parameters
|
|
8328
|
+
*/
|
|
8329
|
+
async update(template, parameters, options) {
|
|
8330
|
+
if (this.currentToolkitInfo.found && !options.force) {
|
|
8331
|
+
const abortResponse = {
|
|
8332
|
+
type: "did-deploy-stack",
|
|
8333
|
+
noOp: true,
|
|
8334
|
+
outputs: {},
|
|
8335
|
+
stackArn: this.currentToolkitInfo.bootstrapStack.stackId
|
|
8336
|
+
};
|
|
8337
|
+
const currentVariant = this.currentToolkitInfo.variant;
|
|
8338
|
+
const newVariant = bootstrapVariantFromTemplate(template);
|
|
8339
|
+
if (currentVariant !== newVariant) {
|
|
8340
|
+
await this.msg.ioHost.notify(warn(
|
|
8341
|
+
this.msg.action,
|
|
8342
|
+
`Bootstrap stack already exists, containing '${currentVariant}'. Not overwriting it with a template containing '${newVariant}' (use --force if you intend to overwrite)`
|
|
8343
|
+
));
|
|
8344
|
+
return abortResponse;
|
|
8345
|
+
}
|
|
8346
|
+
const newVersion = bootstrapVersionFromTemplate(template);
|
|
8347
|
+
const currentVersion = this.currentToolkitInfo.version;
|
|
8348
|
+
if (newVersion < currentVersion) {
|
|
8349
|
+
await this.msg.ioHost.notify(warn(
|
|
8350
|
+
this.msg.action,
|
|
8351
|
+
`Bootstrap stack already at version ${currentVersion}. Not downgrading it to version ${newVersion} (use --force if you intend to downgrade)`
|
|
8352
|
+
));
|
|
8353
|
+
if (newVersion === 0) {
|
|
8354
|
+
await this.msg.ioHost.notify(warn(
|
|
8355
|
+
this.msg.action,
|
|
8356
|
+
"(Did you set the '@aws-cdk/core:newStyleStackSynthesis' feature flag in cdk.json?)"
|
|
8357
|
+
));
|
|
8358
|
+
}
|
|
8359
|
+
return abortResponse;
|
|
8360
|
+
}
|
|
8361
|
+
}
|
|
8362
|
+
const outdir = await fs14.mkdtemp(path11.join(os4.tmpdir(), "cdk-bootstrap"));
|
|
8363
|
+
const builder = new import_cx_api6.CloudAssemblyBuilder(outdir);
|
|
8364
|
+
const templateFile = `${this.toolkitStackName}.template.json`;
|
|
8365
|
+
await fs14.writeJson(path11.join(builder.outdir, templateFile), template, {
|
|
8366
|
+
spaces: 2
|
|
8367
|
+
});
|
|
8368
|
+
builder.addArtifact(this.toolkitStackName, {
|
|
8369
|
+
type: import_cloud_assembly_schema2.ArtifactType.AWS_CLOUDFORMATION_STACK,
|
|
8370
|
+
environment: import_cx_api6.EnvironmentUtils.format(this.resolvedEnvironment.account, this.resolvedEnvironment.region),
|
|
8371
|
+
properties: {
|
|
8372
|
+
templateFile,
|
|
8373
|
+
terminationProtection: options.terminationProtection ?? false
|
|
8374
|
+
}
|
|
8375
|
+
});
|
|
8376
|
+
const assembly = builder.buildAssembly();
|
|
8377
|
+
const ret = await deployStack({
|
|
8378
|
+
stack: assembly.getStackByName(this.toolkitStackName),
|
|
8379
|
+
resolvedEnvironment: this.resolvedEnvironment,
|
|
8380
|
+
sdk: this.sdk,
|
|
8381
|
+
sdkProvider: this.sdkProvider,
|
|
8382
|
+
force: options.force,
|
|
8383
|
+
roleArn: options.roleArn,
|
|
8384
|
+
tags: options.tags,
|
|
8385
|
+
deploymentMethod: { method: "change-set", execute: options.execute },
|
|
8386
|
+
parameters,
|
|
8387
|
+
usePreviousParameters: options.usePreviousParameters ?? true,
|
|
8388
|
+
// Obviously we can't need a bootstrap stack to deploy a bootstrap stack
|
|
8389
|
+
envResources: new NoBootstrapStackEnvironmentResources(this.resolvedEnvironment, this.sdk, this.msg)
|
|
8390
|
+
}, this.msg);
|
|
8391
|
+
assertIsSuccessfulDeployStackResult(ret);
|
|
8392
|
+
return ret;
|
|
8393
|
+
}
|
|
8394
|
+
};
|
|
8395
|
+
function bootstrapVersionFromTemplate(template) {
|
|
8396
|
+
const versionSources = [
|
|
8397
|
+
template.Outputs?.[BOOTSTRAP_VERSION_OUTPUT]?.Value,
|
|
8398
|
+
template.Resources?.[BOOTSTRAP_VERSION_RESOURCE]?.Properties?.Value
|
|
8399
|
+
];
|
|
8400
|
+
for (const vs of versionSources) {
|
|
8401
|
+
if (typeof vs === "number") {
|
|
8402
|
+
return vs;
|
|
8403
|
+
}
|
|
8404
|
+
if (typeof vs === "string" && !isNaN(parseInt(vs, 10))) {
|
|
8405
|
+
return parseInt(vs, 10);
|
|
8406
|
+
}
|
|
8407
|
+
}
|
|
8408
|
+
return 0;
|
|
8409
|
+
}
|
|
8410
|
+
function bootstrapVariantFromTemplate(template) {
|
|
8411
|
+
return template.Parameters?.[BOOTSTRAP_VARIANT_PARAMETER]?.Default ?? DEFAULT_BOOTSTRAP_VARIANT;
|
|
8412
|
+
}
|
|
8413
|
+
|
|
8414
|
+
// ../../aws-cdk/lib/api/bootstrap/legacy-template.ts
|
|
8415
|
+
function legacyBootstrapTemplate(params) {
|
|
8416
|
+
return {
|
|
8417
|
+
Description: "The CDK Toolkit Stack. It was created by `cdk bootstrap` and manages resources necessary for managing your Cloud Applications with AWS CDK.",
|
|
8418
|
+
Conditions: {
|
|
8419
|
+
UsePublicAccessBlockConfiguration: {
|
|
8420
|
+
"Fn::Equals": [
|
|
8421
|
+
params.publicAccessBlockConfiguration || params.publicAccessBlockConfiguration === void 0 ? "true" : "false",
|
|
8422
|
+
"true"
|
|
8423
|
+
]
|
|
8424
|
+
}
|
|
8425
|
+
},
|
|
8426
|
+
Resources: {
|
|
8427
|
+
StagingBucket: {
|
|
8428
|
+
Type: "AWS::S3::Bucket",
|
|
8429
|
+
Properties: {
|
|
8430
|
+
BucketName: params.bucketName,
|
|
8431
|
+
AccessControl: "Private",
|
|
8432
|
+
BucketEncryption: {
|
|
8433
|
+
ServerSideEncryptionConfiguration: [{
|
|
8434
|
+
ServerSideEncryptionByDefault: {
|
|
8435
|
+
SSEAlgorithm: "aws:kms",
|
|
8436
|
+
KMSMasterKeyID: params.kmsKeyId
|
|
8437
|
+
}
|
|
8438
|
+
}]
|
|
8439
|
+
},
|
|
8440
|
+
PublicAccessBlockConfiguration: {
|
|
8441
|
+
"Fn::If": [
|
|
8442
|
+
"UsePublicAccessBlockConfiguration",
|
|
8443
|
+
{
|
|
8444
|
+
BlockPublicAcls: true,
|
|
8445
|
+
BlockPublicPolicy: true,
|
|
8446
|
+
IgnorePublicAcls: true,
|
|
8447
|
+
RestrictPublicBuckets: true
|
|
8448
|
+
},
|
|
8449
|
+
{ Ref: "AWS::NoValue" }
|
|
8450
|
+
]
|
|
8451
|
+
}
|
|
8452
|
+
}
|
|
8453
|
+
},
|
|
8454
|
+
StagingBucketPolicy: {
|
|
8455
|
+
Type: "AWS::S3::BucketPolicy",
|
|
8456
|
+
Properties: {
|
|
8457
|
+
Bucket: { Ref: "StagingBucket" },
|
|
8458
|
+
PolicyDocument: {
|
|
8459
|
+
Id: "AccessControl",
|
|
8460
|
+
Version: "2012-10-17",
|
|
8461
|
+
Statement: [
|
|
8462
|
+
{
|
|
8463
|
+
Sid: "AllowSSLRequestsOnly",
|
|
8464
|
+
Action: "s3:*",
|
|
8465
|
+
Effect: "Deny",
|
|
8466
|
+
Resource: [
|
|
8467
|
+
{ "Fn::Sub": "${StagingBucket.Arn}" },
|
|
8468
|
+
{ "Fn::Sub": "${StagingBucket.Arn}/*" }
|
|
8469
|
+
],
|
|
8470
|
+
Condition: {
|
|
8471
|
+
Bool: { "aws:SecureTransport": "false" }
|
|
8472
|
+
},
|
|
8473
|
+
Principal: "*"
|
|
8474
|
+
}
|
|
8475
|
+
]
|
|
8476
|
+
}
|
|
8477
|
+
}
|
|
8478
|
+
}
|
|
8479
|
+
},
|
|
8480
|
+
Outputs: {
|
|
8481
|
+
[BUCKET_NAME_OUTPUT]: {
|
|
8482
|
+
Description: "The name of the S3 bucket owned by the CDK toolkit stack",
|
|
8483
|
+
Value: { Ref: "StagingBucket" }
|
|
8484
|
+
},
|
|
8485
|
+
[BUCKET_DOMAIN_NAME_OUTPUT]: {
|
|
8486
|
+
Description: "The domain name of the S3 bucket owned by the CDK toolkit stack",
|
|
8487
|
+
Value: { "Fn::GetAtt": ["StagingBucket", "RegionalDomainName"] }
|
|
8488
|
+
}
|
|
8489
|
+
}
|
|
8490
|
+
};
|
|
8491
|
+
}
|
|
8492
|
+
|
|
8493
|
+
// ../../aws-cdk/lib/api/bootstrap/bootstrap-environment.ts
|
|
8494
|
+
var Bootstrapper = class {
|
|
8495
|
+
constructor(source = { source: "default" }, msg) {
|
|
8496
|
+
this.source = source;
|
|
8497
|
+
this.msg = msg;
|
|
8498
|
+
}
|
|
8499
|
+
bootstrapEnvironment(environment, sdkProvider, options = {}) {
|
|
8500
|
+
switch (this.source.source) {
|
|
8501
|
+
case "legacy":
|
|
8502
|
+
return this.legacyBootstrap(environment, sdkProvider, options);
|
|
8503
|
+
case "default":
|
|
8504
|
+
return this.modernBootstrap(environment, sdkProvider, options);
|
|
8505
|
+
case "custom":
|
|
8506
|
+
return this.customBootstrap(environment, sdkProvider, options);
|
|
8507
|
+
}
|
|
8508
|
+
}
|
|
8509
|
+
async showTemplate(json) {
|
|
8510
|
+
const template = await this.loadTemplate();
|
|
8511
|
+
process.stdout.write(`${serializeStructure(template, json)}
|
|
8512
|
+
`);
|
|
8513
|
+
}
|
|
8514
|
+
/**
|
|
8515
|
+
* Deploy legacy bootstrap stack
|
|
8516
|
+
*
|
|
8517
|
+
*/
|
|
8518
|
+
async legacyBootstrap(environment, sdkProvider, options = {}) {
|
|
8519
|
+
const params = options.parameters ?? {};
|
|
8520
|
+
if (params.trustedAccounts?.length) {
|
|
8521
|
+
throw new ToolkitError("--trust can only be passed for the modern bootstrap experience.");
|
|
8522
|
+
}
|
|
8523
|
+
if (params.cloudFormationExecutionPolicies?.length) {
|
|
8524
|
+
throw new ToolkitError("--cloudformation-execution-policies can only be passed for the modern bootstrap experience.");
|
|
8525
|
+
}
|
|
8526
|
+
if (params.createCustomerMasterKey !== void 0) {
|
|
8527
|
+
throw new ToolkitError("--bootstrap-customer-key can only be passed for the modern bootstrap experience.");
|
|
8528
|
+
}
|
|
8529
|
+
if (params.qualifier) {
|
|
8530
|
+
throw new ToolkitError("--qualifier can only be passed for the modern bootstrap experience.");
|
|
8531
|
+
}
|
|
8532
|
+
const toolkitStackName = options.toolkitStackName ?? DEFAULT_TOOLKIT_STACK_NAME;
|
|
8533
|
+
const current = await BootstrapStack.lookup(sdkProvider, environment, toolkitStackName, this.msg);
|
|
8534
|
+
return current.update(
|
|
8535
|
+
await this.loadTemplate(params),
|
|
8536
|
+
{},
|
|
8537
|
+
{
|
|
8538
|
+
...options,
|
|
8539
|
+
terminationProtection: options.terminationProtection ?? current.terminationProtection
|
|
8540
|
+
}
|
|
8541
|
+
);
|
|
8542
|
+
}
|
|
8543
|
+
/**
|
|
8544
|
+
* Deploy CI/CD-ready bootstrap stack from template
|
|
8545
|
+
*
|
|
8546
|
+
*/
|
|
8547
|
+
async modernBootstrap(environment, sdkProvider, options = {}) {
|
|
8548
|
+
const params = options.parameters ?? {};
|
|
8549
|
+
const bootstrapTemplate = await this.loadTemplate();
|
|
8550
|
+
const toolkitStackName = options.toolkitStackName ?? DEFAULT_TOOLKIT_STACK_NAME;
|
|
8551
|
+
const current = await BootstrapStack.lookup(sdkProvider, environment, toolkitStackName, this.msg);
|
|
8552
|
+
const partition = await current.partition();
|
|
8553
|
+
if (params.createCustomerMasterKey !== void 0 && params.kmsKeyId) {
|
|
8554
|
+
throw new ToolkitError(
|
|
8555
|
+
"You cannot pass '--bootstrap-kms-key-id' and '--bootstrap-customer-key' together. Specify one or the other"
|
|
8556
|
+
);
|
|
8557
|
+
}
|
|
8558
|
+
const allTrusted = /* @__PURE__ */ new Set([
|
|
8559
|
+
...params.trustedAccounts ?? [],
|
|
8560
|
+
...params.trustedAccountsForLookup ?? []
|
|
8561
|
+
]);
|
|
8562
|
+
const invalid = intersection(allTrusted, new Set(params.untrustedAccounts));
|
|
8563
|
+
if (invalid.size > 0) {
|
|
8564
|
+
throw new ToolkitError(`Accounts cannot be both trusted and untrusted. Found: ${[...invalid].join(",")}`);
|
|
8565
|
+
}
|
|
8566
|
+
const removeUntrusted = (accounts) => accounts.filter((acc) => !params.untrustedAccounts?.map(String).includes(String(acc)));
|
|
8567
|
+
const trustedAccounts = removeUntrusted(params.trustedAccounts ?? splitCfnArray(current.parameters.TrustedAccounts));
|
|
8568
|
+
(0, import_console.info)(`Trusted accounts for deployment: ${trustedAccounts.length > 0 ? trustedAccounts.join(", ") : "(none)"}`);
|
|
8569
|
+
const trustedAccountsForLookup = removeUntrusted(
|
|
8570
|
+
params.trustedAccountsForLookup ?? splitCfnArray(current.parameters.TrustedAccountsForLookup)
|
|
8571
|
+
);
|
|
8572
|
+
(0, import_console.info)(
|
|
8573
|
+
`Trusted accounts for lookup: ${trustedAccountsForLookup.length > 0 ? trustedAccountsForLookup.join(", ") : "(none)"}`
|
|
8574
|
+
);
|
|
8575
|
+
const cloudFormationExecutionPolicies = params.cloudFormationExecutionPolicies ?? splitCfnArray(current.parameters.CloudFormationExecutionPolicies);
|
|
8576
|
+
if (trustedAccounts.length === 0 && cloudFormationExecutionPolicies.length === 0) {
|
|
8577
|
+
const implicitPolicy = `arn:${partition}:iam::aws:policy/AdministratorAccess`;
|
|
8578
|
+
await this.msg.ioHost.notify(warn(
|
|
8579
|
+
this.msg.action,
|
|
8580
|
+
`Using default execution policy of '${implicitPolicy}'. Pass '--cloudformation-execution-policies' to customize.`
|
|
8581
|
+
));
|
|
8582
|
+
} else if (cloudFormationExecutionPolicies.length === 0) {
|
|
8583
|
+
throw new ToolkitError(
|
|
8584
|
+
`Please pass '--cloudformation-execution-policies' when using '--trust' to specify deployment permissions. Try a managed policy of the form 'arn:${partition}:iam::aws:policy/<PolicyName>'.`
|
|
8585
|
+
);
|
|
8586
|
+
} else {
|
|
8587
|
+
(0, import_console.info)(`Execution policies: ${cloudFormationExecutionPolicies.join(", ")}`);
|
|
8588
|
+
}
|
|
8589
|
+
const currentKmsKeyId = current.parameters.FileAssetsBucketKmsKeyId;
|
|
8590
|
+
const kmsKeyId = params.kmsKeyId ?? (params.createCustomerMasterKey === true ? CREATE_NEW_KEY : params.createCustomerMasterKey === false || currentKmsKeyId === void 0 ? USE_AWS_MANAGED_KEY : void 0);
|
|
8591
|
+
const currentPermissionsBoundary = current.parameters.InputPermissionsBoundary || void 0;
|
|
8592
|
+
const inputPolicyName = params.examplePermissionsBoundary ? CDK_BOOTSTRAP_PERMISSIONS_BOUNDARY : params.customPermissionsBoundary;
|
|
8593
|
+
let policyName;
|
|
8594
|
+
if (inputPolicyName) {
|
|
8595
|
+
const sdk = (await sdkProvider.forEnvironment(environment, 1 /* ForWriting */)).sdk;
|
|
8596
|
+
policyName = await this.getPolicyName(environment, sdk, inputPolicyName, partition, params);
|
|
8597
|
+
}
|
|
8598
|
+
if (currentPermissionsBoundary !== policyName) {
|
|
8599
|
+
if (!currentPermissionsBoundary) {
|
|
8600
|
+
await this.msg.ioHost.notify(warn(
|
|
8601
|
+
this.msg.action,
|
|
8602
|
+
`Adding new permissions boundary ${policyName}`
|
|
8603
|
+
));
|
|
8604
|
+
} else if (!policyName) {
|
|
8605
|
+
await this.msg.ioHost.notify(warn(
|
|
8606
|
+
this.msg.action,
|
|
8607
|
+
`Removing existing permissions boundary ${currentPermissionsBoundary}`
|
|
8608
|
+
));
|
|
8609
|
+
} else {
|
|
8610
|
+
await this.msg.ioHost.notify(warn(
|
|
8611
|
+
this.msg.action,
|
|
8612
|
+
`Changing permissions boundary from ${currentPermissionsBoundary} to ${policyName}`
|
|
8613
|
+
));
|
|
8614
|
+
}
|
|
8615
|
+
}
|
|
8616
|
+
return current.update(
|
|
8617
|
+
bootstrapTemplate,
|
|
8618
|
+
{
|
|
8619
|
+
FileAssetsBucketName: params.bucketName,
|
|
8620
|
+
FileAssetsBucketKmsKeyId: kmsKeyId,
|
|
8621
|
+
// Empty array becomes empty string
|
|
8622
|
+
TrustedAccounts: trustedAccounts.join(","),
|
|
8623
|
+
TrustedAccountsForLookup: trustedAccountsForLookup.join(","),
|
|
8624
|
+
CloudFormationExecutionPolicies: cloudFormationExecutionPolicies.join(","),
|
|
8625
|
+
Qualifier: params.qualifier,
|
|
8626
|
+
PublicAccessBlockConfiguration: params.publicAccessBlockConfiguration || params.publicAccessBlockConfiguration === void 0 ? "true" : "false",
|
|
8627
|
+
InputPermissionsBoundary: policyName
|
|
8628
|
+
},
|
|
8629
|
+
{
|
|
8630
|
+
...options,
|
|
8631
|
+
terminationProtection: options.terminationProtection ?? current.terminationProtection
|
|
8632
|
+
}
|
|
8633
|
+
);
|
|
8634
|
+
}
|
|
8635
|
+
async getPolicyName(environment, sdk, permissionsBoundary, partition, params) {
|
|
8636
|
+
if (permissionsBoundary !== CDK_BOOTSTRAP_PERMISSIONS_BOUNDARY) {
|
|
8637
|
+
this.validatePolicyName(permissionsBoundary);
|
|
8638
|
+
return Promise.resolve(permissionsBoundary);
|
|
8639
|
+
}
|
|
8640
|
+
const arn = await this.getExamplePermissionsBoundary(
|
|
8641
|
+
params.qualifier ?? "hnb659fds",
|
|
8642
|
+
partition,
|
|
8643
|
+
environment.account,
|
|
8644
|
+
sdk
|
|
8645
|
+
);
|
|
8646
|
+
const policyName = arn.split("/").pop();
|
|
8647
|
+
if (!policyName) {
|
|
8648
|
+
throw new ToolkitError("Could not retrieve the example permission boundary!");
|
|
8649
|
+
}
|
|
8650
|
+
return Promise.resolve(policyName);
|
|
8651
|
+
}
|
|
8652
|
+
async getExamplePermissionsBoundary(qualifier, partition, account, sdk) {
|
|
8653
|
+
const iam = sdk.iam();
|
|
8654
|
+
let policyName = `cdk-${qualifier}-permissions-boundary`;
|
|
8655
|
+
const arn = `arn:${partition}:iam::${account}:policy/${policyName}`;
|
|
8656
|
+
try {
|
|
8657
|
+
let getPolicyResp = await iam.getPolicy({ PolicyArn: arn });
|
|
8658
|
+
if (getPolicyResp.Policy) {
|
|
8659
|
+
return arn;
|
|
8660
|
+
}
|
|
8661
|
+
} catch (e) {
|
|
8662
|
+
if (e.name === "NoSuchEntity") {
|
|
8663
|
+
} else {
|
|
8664
|
+
throw e;
|
|
8665
|
+
}
|
|
8666
|
+
}
|
|
8667
|
+
const policyDoc = {
|
|
8668
|
+
Version: "2012-10-17",
|
|
8669
|
+
Statement: [
|
|
8670
|
+
{
|
|
8671
|
+
Action: ["*"],
|
|
8672
|
+
Resource: "*",
|
|
8673
|
+
Effect: "Allow",
|
|
8674
|
+
Sid: "ExplicitAllowAll"
|
|
8675
|
+
},
|
|
8676
|
+
{
|
|
8677
|
+
Condition: {
|
|
8678
|
+
StringEquals: {
|
|
8679
|
+
"iam:PermissionsBoundary": `arn:${partition}:iam::${account}:policy/cdk-${qualifier}-permissions-boundary`
|
|
8680
|
+
}
|
|
8681
|
+
},
|
|
8682
|
+
Action: [
|
|
8683
|
+
"iam:CreateUser",
|
|
8684
|
+
"iam:CreateRole",
|
|
8685
|
+
"iam:PutRolePermissionsBoundary",
|
|
8686
|
+
"iam:PutUserPermissionsBoundary"
|
|
8687
|
+
],
|
|
8688
|
+
Resource: "*",
|
|
8689
|
+
Effect: "Allow",
|
|
8690
|
+
Sid: "DenyAccessIfRequiredPermBoundaryIsNotBeingApplied"
|
|
8691
|
+
},
|
|
8692
|
+
{
|
|
8693
|
+
Action: [
|
|
8694
|
+
"iam:CreatePolicyVersion",
|
|
8695
|
+
"iam:DeletePolicy",
|
|
8696
|
+
"iam:DeletePolicyVersion",
|
|
8697
|
+
"iam:SetDefaultPolicyVersion"
|
|
8698
|
+
],
|
|
8699
|
+
Resource: `arn:${partition}:iam::${account}:policy/cdk-${qualifier}-permissions-boundary`,
|
|
8700
|
+
Effect: "Deny",
|
|
8701
|
+
Sid: "DenyPermBoundaryIAMPolicyAlteration"
|
|
8702
|
+
},
|
|
8703
|
+
{
|
|
8704
|
+
Action: ["iam:DeleteUserPermissionsBoundary", "iam:DeleteRolePermissionsBoundary"],
|
|
8705
|
+
Resource: "*",
|
|
8706
|
+
Effect: "Deny",
|
|
8707
|
+
Sid: "DenyRemovalOfPermBoundaryFromAnyUserOrRole"
|
|
8708
|
+
}
|
|
8709
|
+
]
|
|
8710
|
+
};
|
|
8711
|
+
const request = {
|
|
8712
|
+
PolicyName: policyName,
|
|
8713
|
+
PolicyDocument: JSON.stringify(policyDoc)
|
|
8714
|
+
};
|
|
8715
|
+
const createPolicyResponse = await iam.createPolicy(request);
|
|
8716
|
+
if (createPolicyResponse.Policy?.Arn) {
|
|
8717
|
+
return createPolicyResponse.Policy.Arn;
|
|
8718
|
+
} else {
|
|
8719
|
+
throw new ToolkitError(`Could not retrieve the example permission boundary ${arn}!`);
|
|
8720
|
+
}
|
|
8721
|
+
}
|
|
8722
|
+
validatePolicyName(permissionsBoundary) {
|
|
8723
|
+
const regexp = /[\w+\/=,.@-]+/;
|
|
8724
|
+
const matches = regexp.exec(permissionsBoundary);
|
|
8725
|
+
if (!(matches && matches.length === 1 && matches[0] === permissionsBoundary)) {
|
|
8726
|
+
throw new ToolkitError(`The permissions boundary name ${permissionsBoundary} does not match the IAM conventions.`);
|
|
8727
|
+
}
|
|
8728
|
+
}
|
|
8729
|
+
async customBootstrap(environment, sdkProvider, options = {}) {
|
|
8730
|
+
const version = bootstrapVersionFromTemplate(await this.loadTemplate());
|
|
8731
|
+
if (version === 0) {
|
|
8732
|
+
return this.legacyBootstrap(environment, sdkProvider, options);
|
|
8733
|
+
} else {
|
|
8734
|
+
return this.modernBootstrap(environment, sdkProvider, options);
|
|
8735
|
+
}
|
|
8736
|
+
}
|
|
8737
|
+
async loadTemplate(params = {}) {
|
|
8738
|
+
switch (this.source.source) {
|
|
8739
|
+
case "custom":
|
|
8740
|
+
return loadStructuredFile(this.source.templateFile);
|
|
8741
|
+
case "default":
|
|
8742
|
+
return loadStructuredFile(path12.join(bundledPackageRootDir(__dirname), "lib", "api", "bootstrap", "bootstrap-template.yaml"));
|
|
8743
|
+
case "legacy":
|
|
8744
|
+
return legacyBootstrapTemplate(params);
|
|
8745
|
+
}
|
|
8746
|
+
}
|
|
8747
|
+
};
|
|
8748
|
+
var USE_AWS_MANAGED_KEY = "AWS_MANAGED_KEY";
|
|
8749
|
+
var CREATE_NEW_KEY = "";
|
|
8750
|
+
var CDK_BOOTSTRAP_PERMISSIONS_BOUNDARY = "CDK_BOOTSTRAP_PERMISSIONS_BOUNDARY";
|
|
8751
|
+
function splitCfnArray(xs) {
|
|
8752
|
+
if (xs === "" || xs === void 0) {
|
|
8753
|
+
return [];
|
|
8754
|
+
}
|
|
8755
|
+
return xs.split(",");
|
|
8756
|
+
}
|
|
8757
|
+
function intersection(xs, ys) {
|
|
8758
|
+
return new Set(Array.from(xs).filter((x) => ys.has(x)));
|
|
8099
8759
|
}
|
|
8100
8760
|
|
|
8101
8761
|
// ../../aws-cdk/lib/context-providers/index.ts
|
|
@@ -8163,27 +8823,6 @@ var AZContextProviderPlugin = class {
|
|
|
8163
8823
|
}
|
|
8164
8824
|
};
|
|
8165
8825
|
|
|
8166
|
-
// ../../aws-cdk/lib/util/json.ts
|
|
8167
|
-
function getResultObj(jsonObject, identifier, propertiesToReturn) {
|
|
8168
|
-
const propsObj = {};
|
|
8169
|
-
propertiesToReturn.forEach((propName) => {
|
|
8170
|
-
Object.assign(propsObj, { [propName]: findJsonValue(jsonObject, propName) });
|
|
8171
|
-
});
|
|
8172
|
-
Object.assign(propsObj, { ["Identifier"]: identifier });
|
|
8173
|
-
return propsObj;
|
|
8174
|
-
}
|
|
8175
|
-
function findJsonValue(jsonObject, path12) {
|
|
8176
|
-
const paths = path12.split(".");
|
|
8177
|
-
let obj = jsonObject;
|
|
8178
|
-
paths.forEach((p) => {
|
|
8179
|
-
obj = obj[p];
|
|
8180
|
-
if (obj === void 0) {
|
|
8181
|
-
throw new TypeError(`Cannot read field ${path12}. ${p} is not found.`);
|
|
8182
|
-
}
|
|
8183
|
-
});
|
|
8184
|
-
return obj;
|
|
8185
|
-
}
|
|
8186
|
-
|
|
8187
8826
|
// ../../aws-cdk/lib/context-providers/cc-api-provider.ts
|
|
8188
8827
|
var CcApiContextProviderPlugin = class {
|
|
8189
8828
|
constructor(aws) {
|
|
@@ -8279,7 +8918,7 @@ var CcApiContextProviderPlugin = class {
|
|
|
8279
8918
|
}
|
|
8280
8919
|
});
|
|
8281
8920
|
} catch (err) {
|
|
8282
|
-
throw new ContextProviderError(`Could not get resources ${propertyMatch}. Error: ${err}`);
|
|
8921
|
+
throw new ContextProviderError(`Could not get resources ${JSON.stringify(propertyMatch)}. Error: ${err}`);
|
|
8283
8922
|
}
|
|
8284
8923
|
return resultObjs;
|
|
8285
8924
|
}
|
|
@@ -8416,7 +9055,7 @@ var KeyContextProviderPlugin = class {
|
|
|
8416
9055
|
};
|
|
8417
9056
|
|
|
8418
9057
|
// ../../aws-cdk/lib/context-providers/load-balancers.ts
|
|
8419
|
-
var
|
|
9058
|
+
var import_cx_api7 = require("@aws-cdk/cx-api");
|
|
8420
9059
|
var LoadBalancerContextProviderPlugin = class {
|
|
8421
9060
|
constructor(aws) {
|
|
8422
9061
|
this.aws = aws;
|
|
@@ -8426,7 +9065,7 @@ var LoadBalancerContextProviderPlugin = class {
|
|
|
8426
9065
|
throw new ContextProviderError("The load balancer lookup query must specify either `loadBalancerArn` or `loadBalancerTags`");
|
|
8427
9066
|
}
|
|
8428
9067
|
const loadBalancer = await (await LoadBalancerProvider.getClient(this.aws, query)).getLoadBalancer();
|
|
8429
|
-
const ipAddressType = loadBalancer.IpAddressType === "ipv4" ?
|
|
9068
|
+
const ipAddressType = loadBalancer.IpAddressType === "ipv4" ? import_cx_api7.LoadBalancerIpAddressType.IPV4 : import_cx_api7.LoadBalancerIpAddressType.DUAL_STACK;
|
|
8430
9069
|
return {
|
|
8431
9070
|
loadBalancerArn: loadBalancer.LoadBalancerArn,
|
|
8432
9071
|
loadBalancerCanonicalHostedZoneId: loadBalancer.CanonicalHostedZoneId,
|
|
@@ -8673,7 +9312,7 @@ var SSMContextProviderPlugin = class {
|
|
|
8673
9312
|
};
|
|
8674
9313
|
|
|
8675
9314
|
// ../../aws-cdk/lib/context-providers/vpcs.ts
|
|
8676
|
-
var
|
|
9315
|
+
var import_cx_api8 = require("@aws-cdk/cx-api");
|
|
8677
9316
|
var VpcNetworkContextProviderPlugin = class {
|
|
8678
9317
|
constructor(aws) {
|
|
8679
9318
|
this.aws = aws;
|
|
@@ -8910,11 +9549,11 @@ function groupAsymmetricSubnets(subnets) {
|
|
|
8910
9549
|
function subnetTypeToVpcSubnetType(type) {
|
|
8911
9550
|
switch (type) {
|
|
8912
9551
|
case "Isolated" /* Isolated */:
|
|
8913
|
-
return
|
|
9552
|
+
return import_cx_api8.VpcSubnetGroupType.ISOLATED;
|
|
8914
9553
|
case "Private" /* Private */:
|
|
8915
|
-
return
|
|
9554
|
+
return import_cx_api8.VpcSubnetGroupType.PRIVATE;
|
|
8916
9555
|
case "Public" /* Public */:
|
|
8917
|
-
return
|
|
9556
|
+
return import_cx_api8.VpcSubnetGroupType.PUBLIC;
|
|
8918
9557
|
}
|
|
8919
9558
|
}
|
|
8920
9559
|
function isValidSubnetType(val) {
|
|
@@ -9008,13 +9647,13 @@ var availableContextProviders = {
|
|
|
9008
9647
|
|
|
9009
9648
|
// ../../aws-cdk/lib/api/util/rwlock.ts
|
|
9010
9649
|
var import_fs = require("fs");
|
|
9011
|
-
var
|
|
9650
|
+
var path13 = __toESM(require("path"));
|
|
9012
9651
|
var RWLock = class {
|
|
9013
9652
|
constructor(directory) {
|
|
9014
9653
|
this.directory = directory;
|
|
9015
9654
|
this.readCounter = 0;
|
|
9016
9655
|
this.pidString = `${process.pid}`;
|
|
9017
|
-
this.writerFile =
|
|
9656
|
+
this.writerFile = path13.join(this.directory, "synth.lock");
|
|
9018
9657
|
}
|
|
9019
9658
|
/**
|
|
9020
9659
|
* Acquire a writer lock.
|
|
@@ -9056,7 +9695,7 @@ var RWLock = class {
|
|
|
9056
9695
|
* is incremented "atomically" from the point of view of this PID.).
|
|
9057
9696
|
*/
|
|
9058
9697
|
readerFile() {
|
|
9059
|
-
return
|
|
9698
|
+
return path13.join(this.directory, `read.${this.pidString}.${++this.readCounter}.lock`);
|
|
9060
9699
|
}
|
|
9061
9700
|
/**
|
|
9062
9701
|
* Do the actual acquiring of a read lock.
|
|
@@ -9113,7 +9752,7 @@ var RWLock = class {
|
|
|
9113
9752
|
if (processExists(pid)) {
|
|
9114
9753
|
ret.push(pid);
|
|
9115
9754
|
} else {
|
|
9116
|
-
await deleteFile(
|
|
9755
|
+
await deleteFile(path13.join(this.directory, fname));
|
|
9117
9756
|
}
|
|
9118
9757
|
}
|
|
9119
9758
|
}
|
|
@@ -9132,7 +9771,7 @@ async function readFileIfExists(filename) {
|
|
|
9132
9771
|
}
|
|
9133
9772
|
var tmpCounter = 0;
|
|
9134
9773
|
async function writeFileAtomic(filename, contents) {
|
|
9135
|
-
await import_fs.promises.mkdir(
|
|
9774
|
+
await import_fs.promises.mkdir(path13.dirname(filename), { recursive: true });
|
|
9136
9775
|
const tmpFile = `${filename}.${process.pid}_${++tmpCounter}`;
|
|
9137
9776
|
await import_fs.promises.writeFile(tmpFile, contents, { encoding: "utf-8" });
|
|
9138
9777
|
await import_fs.promises.rename(tmpFile, filename);
|
|
@@ -9157,8 +9796,8 @@ function processExists(pid) {
|
|
|
9157
9796
|
}
|
|
9158
9797
|
|
|
9159
9798
|
// ../../aws-cdk/lib/api/cxapp/cloud-assembly.ts
|
|
9160
|
-
var
|
|
9161
|
-
var
|
|
9799
|
+
var import_cx_api9 = require("@aws-cdk/cx-api");
|
|
9800
|
+
var chalk16 = __toESM(require("chalk"));
|
|
9162
9801
|
var import_minimatch = require("minimatch");
|
|
9163
9802
|
var semver5 = __toESM(require("semver"));
|
|
9164
9803
|
var ExtendedStackSelection = /* @__PURE__ */ ((ExtendedStackSelection2) => {
|
|
@@ -9320,15 +9959,15 @@ var StackCollection = class _StackCollection {
|
|
|
9320
9959
|
for (const stack of this.stackArtifacts) {
|
|
9321
9960
|
for (const message of stack.messages) {
|
|
9322
9961
|
switch (message.level) {
|
|
9323
|
-
case
|
|
9962
|
+
case import_cx_api9.SynthesisMessageLevel.WARNING:
|
|
9324
9963
|
warnings = true;
|
|
9325
9964
|
await logger("warn", message);
|
|
9326
9965
|
break;
|
|
9327
|
-
case
|
|
9966
|
+
case import_cx_api9.SynthesisMessageLevel.ERROR:
|
|
9328
9967
|
errors = true;
|
|
9329
9968
|
await logger("error", message);
|
|
9330
9969
|
break;
|
|
9331
|
-
case
|
|
9970
|
+
case import_cx_api9.SynthesisMessageLevel.INFO:
|
|
9332
9971
|
await logger("info", message);
|
|
9333
9972
|
break;
|
|
9334
9973
|
}
|
|
@@ -9363,7 +10002,7 @@ function includeDownstreamStacks(selectedStacks, allStacks) {
|
|
|
9363
10002
|
}
|
|
9364
10003
|
} while (madeProgress);
|
|
9365
10004
|
if (added.length > 0) {
|
|
9366
|
-
info("Including depending stacks: %s",
|
|
10005
|
+
info("Including depending stacks: %s", chalk16.bold(added.join(", ")));
|
|
9367
10006
|
}
|
|
9368
10007
|
}
|
|
9369
10008
|
function includeUpstreamStacks(selectedStacks, allStacks) {
|
|
@@ -9382,7 +10021,7 @@ function includeUpstreamStacks(selectedStacks, allStacks) {
|
|
|
9382
10021
|
}
|
|
9383
10022
|
}
|
|
9384
10023
|
if (added.length > 0) {
|
|
9385
|
-
info("Including dependency stacks: %s",
|
|
10024
|
+
info("Including dependency stacks: %s", chalk16.bold(added.join(", ")));
|
|
9386
10025
|
}
|
|
9387
10026
|
}
|
|
9388
10027
|
function sanitizePatterns(patterns) {
|
|
@@ -9392,10 +10031,10 @@ function sanitizePatterns(patterns) {
|
|
|
9392
10031
|
}
|
|
9393
10032
|
|
|
9394
10033
|
// ../../aws-cdk/lib/api/cxapp/exec.ts
|
|
9395
|
-
var
|
|
10034
|
+
var path14 = __toESM(require("path"));
|
|
9396
10035
|
var cxschema4 = __toESM(require("@aws-cdk/cloud-assembly-schema"));
|
|
9397
10036
|
var cxapi5 = __toESM(require("@aws-cdk/cx-api"));
|
|
9398
|
-
var
|
|
10037
|
+
var fs16 = __toESM(require("fs-extra"));
|
|
9399
10038
|
var semver6 = __toESM(require("semver"));
|
|
9400
10039
|
async function prepareDefaultEnvironment(aws, logFn = debug) {
|
|
9401
10040
|
const env = {};
|
|
@@ -9451,14 +10090,14 @@ async function guessExecutable(app) {
|
|
|
9451
10090
|
if (commandLine.length === 1) {
|
|
9452
10091
|
let fstat;
|
|
9453
10092
|
try {
|
|
9454
|
-
fstat = await
|
|
10093
|
+
fstat = await fs16.stat(commandLine[0]);
|
|
9455
10094
|
} catch {
|
|
9456
10095
|
debug(`Not a file: '${commandLine[0]}'. Using '${commandLine}' as command-line`);
|
|
9457
10096
|
return commandLine;
|
|
9458
10097
|
}
|
|
9459
|
-
const isExecutable = (fstat.mode &
|
|
10098
|
+
const isExecutable = (fstat.mode & fs16.constants.X_OK) !== 0;
|
|
9460
10099
|
const isWindows = process.platform === "win32";
|
|
9461
|
-
const handler = EXTENSION_MAP.get(
|
|
10100
|
+
const handler = EXTENSION_MAP.get(path14.extname(commandLine[0]));
|
|
9462
10101
|
if (handler && (!isExecutable || isWindows)) {
|
|
9463
10102
|
return handler(commandLine[0]);
|
|
9464
10103
|
}
|
|
@@ -9472,6 +10111,7 @@ function spaceAvailableForContext(env, limit) {
|
|
|
9472
10111
|
}
|
|
9473
10112
|
// Annotate the CommonJS export names for ESM import in node:
|
|
9474
10113
|
0 && (module.exports = {
|
|
10114
|
+
Bootstrapper,
|
|
9475
10115
|
CliIoHost,
|
|
9476
10116
|
CloudAssembly,
|
|
9477
10117
|
CloudWatchLogEventMonitor,
|
|
@@ -9487,26 +10127,19 @@ function spaceAvailableForContext(env, limit) {
|
|
|
9487
10127
|
ResourceMigrator,
|
|
9488
10128
|
SdkProvider,
|
|
9489
10129
|
Settings,
|
|
9490
|
-
StackActivityProgress,
|
|
9491
10130
|
StackCollection,
|
|
9492
10131
|
WorkGraphBuilder,
|
|
9493
10132
|
contextproviders,
|
|
9494
10133
|
findCloudWatchLogGroups,
|
|
9495
|
-
formatErrorMessage,
|
|
9496
10134
|
formatSdkLoggerContent,
|
|
9497
|
-
formatTime,
|
|
9498
10135
|
guessExecutable,
|
|
9499
10136
|
loadTree,
|
|
9500
|
-
obscureTemplate,
|
|
9501
10137
|
prepareContext,
|
|
9502
10138
|
prepareDefaultEnvironment,
|
|
9503
10139
|
sanitizePatterns,
|
|
9504
|
-
serializeStructure,
|
|
9505
10140
|
some,
|
|
9506
10141
|
spaceAvailableForContext,
|
|
9507
|
-
splitBySize,
|
|
9508
10142
|
tagsForStack,
|
|
9509
|
-
validateSnsTopicArn,
|
|
9510
10143
|
versionNumber
|
|
9511
10144
|
});
|
|
9512
10145
|
//# sourceMappingURL=aws-cdk.js.map
|