cdk-local 0.167.0 → 0.167.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/internal.d.ts +5 -2
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +2 -2
- package/dist/{local-studio-DRE1RQLn.js → local-studio-B0Wlk_VO.js} +689 -241
- package/dist/local-studio-B0Wlk_VO.js.map +1 -0
- package/dist/{local-studio-D6Qd0GIc.d.ts → local-studio-DDUOz4HF.d.ts} +10 -2
- package/dist/local-studio-DDUOz4HF.d.ts.map +1 -0
- package/package.json +1 -1
- package/dist/local-studio-D6Qd0GIc.d.ts.map +0 -1
- package/dist/local-studio-DRE1RQLn.js.map +0 -1
|
@@ -2457,9 +2457,26 @@ async function resolveDynamicReferencesInEnv(env, options) {
|
|
|
2457
2457
|
}
|
|
2458
2458
|
}
|
|
2459
2459
|
|
|
2460
|
+
// src/utils/ambient-default-region.ts
|
|
2461
|
+
let recorded;
|
|
2462
|
+
function setAmbientDefaultRegion(region) {
|
|
2463
|
+
recorded = region === "" ? void 0 : region;
|
|
2464
|
+
}
|
|
2465
|
+
function ambientDefaultRegion() {
|
|
2466
|
+
return recorded !== void 0 && process.env["AWS_REGION"] === recorded ? recorded : void 0;
|
|
2467
|
+
}
|
|
2468
|
+
function namedEnvAwsRegion() {
|
|
2469
|
+
return ambientDefaultRegion() === void 0 ? process.env["AWS_REGION"] : void 0;
|
|
2470
|
+
}
|
|
2471
|
+
function regionOrAmbientDefault(stackRegion) {
|
|
2472
|
+
const ambient = ambientDefaultRegion();
|
|
2473
|
+
if (ambient === void 0) return stackRegion;
|
|
2474
|
+
return stackRegion === void 0 || stackRegion === "" || stackRegion === "unknown-region" ? ambient : stackRegion;
|
|
2475
|
+
}
|
|
2476
|
+
|
|
2460
2477
|
// src/utils/profile-region.ts
|
|
2461
2478
|
async function resolveContainerRegion(sources) {
|
|
2462
|
-
const named = firstUsableRegion(sources.region,
|
|
2479
|
+
const named = firstUsableRegion(sources.region, namedEnvAwsRegion(), process.env["AWS_DEFAULT_REGION"], sources.stackRegion, sources.stateRegion, ambientDefaultRegion());
|
|
2463
2480
|
if (named) return named.toLowerCase();
|
|
2464
2481
|
return firstUsableRegion(await resolveSdkDefaultRegion(sources.profile))?.toLowerCase();
|
|
2465
2482
|
}
|
|
@@ -2485,6 +2502,32 @@ async function resolveProfileRegion(profile) {
|
|
|
2485
2502
|
return resolveSdkDefaultRegion(profile);
|
|
2486
2503
|
}
|
|
2487
2504
|
|
|
2505
|
+
// src/utils/shutdown-signal.ts
|
|
2506
|
+
function signalExitCode(signal) {
|
|
2507
|
+
return signal === "SIGINT" ? 130 : 143;
|
|
2508
|
+
}
|
|
2509
|
+
function createShutdownSignalHandler(options) {
|
|
2510
|
+
const exit = options.exit ?? ((code) => process.exit(code));
|
|
2511
|
+
const writeStderr = options.writeStderr ?? ((text) => void process.stderr.write(text));
|
|
2512
|
+
let count = 0;
|
|
2513
|
+
const handler = (signal, exitCode) => {
|
|
2514
|
+
const code = exitCode ?? signalExitCode(signal === "SIGINT" ? "SIGINT" : "SIGTERM");
|
|
2515
|
+
count += 1;
|
|
2516
|
+
if (count === 1) {
|
|
2517
|
+
options.info(options.stoppingMessage(signal));
|
|
2518
|
+
options.cleanup().then(() => exit(code));
|
|
2519
|
+
return;
|
|
2520
|
+
}
|
|
2521
|
+
if (count === 2) {
|
|
2522
|
+
options.warn(`Received ${signal} again; still shutting down — waiting for the cleanup to remove the containers and networks. Send it once more to force-exit (that skips the cleanup).`);
|
|
2523
|
+
return;
|
|
2524
|
+
}
|
|
2525
|
+
writeStderr(`Force-exit on repeated ${signal}; container cleanup skipped. ${options.forceExitHint}\n`);
|
|
2526
|
+
exit(code);
|
|
2527
|
+
};
|
|
2528
|
+
return handler;
|
|
2529
|
+
}
|
|
2530
|
+
|
|
2488
2531
|
// src/utils/error-handler.ts
|
|
2489
2532
|
var CdkLocalError = class CdkLocalError extends Error {
|
|
2490
2533
|
code;
|
|
@@ -5678,7 +5721,7 @@ function hostStateSourceFields(options, extraStateProviders) {
|
|
|
5678
5721
|
return { ...options };
|
|
5679
5722
|
}
|
|
5680
5723
|
function resolveCfnRegion(options, synthRegion) {
|
|
5681
|
-
const region = options.stackRegion ?? options.region ??
|
|
5724
|
+
const region = options.stackRegion ?? options.region ?? namedEnvAwsRegion() ?? process.env["AWS_DEFAULT_REGION"] ?? regionOrAmbientDefault(synthRegion);
|
|
5682
5725
|
if (region === void 0) throw new LocalStateSourceError("--from-cfn-stack requires a region to query CloudFormation. Set one of: --stack-region <region>, --region <region>, AWS_REGION env var, AWS_DEFAULT_REGION env var, or an env.region on the target CDK stack.");
|
|
5683
5726
|
return region;
|
|
5684
5727
|
}
|
|
@@ -6297,7 +6340,15 @@ async function substituteAgainstStateAsync(value, contextOrResources) {
|
|
|
6297
6340
|
};
|
|
6298
6341
|
const intrinsic = keys[0];
|
|
6299
6342
|
const arg = obj[intrinsic];
|
|
6300
|
-
if (intrinsic === "Ref" || intrinsic === "Fn::GetAtt" || intrinsic === "Fn::Sub" || intrinsic === "Fn::Join" || intrinsic === "Fn::Select" || intrinsic === "Fn::Split")
|
|
6343
|
+
if (intrinsic === "Ref" || intrinsic === "Fn::GetAtt" || intrinsic === "Fn::Sub" || intrinsic === "Fn::Join" || intrinsic === "Fn::Select" || intrinsic === "Fn::Split") {
|
|
6344
|
+
if (!containsCrossStackIntrinsic(value)) return substituteAgainstState(value, context);
|
|
6345
|
+
const rewritten = await resolveNestedCrossStack(value, context);
|
|
6346
|
+
if ("reason" in rewritten) return {
|
|
6347
|
+
kind: "unresolved",
|
|
6348
|
+
reason: rewritten.reason
|
|
6349
|
+
};
|
|
6350
|
+
return substituteAgainstState(rewritten.value, context);
|
|
6351
|
+
}
|
|
6301
6352
|
if (intrinsic === "Fn::ImportValue") return resolveImportValueAsync(arg, context);
|
|
6302
6353
|
if (intrinsic === "Fn::GetStackOutput") return resolveGetStackOutputAsync(arg, context);
|
|
6303
6354
|
return {
|
|
@@ -6305,6 +6356,39 @@ async function substituteAgainstStateAsync(value, contextOrResources) {
|
|
|
6305
6356
|
reason: `unsupported intrinsic ${displayIdent(intrinsic)} (supported: Ref, Fn::GetAtt, Fn::Sub, Fn::Join, Fn::Select, Fn::Split, Fn::ImportValue, Fn::GetStackOutput)`
|
|
6306
6357
|
};
|
|
6307
6358
|
}
|
|
6359
|
+
function isCrossStackNode(value) {
|
|
6360
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
6361
|
+
return Object.hasOwn(value, "Fn::ImportValue") || Object.hasOwn(value, "Fn::GetStackOutput");
|
|
6362
|
+
}
|
|
6363
|
+
function containsCrossStackIntrinsic(value) {
|
|
6364
|
+
if (value === null || typeof value !== "object") return false;
|
|
6365
|
+
if (Array.isArray(value)) return value.some(containsCrossStackIntrinsic);
|
|
6366
|
+
if (isCrossStackNode(value)) return true;
|
|
6367
|
+
return Object.values(value).some(containsCrossStackIntrinsic);
|
|
6368
|
+
}
|
|
6369
|
+
async function resolveNestedCrossStack(value, context) {
|
|
6370
|
+
if (!containsCrossStackIntrinsic(value)) return { value };
|
|
6371
|
+
if (isCrossStackNode(value)) {
|
|
6372
|
+
const sub = await substituteAgainstStateAsync(value, context);
|
|
6373
|
+
return sub.kind === "literal" ? { value: sub.value } : { reason: sub.reason };
|
|
6374
|
+
}
|
|
6375
|
+
if (Array.isArray(value)) {
|
|
6376
|
+
const out = [];
|
|
6377
|
+
for (const item of value) {
|
|
6378
|
+
const r = await resolveNestedCrossStack(item, context);
|
|
6379
|
+
if ("reason" in r) return r;
|
|
6380
|
+
out.push(r.value);
|
|
6381
|
+
}
|
|
6382
|
+
return { value: out };
|
|
6383
|
+
}
|
|
6384
|
+
const out = {};
|
|
6385
|
+
for (const [key, item] of Object.entries(value)) {
|
|
6386
|
+
const r = await resolveNestedCrossStack(item, context);
|
|
6387
|
+
if ("reason" in r) return r;
|
|
6388
|
+
defineOwnKey(out, key, r.value);
|
|
6389
|
+
}
|
|
6390
|
+
return { value: out };
|
|
6391
|
+
}
|
|
6308
6392
|
async function resolveImportValueAsync(arg, context) {
|
|
6309
6393
|
const inner = substituteAgainstState(arg, context);
|
|
6310
6394
|
if (inner.kind !== "literal") return {
|
|
@@ -6637,6 +6721,12 @@ function detectEcsImageResolutionNeeds(stack) {
|
|
|
6637
6721
|
if (need.pseudo) needsPseudoParameters = true;
|
|
6638
6722
|
if (need.state) needsStateResources = true;
|
|
6639
6723
|
if (containerHasIntrinsicEnvOrSecret(co)) needsEnvOrSecretSubstitution = true;
|
|
6724
|
+
const argv = containerArgvElements(co);
|
|
6725
|
+
if (argv.some((v) => v !== null && typeof v === "object")) needsEnvOrSecretSubstitution = true;
|
|
6726
|
+
if (argv.some(isCrossStackIntrinsic)) {
|
|
6727
|
+
needsEnvOrSecretSubstitution = true;
|
|
6728
|
+
needsCrossStackResolver = true;
|
|
6729
|
+
}
|
|
6640
6730
|
if (containerHasCrossStackEnvOrSecret(co)) {
|
|
6641
6731
|
needsEnvOrSecretSubstitution = true;
|
|
6642
6732
|
needsCrossStackResolver = true;
|
|
@@ -6675,10 +6765,16 @@ function containerHasCrossStackEnvOrSecret(c) {
|
|
|
6675
6765
|
}
|
|
6676
6766
|
return false;
|
|
6677
6767
|
}
|
|
6768
|
+
function containerArgvElements(c) {
|
|
6769
|
+
const health = c["HealthCheck"];
|
|
6770
|
+
return [
|
|
6771
|
+
c["Command"],
|
|
6772
|
+
c["EntryPoint"],
|
|
6773
|
+
health && typeof health === "object" ? health["Command"] : void 0
|
|
6774
|
+
].flatMap((l) => Array.isArray(l) ? l : []);
|
|
6775
|
+
}
|
|
6678
6776
|
function isCrossStackIntrinsic(value) {
|
|
6679
|
-
|
|
6680
|
-
const obj = value;
|
|
6681
|
-
return "Fn::ImportValue" in obj || "Fn::GetStackOutput" in obj;
|
|
6777
|
+
return containsCrossStackIntrinsic(value);
|
|
6682
6778
|
}
|
|
6683
6779
|
function volumeHasIntrinsicSourcePath(v) {
|
|
6684
6780
|
if (!v || typeof v !== "object") return false;
|
|
@@ -6910,10 +7006,13 @@ function parseContainerDefinition(raw, idx, taskLogicalId, resources, stack, con
|
|
|
6910
7006
|
const name = pickString(c["Name"]);
|
|
6911
7007
|
if (!name) throw new EcsTaskResolutionError(`Task ${displayIdent(taskLogicalId)} ContainerDefinitions[${idx}] has no Name.`);
|
|
6912
7008
|
const image = parseContainerImage(c["Image"], name, taskLogicalId, resources, stack, context);
|
|
6913
|
-
const
|
|
6914
|
-
const
|
|
7009
|
+
const containerContext = contextForContainer(context, name);
|
|
7010
|
+
const subContext = buildSubstitutionContextFromImageContext(containerContext);
|
|
7011
|
+
const unresolvedCommandElements = [];
|
|
7012
|
+
const argv = (raw, field) => resolveArgvArray(raw, field, subContext, containerContext, unresolvedCommandElements);
|
|
7013
|
+
const command = argv(c["Command"], "Command");
|
|
7014
|
+
const entryPoint = argv(c["EntryPoint"], "EntryPoint");
|
|
6915
7015
|
const workingDirectory = pickString(c["WorkingDirectory"]);
|
|
6916
|
-
const subContext = buildSubstitutionContextFromImageContext(contextForContainer(context, name));
|
|
6917
7016
|
const environment = {};
|
|
6918
7017
|
const sensitiveEnvKeys = [];
|
|
6919
7018
|
const droppedEnvKeys = [];
|
|
@@ -7027,7 +7126,7 @@ function parseContainerDefinition(raw, idx, taskLogicalId, resources, stack, con
|
|
|
7027
7126
|
let healthCheck;
|
|
7028
7127
|
if (c["HealthCheck"] && typeof c["HealthCheck"] === "object") {
|
|
7029
7128
|
const h = c["HealthCheck"];
|
|
7030
|
-
const command2 =
|
|
7129
|
+
const command2 = argv(h["Command"], "HealthCheck.Command");
|
|
7031
7130
|
if (command2 && command2.length > 0) {
|
|
7032
7131
|
healthCheck = { command: command2 };
|
|
7033
7132
|
if (typeof h["Interval"] === "number") healthCheck.interval = h["Interval"];
|
|
@@ -7079,8 +7178,150 @@ function parseContainerDefinition(raw, idx, taskLogicalId, resources, stack, con
|
|
|
7079
7178
|
if (user !== void 0) out.user = user;
|
|
7080
7179
|
if (privileged !== void 0) out.privileged = privileged;
|
|
7081
7180
|
if (readonlyRootFilesystem !== void 0) out.readonlyRootFilesystem = readonlyRootFilesystem;
|
|
7181
|
+
if (unresolvedCommandElements.length > 0) out.unresolvedCommandElements = unresolvedCommandElements;
|
|
7082
7182
|
return out;
|
|
7083
7183
|
}
|
|
7184
|
+
function resolveArgvArray(raw, field, subContext, context, unresolved) {
|
|
7185
|
+
if (!Array.isArray(raw)) return void 0;
|
|
7186
|
+
return raw.map((element, index) => {
|
|
7187
|
+
if (typeof element === "string") return element;
|
|
7188
|
+
if (typeof element === "number" || typeof element === "boolean") return String(element);
|
|
7189
|
+
if (!element || typeof element !== "object" || Array.isArray(element)) {
|
|
7190
|
+
unresolved.push({
|
|
7191
|
+
field,
|
|
7192
|
+
index,
|
|
7193
|
+
reason: "not a string or an intrinsic"
|
|
7194
|
+
});
|
|
7195
|
+
return "";
|
|
7196
|
+
}
|
|
7197
|
+
if (isCrossStackIntrinsic(element)) {
|
|
7198
|
+
unresolved.push({
|
|
7199
|
+
field,
|
|
7200
|
+
index,
|
|
7201
|
+
reason: CROSS_STACK_ARGV_REASON
|
|
7202
|
+
});
|
|
7203
|
+
return "";
|
|
7204
|
+
}
|
|
7205
|
+
if (!subContext) {
|
|
7206
|
+
unresolved.push({
|
|
7207
|
+
field,
|
|
7208
|
+
index,
|
|
7209
|
+
reason: `intrinsic-valued and no deployed state was loaded: ${formatStateRemedy(context)}`
|
|
7210
|
+
});
|
|
7211
|
+
return "";
|
|
7212
|
+
}
|
|
7213
|
+
const secret = secretAttributeRead(element, subContext.resources);
|
|
7214
|
+
if (secret !== void 0) {
|
|
7215
|
+
unresolved.push({
|
|
7216
|
+
field,
|
|
7217
|
+
index,
|
|
7218
|
+
reason: secret
|
|
7219
|
+
});
|
|
7220
|
+
return "";
|
|
7221
|
+
}
|
|
7222
|
+
const { result: sub, consumedSensitive } = resolveWithSensitivity(element, subContext);
|
|
7223
|
+
const arg = argvValue(sub, consumedSensitive);
|
|
7224
|
+
if ("value" in arg) return arg.value;
|
|
7225
|
+
unresolved.push({
|
|
7226
|
+
field,
|
|
7227
|
+
index,
|
|
7228
|
+
reason: arg.reason
|
|
7229
|
+
});
|
|
7230
|
+
return "";
|
|
7231
|
+
});
|
|
7232
|
+
}
|
|
7233
|
+
const STATE_SECRET_MASK = "***";
|
|
7234
|
+
const SECRET_ATTRIBUTE_NAME = /secret|password|credential/i;
|
|
7235
|
+
const NON_SECRET_ATTRIBUTE_SUFFIX = /(arn|id|name|url|alias|status)$/i;
|
|
7236
|
+
const SECRET_VALUED_ATTRIBUTES = /* @__PURE__ */ new Map([
|
|
7237
|
+
["AWS::AppSync::ApiKey", ["ApiKey"]],
|
|
7238
|
+
["AWS::EC2::IpamExternalResourceVerificationToken", ["TokenValue"]],
|
|
7239
|
+
["AWS::IVS::StreamKey", ["Value"]]
|
|
7240
|
+
]);
|
|
7241
|
+
function secretAttributeRead(element, stateResources) {
|
|
7242
|
+
for (const [logicalId, attribute] of getAttReads(element)) {
|
|
7243
|
+
const record = Object.hasOwn(stateResources, logicalId) ? stateResources[logicalId] : void 0;
|
|
7244
|
+
const recorded = record?.attributes;
|
|
7245
|
+
const stored = recorded && Object.hasOwn(recorded, attribute) ? recorded[attribute] : void 0;
|
|
7246
|
+
const type = typeof record?.resourceType === "string" ? record.resourceType : "";
|
|
7247
|
+
const typed = SECRET_VALUED_ATTRIBUTES.get(type);
|
|
7248
|
+
if (SECRET_ATTRIBUTE_NAME.test(attribute) && !NON_SECRET_ATTRIBUTE_SUFFIX.test(attribute) || typed?.includes(attribute) === true || type.startsWith("Custom::") || type === "AWS::CloudFormation::CustomResource" || type === "AWS::CloudFormation::Stack" && attribute.startsWith("Outputs.") || stored === STATE_SECRET_MASK) return `reads ${displayIdent(logicalId)}.${displayIdent(attribute)}, an attribute that is or may be a secret, which ${getEmbedConfig().binaryName} will not put on the docker run command line; pass the value through Environment or Secrets instead`;
|
|
7249
|
+
}
|
|
7250
|
+
}
|
|
7251
|
+
function getAttReads(node, out = []) {
|
|
7252
|
+
if (node === null || typeof node !== "object") return out;
|
|
7253
|
+
if (Array.isArray(node)) {
|
|
7254
|
+
for (const item of node) getAttReads(item, out);
|
|
7255
|
+
return out;
|
|
7256
|
+
}
|
|
7257
|
+
for (const [key, value] of Object.entries(node)) {
|
|
7258
|
+
if (key === "Fn::GetAtt") {
|
|
7259
|
+
if (Array.isArray(value) && typeof value[0] === "string" && typeof value[1] === "string") out.push([value[0], value[1]]);
|
|
7260
|
+
else if (typeof value === "string" && value.includes(".")) {
|
|
7261
|
+
const dot = value.indexOf(".");
|
|
7262
|
+
out.push([value.slice(0, dot), value.slice(dot + 1)]);
|
|
7263
|
+
}
|
|
7264
|
+
} else if (key === "Fn::Sub") {
|
|
7265
|
+
const template = Array.isArray(value) ? value[0] : value;
|
|
7266
|
+
if (typeof template === "string") for (const m of template.matchAll(/\$\{([^}!][^}]*)\}/g)) {
|
|
7267
|
+
const ref = m[1].trim();
|
|
7268
|
+
const dot = ref.indexOf(".");
|
|
7269
|
+
if (dot > 0 && !ref.startsWith("AWS::")) out.push([ref.slice(0, dot), ref.slice(dot + 1)]);
|
|
7270
|
+
}
|
|
7271
|
+
}
|
|
7272
|
+
getAttReads(value, out);
|
|
7273
|
+
}
|
|
7274
|
+
return out;
|
|
7275
|
+
}
|
|
7276
|
+
function computedAttributeRead(node) {
|
|
7277
|
+
if (node === null || typeof node !== "object") return void 0;
|
|
7278
|
+
if (Array.isArray(node)) {
|
|
7279
|
+
for (const item of node) {
|
|
7280
|
+
const r = computedAttributeRead(item);
|
|
7281
|
+
if (r !== void 0) return r;
|
|
7282
|
+
}
|
|
7283
|
+
return;
|
|
7284
|
+
}
|
|
7285
|
+
for (const [key, value] of Object.entries(node)) {
|
|
7286
|
+
if (key === "Fn::GetAtt" && isCrossStackIntrinsic(value)) return "a Fn::GetAtt whose logical ID or attribute name is a cross-stack reference, which CloudFormation does not accept";
|
|
7287
|
+
if (key === "Fn::Sub") {
|
|
7288
|
+
if (isCrossStackIntrinsic(Array.isArray(value) ? value[0] : value)) return "a Fn::Sub whose template is a cross-stack reference, which CloudFormation does not accept";
|
|
7289
|
+
}
|
|
7290
|
+
const r = computedAttributeRead(value);
|
|
7291
|
+
if (r !== void 0) return r;
|
|
7292
|
+
}
|
|
7293
|
+
}
|
|
7294
|
+
function withMaskWatch(context, masked) {
|
|
7295
|
+
const inner = context.crossStackResolver;
|
|
7296
|
+
if (!inner) return context;
|
|
7297
|
+
const watch = (v) => {
|
|
7298
|
+
if (v === STATE_SECRET_MASK) masked.hit = true;
|
|
7299
|
+
return v;
|
|
7300
|
+
};
|
|
7301
|
+
return {
|
|
7302
|
+
...context,
|
|
7303
|
+
crossStackResolver: {
|
|
7304
|
+
resolveImport: async (exportName) => watch(await inner.resolveImport(exportName)),
|
|
7305
|
+
resolveGetStackOutput: async (stack, region, output) => watch(await inner.resolveGetStackOutput(stack, region, output))
|
|
7306
|
+
}
|
|
7307
|
+
};
|
|
7308
|
+
}
|
|
7309
|
+
const CROSS_STACK_ARGV_REASON = "a cross-stack reference (Fn::ImportValue / Fn::GetStackOutput): it resolves only from a state source with the producer stack deployed";
|
|
7310
|
+
function argvValue(sub, consumedSensitive) {
|
|
7311
|
+
if (consumedSensitive) return { reason: "resolved from a SecureString parameter, which would put the secret on the docker run argv; move the value into an Environment variable or a Secrets entry" };
|
|
7312
|
+
if (sub.kind !== "literal") return { reason: sub.reason };
|
|
7313
|
+
const value = sub.value;
|
|
7314
|
+
if (typeof value === "number" || typeof value === "boolean") return { value: String(value) };
|
|
7315
|
+
if (value === STATE_SECRET_MASK) return { reason: "resolved to the secret mask (***), not the deployed value" };
|
|
7316
|
+
if (containsDynamicReference(value)) return { reason: "resolved to a CloudFormation dynamic reference ({{resolve:...}}), which is resolved only in Environment, because resolving one here would put the secret on the docker run argv; move the value into an Environment variable or a Secrets entry" };
|
|
7317
|
+
return { value };
|
|
7318
|
+
}
|
|
7319
|
+
function assertEcsTaskCommandsResolved(task) {
|
|
7320
|
+
const lines = [];
|
|
7321
|
+
for (const container of task.containers) for (const u of container.unresolvedCommandElements ?? []) lines.push(` - Container ${displayIdent(container.name)} ${u.field}[${u.index}]: ${u.reason}`);
|
|
7322
|
+
if (lines.length === 0) return;
|
|
7323
|
+
throw new EcsTaskResolutionError(`Task ${displayIdent(task.taskDefinitionLogicalId)} has container command elements ${getEmbedConfig().binaryName} could not resolve:\n${lines.join("\n")}\nRefusing to run the task with these arguments missing, since that runs a different command than the deployed task.`);
|
|
7324
|
+
}
|
|
7084
7325
|
function buildSubstitutionContextFromImageContext(context) {
|
|
7085
7326
|
if (!context?.stateResources) return void 0;
|
|
7086
7327
|
const subContext = { resources: context.stateResources };
|
|
@@ -7391,6 +7632,21 @@ async function applyCrossStackValuesToTask(task, crossStackResolver, opts) {
|
|
|
7391
7632
|
dynamicRefs.dispose();
|
|
7392
7633
|
}
|
|
7393
7634
|
}
|
|
7635
|
+
function argvTarget(container, field) {
|
|
7636
|
+
if (field === "Command") return container.command;
|
|
7637
|
+
if (field === "EntryPoint") return container.entryPoint;
|
|
7638
|
+
return container.healthCheck?.command;
|
|
7639
|
+
}
|
|
7640
|
+
function rawArgv(c, field) {
|
|
7641
|
+
let raw;
|
|
7642
|
+
if (field === "Command") raw = c["Command"];
|
|
7643
|
+
else if (field === "EntryPoint") raw = c["EntryPoint"];
|
|
7644
|
+
else {
|
|
7645
|
+
const h = c["HealthCheck"];
|
|
7646
|
+
raw = h && typeof h === "object" ? h["Command"] : void 0;
|
|
7647
|
+
}
|
|
7648
|
+
return Array.isArray(raw) ? raw : void 0;
|
|
7649
|
+
}
|
|
7394
7650
|
function withContainerState(context, state) {
|
|
7395
7651
|
const out = {
|
|
7396
7652
|
...context,
|
|
@@ -7456,6 +7712,39 @@ async function applyCrossStackResolverToTask(task, context, containerState) {
|
|
|
7456
7712
|
resolvedSecretNames.add(sName);
|
|
7457
7713
|
}
|
|
7458
7714
|
}
|
|
7715
|
+
if (container.unresolvedCommandElements?.length) {
|
|
7716
|
+
const argvContext = ownState ? withContainerState(secretContext, ownState) : secretContext;
|
|
7717
|
+
const remaining = [];
|
|
7718
|
+
for (const u of container.unresolvedCommandElements) {
|
|
7719
|
+
const target = argvTarget(container, u.field);
|
|
7720
|
+
const rawElement = rawArgv(c, u.field)?.[u.index];
|
|
7721
|
+
if (!target || !isCrossStackIntrinsic(rawElement)) {
|
|
7722
|
+
remaining.push(u);
|
|
7723
|
+
continue;
|
|
7724
|
+
}
|
|
7725
|
+
const refusal = secretAttributeRead(rawElement, argvContext.resources) ?? computedAttributeRead(rawElement);
|
|
7726
|
+
if (refusal !== void 0) {
|
|
7727
|
+
remaining.push({
|
|
7728
|
+
...u,
|
|
7729
|
+
reason: refusal
|
|
7730
|
+
});
|
|
7731
|
+
continue;
|
|
7732
|
+
}
|
|
7733
|
+
const masked = { hit: false };
|
|
7734
|
+
const { result: sub, consumedSensitive } = await resolveWithSensitivityAsync(rawElement, withMaskWatch(argvContext, masked));
|
|
7735
|
+
const arg = masked.hit ? { reason: `resolved a cross-stack value recorded as the secret mask (${STATE_SECRET_MASK}), not the deployed value` } : argvValue(sub, consumedSensitive);
|
|
7736
|
+
if ("value" in arg) {
|
|
7737
|
+
target[u.index] = arg.value;
|
|
7738
|
+
continue;
|
|
7739
|
+
}
|
|
7740
|
+
remaining.push({
|
|
7741
|
+
...u,
|
|
7742
|
+
reason: arg.reason
|
|
7743
|
+
});
|
|
7744
|
+
}
|
|
7745
|
+
if (remaining.length > 0) container.unresolvedCommandElements = remaining;
|
|
7746
|
+
else delete container.unresolvedCommandElements;
|
|
7747
|
+
}
|
|
7459
7748
|
if (resolvedEnvKeys.size > 0 || resolvedSecretNames.size > 0) {
|
|
7460
7749
|
container.warnings = container.warnings.filter((w) => {
|
|
7461
7750
|
for (const k of resolvedEnvKeys) if (w.startsWith(`Environment ${displayIdent(k)} dropped:`)) return false;
|
|
@@ -8182,32 +8471,6 @@ function isMalformedEnvKey(key) {
|
|
|
8182
8471
|
return !WELL_FORMED_ENV_KEY.test(key);
|
|
8183
8472
|
}
|
|
8184
8473
|
|
|
8185
|
-
// src/utils/shutdown-signal.ts
|
|
8186
|
-
function signalExitCode(signal) {
|
|
8187
|
-
return signal === "SIGINT" ? 130 : 143;
|
|
8188
|
-
}
|
|
8189
|
-
function createShutdownSignalHandler(options) {
|
|
8190
|
-
const exit = options.exit ?? ((code) => process.exit(code));
|
|
8191
|
-
const writeStderr = options.writeStderr ?? ((text) => void process.stderr.write(text));
|
|
8192
|
-
let count = 0;
|
|
8193
|
-
const handler = (signal, exitCode) => {
|
|
8194
|
-
const code = exitCode ?? signalExitCode(signal === "SIGINT" ? "SIGINT" : "SIGTERM");
|
|
8195
|
-
count += 1;
|
|
8196
|
-
if (count === 1) {
|
|
8197
|
-
options.info(options.stoppingMessage(signal));
|
|
8198
|
-
options.cleanup().then(() => exit(code));
|
|
8199
|
-
return;
|
|
8200
|
-
}
|
|
8201
|
-
if (count === 2) {
|
|
8202
|
-
options.warn(`Received ${signal} again; still shutting down — waiting for the cleanup to remove the containers and networks. Send it once more to force-exit (that skips the cleanup).`);
|
|
8203
|
-
return;
|
|
8204
|
-
}
|
|
8205
|
-
writeStderr(`Force-exit on repeated ${signal}; container cleanup skipped. ${options.forceExitHint}\n`);
|
|
8206
|
-
exit(code);
|
|
8207
|
-
};
|
|
8208
|
-
return handler;
|
|
8209
|
-
}
|
|
8210
|
-
|
|
8211
8474
|
// src/assets/asset-source-path.ts
|
|
8212
8475
|
function resolveAssetSourcePath(opts) {
|
|
8213
8476
|
const { manifestDir, value, assetOutdir, field, subject, action, wrapError } = opts;
|
|
@@ -9441,6 +9704,46 @@ function execEnvForSecrets(passthrough) {
|
|
|
9441
9704
|
return { env };
|
|
9442
9705
|
}
|
|
9443
9706
|
|
|
9707
|
+
// src/local/container-start-guard.ts
|
|
9708
|
+
const NAME_CONFLICT = /is already (?:in use|used) by|Conflict\. The container name/;
|
|
9709
|
+
function createContainerStartGuard(options) {
|
|
9710
|
+
const remove = options.remove ?? removeContainer;
|
|
9711
|
+
let stopping = false;
|
|
9712
|
+
const inFlight = /* @__PURE__ */ new Set();
|
|
9713
|
+
const cancelled = () => new CdkLocalError("Shutting down: the container is not used.", options.cancelledCode);
|
|
9714
|
+
const stopAll = async () => {
|
|
9715
|
+
stopping = true;
|
|
9716
|
+
return (await Promise.all([...inFlight])).filter((id) => id !== void 0);
|
|
9717
|
+
};
|
|
9718
|
+
return {
|
|
9719
|
+
async run(start, name) {
|
|
9720
|
+
if (stopping) throw cancelled();
|
|
9721
|
+
const started = start();
|
|
9722
|
+
const outcome = started.then((id) => id, async (err) => {
|
|
9723
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
9724
|
+
if (name !== void 0 && !NAME_CONFLICT.test(message)) try {
|
|
9725
|
+
await remove(name);
|
|
9726
|
+
} catch {}
|
|
9727
|
+
});
|
|
9728
|
+
inFlight.add(outcome);
|
|
9729
|
+
try {
|
|
9730
|
+
const id = await started;
|
|
9731
|
+
if (stopping) throw cancelled();
|
|
9732
|
+
return id;
|
|
9733
|
+
} catch (err) {
|
|
9734
|
+
await outcome;
|
|
9735
|
+
throw err;
|
|
9736
|
+
} finally {
|
|
9737
|
+
inFlight.delete(outcome);
|
|
9738
|
+
}
|
|
9739
|
+
},
|
|
9740
|
+
async stop() {
|
|
9741
|
+
return (await stopAll())[0];
|
|
9742
|
+
},
|
|
9743
|
+
stopAll
|
|
9744
|
+
};
|
|
9745
|
+
}
|
|
9746
|
+
|
|
9444
9747
|
// src/local/debug-timeout.ts
|
|
9445
9748
|
const DEBUG_FUNCTION_TIMEOUT_SEC = 36e3;
|
|
9446
9749
|
function applyDebuggerEnv(dockerEnv, debugPort) {
|
|
@@ -10175,13 +10478,17 @@ async function localInvokeCommand(target, options, extraStateProviders) {
|
|
|
10175
10478
|
let containerId;
|
|
10176
10479
|
let stopLogs;
|
|
10177
10480
|
let sigintHandler;
|
|
10481
|
+
let sigtermHandler;
|
|
10178
10482
|
let profileCredsFile;
|
|
10483
|
+
const startGuard = createContainerStartGuard({ cancelledCode: "LOCAL_INVOKE_CANCELLED" });
|
|
10179
10484
|
const cleanup = singleFlight(async () => {
|
|
10485
|
+
const pendingContainer = startGuard.stop();
|
|
10180
10486
|
if (stopLogs) try {
|
|
10181
10487
|
stopLogs();
|
|
10182
10488
|
} catch (err) {
|
|
10183
10489
|
getLogger().debug(`streamLogs stop failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
10184
10490
|
}
|
|
10491
|
+
containerId ??= await pendingContainer;
|
|
10185
10492
|
if (containerId) try {
|
|
10186
10493
|
await removeContainer(containerId);
|
|
10187
10494
|
} catch (err) {
|
|
@@ -10227,6 +10534,17 @@ async function localInvokeCommand(target, options, extraStateProviders) {
|
|
|
10227
10534
|
}, (err) => {
|
|
10228
10535
|
getLogger().debug(`cleanup failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
10229
10536
|
});
|
|
10537
|
+
const onSignal = createShutdownSignalHandler({
|
|
10538
|
+
cleanup,
|
|
10539
|
+
stoppingMessage: (signal) => `Received ${signal}, removing the Lambda container...`,
|
|
10540
|
+
forceExitHint: `Run 'docker ps -a --filter name=${getEmbedConfig().resourceNamePrefix}-' to find what is left.`,
|
|
10541
|
+
info: (m) => logger.info(m),
|
|
10542
|
+
warn: (m) => logger.warn(m)
|
|
10543
|
+
});
|
|
10544
|
+
sigintHandler = () => onSignal("SIGINT");
|
|
10545
|
+
sigtermHandler = () => onSignal("SIGTERM");
|
|
10546
|
+
process.on("SIGINT", sigintHandler);
|
|
10547
|
+
process.on("SIGTERM", sigtermHandler);
|
|
10230
10548
|
try {
|
|
10231
10549
|
await activateWorkloadAwsWiring({
|
|
10232
10550
|
...options,
|
|
@@ -10294,29 +10612,26 @@ async function localInvokeCommand(target, options, extraStateProviders) {
|
|
|
10294
10612
|
readOnly: true
|
|
10295
10613
|
}] : imagePlan.extraMounts;
|
|
10296
10614
|
const hostGatewayExtraHosts = await resolveHostGatewayExtraHosts();
|
|
10297
|
-
|
|
10298
|
-
|
|
10299
|
-
|
|
10615
|
+
const containerName = `${getEmbedConfig().resourceNamePrefix}-invoke-${process.pid}-${Math.random().toString(36).slice(2, 8)}`;
|
|
10616
|
+
const runPlan = imagePlan;
|
|
10617
|
+
containerId = await startGuard.run(() => runDetached({
|
|
10618
|
+
name: containerName,
|
|
10619
|
+
image: runPlan.image,
|
|
10620
|
+
mounts: runPlan.mounts,
|
|
10300
10621
|
extraMounts: extraMountsWithProfile,
|
|
10301
10622
|
env: dockerEnv,
|
|
10302
10623
|
...containerEnv.sensitiveEnvKeys.length > 0 && { sensitiveEnvKeys: new Set(containerEnv.sensitiveEnvKeys) },
|
|
10303
10624
|
...hostGatewayExtraHosts.length > 0 && { extraHosts: hostGatewayExtraHosts },
|
|
10304
|
-
cmd:
|
|
10625
|
+
cmd: runPlan.cmd,
|
|
10305
10626
|
hostPort,
|
|
10306
10627
|
host: containerHost,
|
|
10307
10628
|
...debugPort !== void 0 && { debugPort },
|
|
10308
|
-
...
|
|
10309
|
-
...
|
|
10310
|
-
...
|
|
10311
|
-
...
|
|
10312
|
-
});
|
|
10629
|
+
...runPlan.platform !== void 0 && { platform: runPlan.platform },
|
|
10630
|
+
...runPlan.entryPoint !== void 0 && { entryPoint: runPlan.entryPoint },
|
|
10631
|
+
...runPlan.workingDir !== void 0 && { workingDir: runPlan.workingDir },
|
|
10632
|
+
...runPlan.tmpfs !== void 0 && { tmpfs: runPlan.tmpfs }
|
|
10633
|
+
}), containerName);
|
|
10313
10634
|
stopLogs = streamLogs(containerId);
|
|
10314
|
-
sigintHandler = () => {
|
|
10315
|
-
cleanup().then(() => {
|
|
10316
|
-
process.exit(130);
|
|
10317
|
-
});
|
|
10318
|
-
};
|
|
10319
|
-
process.on("SIGINT", sigintHandler);
|
|
10320
10635
|
await waitForRieReady(containerHost, hostPort, 5e3);
|
|
10321
10636
|
const invokeTimeoutMs = rieInvokeTimeoutMs(lambda.timeoutSec, debugPort !== void 0);
|
|
10322
10637
|
const result = await invokeRie(containerHost, hostPort, event, invokeTimeoutMs);
|
|
@@ -10324,8 +10639,9 @@ async function localInvokeCommand(target, options, extraStateProviders) {
|
|
|
10324
10639
|
process.stdout.write(`${result.raw}\n`);
|
|
10325
10640
|
if (options.responseFile) writeFileSync(options.responseFile, result.raw);
|
|
10326
10641
|
} finally {
|
|
10327
|
-
if (sigintHandler) process.off("SIGINT", sigintHandler);
|
|
10328
10642
|
await cleanup();
|
|
10643
|
+
if (sigintHandler) process.off("SIGINT", sigintHandler);
|
|
10644
|
+
if (sigtermHandler) process.off("SIGTERM", sigtermHandler);
|
|
10329
10645
|
}
|
|
10330
10646
|
}
|
|
10331
10647
|
async function resolveImagePlan(lambda, options) {
|
|
@@ -10499,16 +10815,11 @@ function envHasIntrinsicValue$1(templateEnv) {
|
|
|
10499
10815
|
}
|
|
10500
10816
|
function envHasCrossStackIntrinsic(templateEnv) {
|
|
10501
10817
|
if (!templateEnv) return false;
|
|
10502
|
-
|
|
10503
|
-
if (!v || typeof v !== "object") continue;
|
|
10504
|
-
const obj = v;
|
|
10505
|
-
if ("Fn::ImportValue" in obj || "Fn::GetStackOutput" in obj) return true;
|
|
10506
|
-
}
|
|
10507
|
-
return false;
|
|
10818
|
+
return Object.values(templateEnv).some(containsCrossStackIntrinsic);
|
|
10508
10819
|
}
|
|
10509
10820
|
async function resolvePseudoParametersForInvoke(stackRegion, options) {
|
|
10510
10821
|
const logger = getLogger();
|
|
10511
|
-
const region = options.region ??
|
|
10822
|
+
const region = options.region ?? namedEnvAwsRegion() ?? process.env["AWS_DEFAULT_REGION"] ?? regionOrAmbientDefault(stackRegion);
|
|
10512
10823
|
if (!region) logger.warn(`Resolver references \${AWS::Region} but ${getEmbedConfig().binaryName} could not determine the target region. Pass --region, set AWS_REGION, or declare env.region on the CDK stack.`);
|
|
10513
10824
|
let accountId;
|
|
10514
10825
|
try {
|
|
@@ -12834,6 +13145,8 @@ function createContainerPool(specs, options) {
|
|
|
12834
13145
|
const entries = /* @__PURE__ */ new Map();
|
|
12835
13146
|
let disposed = false;
|
|
12836
13147
|
const inFlightStarts = /* @__PURE__ */ new Set();
|
|
13148
|
+
const startGuard = createContainerStartGuard({ cancelledCode: "CONTAINER_POOL_DISPOSED" });
|
|
13149
|
+
const startedNotReady = /* @__PURE__ */ new Set();
|
|
12837
13150
|
for (const logicalId of specs.keys()) entries.set(logicalId, emptyEntry(logicalId));
|
|
12838
13151
|
function emptyEntry(logicalId) {
|
|
12839
13152
|
return {
|
|
@@ -12864,7 +13177,7 @@ function createContainerPool(specs, options) {
|
|
|
12864
13177
|
}] : optMount;
|
|
12865
13178
|
const containerCodePath = resolveRuntimeCodeMountPath(spec.lambda.runtime);
|
|
12866
13179
|
const image = resolveRuntimeImage(spec.lambda.runtime);
|
|
12867
|
-
containerId = await runDetached({
|
|
13180
|
+
containerId = await startGuard.run(() => runDetached({
|
|
12868
13181
|
image,
|
|
12869
13182
|
platform: architectureToPlatform(spec.lambda.architecture),
|
|
12870
13183
|
mounts: [{
|
|
@@ -12882,8 +13195,8 @@ function createContainerPool(specs, options) {
|
|
|
12882
13195
|
...spec.debugPort !== void 0 && { debugPort: spec.debugPort },
|
|
12883
13196
|
...spec.tmpfs !== void 0 && { tmpfs: spec.tmpfs },
|
|
12884
13197
|
...spec.extraHosts !== void 0 && { extraHosts: spec.extraHosts }
|
|
12885
|
-
});
|
|
12886
|
-
} else containerId = await runDetached({
|
|
13198
|
+
}), name);
|
|
13199
|
+
} else containerId = await startGuard.run(() => runDetached({
|
|
12887
13200
|
image: spec.image,
|
|
12888
13201
|
mounts: [],
|
|
12889
13202
|
extraMounts: [...spec.rieMount ? [spec.rieMount] : [], ...spec.profileCredentialsFile ? [{
|
|
@@ -12903,14 +13216,17 @@ function createContainerPool(specs, options) {
|
|
|
12903
13216
|
...spec.debugPort !== void 0 && { debugPort: spec.debugPort },
|
|
12904
13217
|
...spec.tmpfs !== void 0 && { tmpfs: spec.tmpfs },
|
|
12905
13218
|
...spec.extraHosts !== void 0 && { extraHosts: spec.extraHosts }
|
|
12906
|
-
});
|
|
13219
|
+
}), name);
|
|
12907
13220
|
const stopLogStream = streamingEnabled ? streamLogs(containerId) : () => void 0;
|
|
13221
|
+
startedNotReady.add(containerId);
|
|
12908
13222
|
try {
|
|
12909
13223
|
await waitForRieReady(spec.containerHost, hostPort, 3e4);
|
|
12910
13224
|
} catch (err) {
|
|
12911
13225
|
stopLogStream();
|
|
12912
13226
|
await removeContainer(containerId).catch(() => void 0);
|
|
12913
13227
|
throw err;
|
|
13228
|
+
} finally {
|
|
13229
|
+
startedNotReady.delete(containerId);
|
|
12914
13230
|
}
|
|
12915
13231
|
return {
|
|
12916
13232
|
logicalId: spec.lambda.logicalId,
|
|
@@ -12967,6 +13283,7 @@ function createContainerPool(specs, options) {
|
|
|
12967
13283
|
}
|
|
12968
13284
|
return {
|
|
12969
13285
|
async acquire(logicalId) {
|
|
13286
|
+
if (disposed) throw new Error(`Container pool disposed; not starting ${displayIdent(logicalId)}.`);
|
|
12970
13287
|
const entry = entries.get(logicalId);
|
|
12971
13288
|
if (!entry) throw new Error(`containerPool.acquire: no spec registered for Lambda ${displayIdent(logicalId)}. This is a bug — every reachable route's Lambda should be registered at server boot.`);
|
|
12972
13289
|
if (entry.warm.length > 0) {
|
|
@@ -13033,6 +13350,7 @@ function createContainerPool(specs, options) {
|
|
|
13033
13350
|
return;
|
|
13034
13351
|
}
|
|
13035
13352
|
disposed = true;
|
|
13353
|
+
const pendingRuns = startGuard.stopAll();
|
|
13036
13354
|
logger.debug("Disposing container pool");
|
|
13037
13355
|
for (const entry of entries.values()) {
|
|
13038
13356
|
if (entry.idleTimer) {
|
|
@@ -13094,10 +13412,14 @@ function createContainerPool(specs, options) {
|
|
|
13094
13412
|
let timedOut = 0;
|
|
13095
13413
|
for (const r of results) if (r.kind === "ok") allHandles.push(r.handle);
|
|
13096
13414
|
else if (r.kind === "timeout") timedOut++;
|
|
13097
|
-
if (timedOut > 0) logger.
|
|
13415
|
+
if (timedOut > 0) logger.debug(`${timedOut} in-flight start(s) still pending after ${drainTimeoutMs}ms; removing them by id once their docker run returns.`);
|
|
13098
13416
|
inFlightStarts.clear();
|
|
13099
13417
|
}
|
|
13100
|
-
await
|
|
13418
|
+
const interruptedIds = [...await pendingRuns, ...startedNotReady];
|
|
13419
|
+
startedNotReady.clear();
|
|
13420
|
+
await Promise.allSettled([...allHandles.map((h) => tearDown(h)), ...interruptedIds.map((id) => removeContainer(id).catch((err) => {
|
|
13421
|
+
logger.warn(`Failed to remove container ${id}: ${err instanceof Error ? err.message : String(err)}. Continuing cleanup.`);
|
|
13422
|
+
}))]);
|
|
13101
13423
|
entries.clear();
|
|
13102
13424
|
}
|
|
13103
13425
|
};
|
|
@@ -16031,6 +16353,21 @@ function formatServerListeningBanner(scheme, host, port, pathSuffix, label) {
|
|
|
16031
16353
|
return `Server listening on ${scheme}://${formatAuthority(host, port)}${pathSuffix} (${label})\n`;
|
|
16032
16354
|
}
|
|
16033
16355
|
async function localStartApiCommand(targets, options, extraStateProviders) {
|
|
16356
|
+
let boot;
|
|
16357
|
+
try {
|
|
16358
|
+
await serveStartApi(targets, options, extraStateProviders, (b) => {
|
|
16359
|
+
boot = b;
|
|
16360
|
+
});
|
|
16361
|
+
} catch (err) {
|
|
16362
|
+
if (boot) {
|
|
16363
|
+
await boot.teardown().catch(() => void 0);
|
|
16364
|
+
if (boot.signalled()) await new Promise(() => void 0);
|
|
16365
|
+
boot.detachSignals();
|
|
16366
|
+
}
|
|
16367
|
+
throw err;
|
|
16368
|
+
}
|
|
16369
|
+
}
|
|
16370
|
+
async function serveStartApi(targets, options, extraStateProviders, registerBoot) {
|
|
16034
16371
|
const logger = getLogger();
|
|
16035
16372
|
if (options.verbose) logger.setLevel("debug");
|
|
16036
16373
|
let apiFilters = [...targets];
|
|
@@ -16067,6 +16404,106 @@ async function localStartApiCommand(targets, options, extraStateProviders) {
|
|
|
16067
16404
|
const inlineTmpDirs = /* @__PURE__ */ new Set();
|
|
16068
16405
|
const layerTmpDirs = /* @__PURE__ */ new Set();
|
|
16069
16406
|
let profileCredsFile;
|
|
16407
|
+
const servers = [];
|
|
16408
|
+
const wsServers = [];
|
|
16409
|
+
const bootPools = [];
|
|
16410
|
+
let watcher;
|
|
16411
|
+
let reloadQueue;
|
|
16412
|
+
let shuttingDown = false;
|
|
16413
|
+
let signalled = false;
|
|
16414
|
+
const runCleanup = singleFlight(async () => {
|
|
16415
|
+
shuttingDown = true;
|
|
16416
|
+
await stopWatchReloads({
|
|
16417
|
+
watcher,
|
|
16418
|
+
queue: reloadQueue,
|
|
16419
|
+
onWatcherCloseError: (err) => logger.warn(`watcher.close() failed: ${err instanceof Error ? err.message : String(err)}`)
|
|
16420
|
+
});
|
|
16421
|
+
await Promise.allSettled(wsServers.map(async (ws) => {
|
|
16422
|
+
try {
|
|
16423
|
+
await ws.attached.close();
|
|
16424
|
+
} catch (err) {
|
|
16425
|
+
logger.warn(`WebSocket close() failed for ${ws.api.apiLogicalId}: ${err instanceof Error ? err.message : String(err)}`);
|
|
16426
|
+
}
|
|
16427
|
+
}));
|
|
16428
|
+
await Promise.allSettled(servers.map(async ({ server, group }) => {
|
|
16429
|
+
try {
|
|
16430
|
+
await server.close();
|
|
16431
|
+
} catch (err) {
|
|
16432
|
+
logger.warn(`server.close() failed for ${group.displayName}: ${err instanceof Error ? err.message : String(err)}`);
|
|
16433
|
+
}
|
|
16434
|
+
}));
|
|
16435
|
+
await Promise.allSettled(wsServers.map(async (ws) => {
|
|
16436
|
+
try {
|
|
16437
|
+
await ws.server.close();
|
|
16438
|
+
} catch (err) {
|
|
16439
|
+
logger.warn(`WebSocket server.close() failed for ${ws.api.apiLogicalId}: ${err instanceof Error ? err.message : String(err)}`);
|
|
16440
|
+
}
|
|
16441
|
+
}));
|
|
16442
|
+
await Promise.allSettled(servers.map(async ({ server, group }) => {
|
|
16443
|
+
try {
|
|
16444
|
+
await server.getServerState().pool.dispose();
|
|
16445
|
+
} catch (err) {
|
|
16446
|
+
logger.warn(`pool.dispose() failed for ${group.displayName}: ${err instanceof Error ? err.message : String(err)}`);
|
|
16447
|
+
}
|
|
16448
|
+
}));
|
|
16449
|
+
await Promise.allSettled(wsServers.map(async (ws) => {
|
|
16450
|
+
try {
|
|
16451
|
+
await ws.server.getServerState().pool.dispose();
|
|
16452
|
+
} catch (err) {
|
|
16453
|
+
logger.warn(`WebSocket pool.dispose() failed for ${ws.api.apiLogicalId}: ${err instanceof Error ? err.message : String(err)}`);
|
|
16454
|
+
}
|
|
16455
|
+
}));
|
|
16456
|
+
await Promise.allSettled(bootPools.map(async (pool) => {
|
|
16457
|
+
try {
|
|
16458
|
+
await pool.dispose();
|
|
16459
|
+
} catch (err) {
|
|
16460
|
+
logger.warn(`pool.dispose() failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
16461
|
+
}
|
|
16462
|
+
}));
|
|
16463
|
+
for (const dir of inlineTmpDirs) try {
|
|
16464
|
+
rmSync(dir, {
|
|
16465
|
+
recursive: true,
|
|
16466
|
+
force: true
|
|
16467
|
+
});
|
|
16468
|
+
} catch (err) {
|
|
16469
|
+
logger.warn(`Failed to remove inline-code tmpdir ${dir}: ${err instanceof Error ? err.message : String(err)}`);
|
|
16470
|
+
}
|
|
16471
|
+
for (const dir of layerTmpDirs) try {
|
|
16472
|
+
rmSync(dir, {
|
|
16473
|
+
recursive: true,
|
|
16474
|
+
force: true
|
|
16475
|
+
});
|
|
16476
|
+
} catch (err) {
|
|
16477
|
+
logger.warn(`Failed to remove merged-layers tmpdir ${dir}: ${err instanceof Error ? err.message : String(err)}`);
|
|
16478
|
+
}
|
|
16479
|
+
if (profileCredsFile) try {
|
|
16480
|
+
await profileCredsFile.dispose();
|
|
16481
|
+
} catch (err) {
|
|
16482
|
+
logger.warn(`Failed to remove profile credentials tmpdir ${profileCredsFile.hostPath}: ${err instanceof Error ? err.message : String(err)}`);
|
|
16483
|
+
}
|
|
16484
|
+
});
|
|
16485
|
+
const shutdown = createShutdownSignalHandler({
|
|
16486
|
+
cleanup: async () => {
|
|
16487
|
+
signalled = true;
|
|
16488
|
+
await runCleanup();
|
|
16489
|
+
},
|
|
16490
|
+
stoppingMessage: (signal) => `Received ${signal}, shutting down...`,
|
|
16491
|
+
forceExitHint: `Orphan containers may remain — run 'docker ps --filter name=${getEmbedConfig().resourceNamePrefix}-' and 'docker rm -f' to clean up.`,
|
|
16492
|
+
info: (m) => logger.info(m),
|
|
16493
|
+
warn: (m) => logger.warn(m)
|
|
16494
|
+
});
|
|
16495
|
+
const onSigint = () => shutdown("SIGINT");
|
|
16496
|
+
const onSigterm = () => shutdown("SIGTERM");
|
|
16497
|
+
process.on("SIGINT", onSigint);
|
|
16498
|
+
process.on("SIGTERM", onSigterm);
|
|
16499
|
+
registerBoot({
|
|
16500
|
+
teardown: runCleanup,
|
|
16501
|
+
detachSignals: () => {
|
|
16502
|
+
process.off("SIGINT", onSigint);
|
|
16503
|
+
process.off("SIGTERM", onSigterm);
|
|
16504
|
+
},
|
|
16505
|
+
signalled: () => signalled
|
|
16506
|
+
});
|
|
16070
16507
|
const authorizerCache = createAuthorizerCache();
|
|
16071
16508
|
const jwksCache = createJwksCache();
|
|
16072
16509
|
const jwksWarnedAt = /* @__PURE__ */ new Map();
|
|
@@ -16188,6 +16625,7 @@ async function localStartApiCommand(targets, options, extraStateProviders) {
|
|
|
16188
16625
|
};
|
|
16189
16626
|
};
|
|
16190
16627
|
const buildPool = (specs) => {
|
|
16628
|
+
if (shuttingDown) throw new CdkLocalError("Shutting down: no container pool is built.", "LOCAL_START_API_CANCELLED");
|
|
16191
16629
|
const pool = createContainerPool(specs, {
|
|
16192
16630
|
perLambdaConcurrency,
|
|
16193
16631
|
skipPull: options.pull === false
|
|
@@ -16213,11 +16651,11 @@ async function localStartApiCommand(targets, options, extraStateProviders) {
|
|
|
16213
16651
|
const mtlsConfig = resolveMtlsConfig(options);
|
|
16214
16652
|
if (mtlsConfig) logger.info("mTLS enabled: client certificates required (chain check against --mtls-truststore at TLS handshake).");
|
|
16215
16653
|
const initialGroups = groupRoutesByServer(initialMaterial.routes);
|
|
16216
|
-
const servers = [];
|
|
16217
16654
|
let nextPort = basePort;
|
|
16218
16655
|
for (const group of initialGroups) {
|
|
16219
16656
|
const groupSpecs = filterSpecsForGroup(group, initialMaterial.specs);
|
|
16220
16657
|
const groupPool = buildPool(groupSpecs);
|
|
16658
|
+
bootPools.push(groupPool);
|
|
16221
16659
|
const groupState = {
|
|
16222
16660
|
routes: group.routes,
|
|
16223
16661
|
pool: groupPool,
|
|
@@ -16226,6 +16664,7 @@ async function localStartApiCommand(targets, options, extraStateProviders) {
|
|
|
16226
16664
|
if (options.warm) {
|
|
16227
16665
|
logger.info(`Pre-warming ${groupSpecs.size} container(s) for ${group.displayName}...`);
|
|
16228
16666
|
const handles = await Promise.allSettled([...groupSpecs.keys()].map((id) => groupPool.acquire(id)));
|
|
16667
|
+
if (shuttingDown) throw new CdkLocalError("Shutting down: the boot is not continued.", "LOCAL_START_API_CANCELLED");
|
|
16229
16668
|
for (const result of handles) if (result.status === "fulfilled") groupPool.release(result.value);
|
|
16230
16669
|
else logger.warn(`Pre-warm failed for one Lambda in ${group.displayName} (cold start cost will apply on first request): ${result.reason instanceof Error ? result.reason.message : String(result.reason)}`);
|
|
16231
16670
|
}
|
|
@@ -16250,7 +16689,6 @@ async function localStartApiCommand(targets, options, extraStateProviders) {
|
|
|
16250
16689
|
});
|
|
16251
16690
|
if (basePort !== 0) nextPort += 1;
|
|
16252
16691
|
}
|
|
16253
|
-
const wsServers = [];
|
|
16254
16692
|
const initialWsApis = initialMaterial.webSocketApis ?? [];
|
|
16255
16693
|
warnUnsupportedWebSocketApis(initialWsApis, logger);
|
|
16256
16694
|
if (initialWsApis.filter((api) => !api.unsupported).length > 0) {
|
|
@@ -16271,6 +16709,7 @@ async function localStartApiCommand(targets, options, extraStateProviders) {
|
|
|
16271
16709
|
continue;
|
|
16272
16710
|
}
|
|
16273
16711
|
const wsPool = buildPool(wsSpecs);
|
|
16712
|
+
bootPools.push(wsPool);
|
|
16274
16713
|
const wsState = {
|
|
16275
16714
|
routes: [],
|
|
16276
16715
|
pool: wsPool,
|
|
@@ -16338,8 +16777,6 @@ async function localStartApiCommand(targets, options, extraStateProviders) {
|
|
|
16338
16777
|
process.stdout.write(formatServerListeningBanner(scheme, ws.server.host, ws.server.port, ws.apiPath, `${ws.api.apiLogicalId} (WebSocket API)`));
|
|
16339
16778
|
}
|
|
16340
16779
|
process.stdout.write("^C to stop and clean up containers.\n");
|
|
16341
|
-
let watcher;
|
|
16342
|
-
let reloadQueue;
|
|
16343
16780
|
if (options.watch) {
|
|
16344
16781
|
const watchRoot = process.cwd();
|
|
16345
16782
|
const { ignored, shouldTrigger, excludePatterns } = createWatchPredicates({
|
|
@@ -16369,82 +16806,6 @@ async function localStartApiCommand(targets, options, extraStateProviders) {
|
|
|
16369
16806
|
});
|
|
16370
16807
|
logger.info(`Watching ${watchRoot} for source changes (excluding ${excludePatterns.join(", ")}).`);
|
|
16371
16808
|
}
|
|
16372
|
-
const runCleanup = singleFlight(async () => {
|
|
16373
|
-
await stopWatchReloads({
|
|
16374
|
-
watcher,
|
|
16375
|
-
queue: reloadQueue,
|
|
16376
|
-
onWatcherCloseError: (err) => logger.warn(`watcher.close() failed: ${err instanceof Error ? err.message : String(err)}`)
|
|
16377
|
-
});
|
|
16378
|
-
await Promise.allSettled(wsServers.map(async (ws) => {
|
|
16379
|
-
try {
|
|
16380
|
-
await ws.attached.close();
|
|
16381
|
-
} catch (err) {
|
|
16382
|
-
logger.warn(`WebSocket close() failed for ${ws.api.apiLogicalId}: ${err instanceof Error ? err.message : String(err)}`);
|
|
16383
|
-
}
|
|
16384
|
-
}));
|
|
16385
|
-
await Promise.allSettled(servers.map(async ({ server, group }) => {
|
|
16386
|
-
try {
|
|
16387
|
-
await server.close();
|
|
16388
|
-
} catch (err) {
|
|
16389
|
-
logger.warn(`server.close() failed for ${group.displayName}: ${err instanceof Error ? err.message : String(err)}`);
|
|
16390
|
-
}
|
|
16391
|
-
}));
|
|
16392
|
-
await Promise.allSettled(wsServers.map(async (ws) => {
|
|
16393
|
-
try {
|
|
16394
|
-
await ws.server.close();
|
|
16395
|
-
} catch (err) {
|
|
16396
|
-
logger.warn(`WebSocket server.close() failed for ${ws.api.apiLogicalId}: ${err instanceof Error ? err.message : String(err)}`);
|
|
16397
|
-
}
|
|
16398
|
-
}));
|
|
16399
|
-
await Promise.allSettled(servers.map(async ({ server, group }) => {
|
|
16400
|
-
try {
|
|
16401
|
-
await server.getServerState().pool.dispose();
|
|
16402
|
-
} catch (err) {
|
|
16403
|
-
logger.warn(`pool.dispose() failed for ${group.displayName}: ${err instanceof Error ? err.message : String(err)}`);
|
|
16404
|
-
}
|
|
16405
|
-
}));
|
|
16406
|
-
await Promise.allSettled(wsServers.map(async (ws) => {
|
|
16407
|
-
try {
|
|
16408
|
-
await ws.server.getServerState().pool.dispose();
|
|
16409
|
-
} catch (err) {
|
|
16410
|
-
logger.warn(`WebSocket pool.dispose() failed for ${ws.api.apiLogicalId}: ${err instanceof Error ? err.message : String(err)}`);
|
|
16411
|
-
}
|
|
16412
|
-
}));
|
|
16413
|
-
for (const dir of inlineTmpDirs) try {
|
|
16414
|
-
rmSync(dir, {
|
|
16415
|
-
recursive: true,
|
|
16416
|
-
force: true
|
|
16417
|
-
});
|
|
16418
|
-
} catch (err) {
|
|
16419
|
-
logger.warn(`Failed to remove inline-code tmpdir ${dir}: ${err instanceof Error ? err.message : String(err)}`);
|
|
16420
|
-
}
|
|
16421
|
-
for (const dir of layerTmpDirs) try {
|
|
16422
|
-
rmSync(dir, {
|
|
16423
|
-
recursive: true,
|
|
16424
|
-
force: true
|
|
16425
|
-
});
|
|
16426
|
-
} catch (err) {
|
|
16427
|
-
logger.warn(`Failed to remove merged-layers tmpdir ${dir}: ${err instanceof Error ? err.message : String(err)}`);
|
|
16428
|
-
}
|
|
16429
|
-
if (profileCredsFile) try {
|
|
16430
|
-
await profileCredsFile.dispose();
|
|
16431
|
-
} catch (err) {
|
|
16432
|
-
logger.warn(`Failed to remove profile credentials tmpdir ${profileCredsFile.hostPath}: ${err instanceof Error ? err.message : String(err)}`);
|
|
16433
|
-
}
|
|
16434
|
-
});
|
|
16435
|
-
const shutdown = createShutdownSignalHandler({
|
|
16436
|
-
cleanup: runCleanup,
|
|
16437
|
-
stoppingMessage: (signal) => `Received ${signal}, shutting down...`,
|
|
16438
|
-
forceExitHint: `Orphan containers may remain — run 'docker ps --filter name=${getEmbedConfig().resourceNamePrefix}-' and 'docker rm -f' to clean up.`,
|
|
16439
|
-
info: (m) => logger.info(m),
|
|
16440
|
-
warn: (m) => logger.warn(m)
|
|
16441
|
-
});
|
|
16442
|
-
process.on("SIGINT", () => {
|
|
16443
|
-
shutdown("SIGINT");
|
|
16444
|
-
});
|
|
16445
|
-
process.on("SIGTERM", () => {
|
|
16446
|
-
shutdown("SIGTERM");
|
|
16447
|
-
});
|
|
16448
16809
|
process.on("uncaughtException", (err) => {
|
|
16449
16810
|
logger.error(`Uncaught exception: ${err instanceof Error ? err.stack ?? err.message : String(err)}`);
|
|
16450
16811
|
shutdown("uncaughtException", 1);
|
|
@@ -17345,7 +17706,7 @@ async function loadStackStateBundle(stack, provider, args) {
|
|
|
17345
17706
|
}
|
|
17346
17707
|
async function resolvePseudoParametersForStartApi(stateRegion, options) {
|
|
17347
17708
|
const logger = getLogger();
|
|
17348
|
-
const region = options.region ??
|
|
17709
|
+
const region = options.region ?? namedEnvAwsRegion() ?? process.env["AWS_DEFAULT_REGION"] ?? regionOrAmbientDefault(stateRegion);
|
|
17349
17710
|
let accountId;
|
|
17350
17711
|
try {
|
|
17351
17712
|
const { STSClient, GetCallerIdentityCommand } = await import("@aws-sdk/client-sts");
|
|
@@ -18157,7 +18518,9 @@ async function localInvokeAgentCoreCommand(target, options, extraStateProviders)
|
|
|
18157
18518
|
let profileCredsFile;
|
|
18158
18519
|
let stateProvider;
|
|
18159
18520
|
let stopWatch;
|
|
18521
|
+
const startGuard = createContainerStartGuard({ cancelledCode: "LOCAL_INVOKE_AGENTCORE_CANCELLED" });
|
|
18160
18522
|
const cleanup = singleFlight(async () => {
|
|
18523
|
+
const pendingContainer = startGuard.stop();
|
|
18161
18524
|
if (stopWatch) await stopWatch();
|
|
18162
18525
|
if (stateProvider) try {
|
|
18163
18526
|
stateProvider.dispose();
|
|
@@ -18169,6 +18532,7 @@ async function localInvokeAgentCoreCommand(target, options, extraStateProviders)
|
|
|
18169
18532
|
} catch (err) {
|
|
18170
18533
|
getLogger().debug(`streamLogs stop failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
18171
18534
|
}
|
|
18535
|
+
containerId ??= await pendingContainer;
|
|
18172
18536
|
if (containerId) try {
|
|
18173
18537
|
await removeContainer(containerId);
|
|
18174
18538
|
} catch (err) {
|
|
@@ -18182,6 +18546,17 @@ async function localInvokeAgentCoreCommand(target, options, extraStateProviders)
|
|
|
18182
18546
|
}, (err) => {
|
|
18183
18547
|
getLogger().debug(`cleanup failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
18184
18548
|
});
|
|
18549
|
+
const onSignal = createShutdownSignalHandler({
|
|
18550
|
+
cleanup,
|
|
18551
|
+
stoppingMessage: (signal) => `Received ${signal}, removing the agent container...`,
|
|
18552
|
+
forceExitHint: `Run 'docker ps -a --filter name=${getEmbedConfig().resourceNamePrefix}-' to find what is left.`,
|
|
18553
|
+
info: (m) => logger.info(m),
|
|
18554
|
+
warn: (m) => logger.warn(m)
|
|
18555
|
+
});
|
|
18556
|
+
sigintHandler = () => onSignal("SIGINT");
|
|
18557
|
+
sigtermHandler = () => onSignal("SIGTERM");
|
|
18558
|
+
process.on("SIGINT", sigintHandler);
|
|
18559
|
+
process.on("SIGTERM", sigtermHandler);
|
|
18185
18560
|
try {
|
|
18186
18561
|
await activateWorkloadAwsWiring({
|
|
18187
18562
|
...options,
|
|
@@ -18261,7 +18636,7 @@ async function localInvokeAgentCoreCommand(target, options, extraStateProviders)
|
|
|
18261
18636
|
const containerPort = isMcp ? MCP_CONTAINER_PORT : isA2a ? A2A_CONTAINER_PORT : void 0;
|
|
18262
18637
|
const containerPortLabel = isMcp ? `${MCP_CONTAINER_PORT}${MCP_PATH}` : isA2a ? `${A2A_CONTAINER_PORT}${"/"}` : "8080";
|
|
18263
18638
|
logger.info(`Starting agent container (image=${image}, port=${hostPort} -> ${containerPortLabel})...`);
|
|
18264
|
-
containerId = await runDetached({
|
|
18639
|
+
containerId = await startGuard.run(() => runDetached({
|
|
18265
18640
|
image,
|
|
18266
18641
|
mounts: [],
|
|
18267
18642
|
env: dockerEnv,
|
|
@@ -18272,19 +18647,8 @@ async function localInvokeAgentCoreCommand(target, options, extraStateProviders)
|
|
|
18272
18647
|
name: containerName,
|
|
18273
18648
|
...containerPort !== void 0 && { containerPort },
|
|
18274
18649
|
...sensitiveEnvKeys.size > 0 && { sensitiveEnvKeys }
|
|
18275
|
-
});
|
|
18650
|
+
}), containerName);
|
|
18276
18651
|
stopLogs = streamLogs(containerId);
|
|
18277
|
-
const onSignal = createShutdownSignalHandler({
|
|
18278
|
-
cleanup,
|
|
18279
|
-
stoppingMessage: (signal) => `Received ${signal}, removing the agent container...`,
|
|
18280
|
-
forceExitHint: `Run 'docker ps -a --filter name=${getEmbedConfig().resourceNamePrefix}-' to find what is left.`,
|
|
18281
|
-
info: (m) => logger.info(m),
|
|
18282
|
-
warn: (m) => logger.warn(m)
|
|
18283
|
-
});
|
|
18284
|
-
sigintHandler = () => onSignal("SIGINT");
|
|
18285
|
-
sigtermHandler = () => onSignal("SIGTERM");
|
|
18286
|
-
process.on("SIGINT", sigintHandler);
|
|
18287
|
-
process.on("SIGTERM", sigtermHandler);
|
|
18288
18652
|
if (isMcp && mcpRequest) {
|
|
18289
18653
|
logger.info(`MCP request: ${mcpRequest.method}`);
|
|
18290
18654
|
const mcp = await mcpInvokeOnce(containerHost, hostPort, mcpRequest, { requestTimeoutMs: options.timeout });
|
|
@@ -18424,7 +18788,7 @@ async function resolveAgentCoreSigV4Context(options, resolved, loaded, stateProv
|
|
|
18424
18788
|
getLogger().warn(`Runtime ${displayIdent(resolved.logicalId)} declares a customJwtAuthorizer; --sigv4 ignored (JWT path takes precedence).`);
|
|
18425
18789
|
return;
|
|
18426
18790
|
}
|
|
18427
|
-
const region = options.region ?? options.stackRegion ??
|
|
18791
|
+
const region = options.region ?? options.stackRegion ?? namedEnvAwsRegion() ?? process.env["AWS_DEFAULT_REGION"] ?? regionOrAmbientDefault(resolved.stack.region);
|
|
18428
18792
|
if (!region) throw new CdkLocalError("--sigv4: no region resolved for the AgentCore signing scope. Pass --region <region>, set AWS_REGION, or use --from-cfn-stack with a region-bound stack.", "LOCAL_INVOKE_AGENTCORE_SIGV4_NO_REGION");
|
|
18429
18793
|
return {
|
|
18430
18794
|
credentials: await resolveHostCredentialsForSigV4(options, resolved, loaded, region, stateProvider),
|
|
@@ -18558,7 +18922,7 @@ async function resolveAgentCoreCodeImageFromS3(resolved, code, s3Source, options
|
|
|
18558
18922
|
key: s3Source.key,
|
|
18559
18923
|
...s3Source.versionId !== void 0 && { versionId: s3Source.versionId }
|
|
18560
18924
|
};
|
|
18561
|
-
const region = options.region ?? options.stackRegion ??
|
|
18925
|
+
const region = options.region ?? options.stackRegion ?? namedEnvAwsRegion() ?? process.env["AWS_DEFAULT_REGION"] ?? regionOrAmbientDefault(resolved.stack.region);
|
|
18562
18926
|
const assumeRoleArn = await resolveAssumeRoleArn(options, resolved, loaded, stateProvider);
|
|
18563
18927
|
let credentials;
|
|
18564
18928
|
if (assumeRoleArn) try {
|
|
@@ -18702,7 +19066,7 @@ function describeIntrinsic(value) {
|
|
|
18702
19066
|
}
|
|
18703
19067
|
async function buildAgentCoreImageContext(candidate, stateProvider, options) {
|
|
18704
19068
|
const logger = getLogger();
|
|
18705
|
-
const region = options.region ??
|
|
19069
|
+
const region = options.region ?? namedEnvAwsRegion() ?? process.env["AWS_DEFAULT_REGION"] ?? regionOrAmbientDefault(candidate.region);
|
|
18706
19070
|
let accountId;
|
|
18707
19071
|
try {
|
|
18708
19072
|
accountId = await resolveCallerAccountId$2(region, options.profile, isCfnFlagPresent(options));
|
|
@@ -19854,6 +20218,7 @@ function mergeHostGatewayAddHostFlags(addHostFlags, hostGatewayExtraHosts) {
|
|
|
19854
20218
|
async function runEcsTask(task, options, state) {
|
|
19855
20219
|
const logger = getLogger();
|
|
19856
20220
|
if (task.containers.length === 0) throw new EcsTaskRunnerError(`Task ${displayIdent(task.taskDefinitionLogicalId)} has no containers — nothing to run.`);
|
|
20221
|
+
assertEcsTaskCommandsResolved(task);
|
|
19857
20222
|
for (const w of task.warnings) logger.warn(w);
|
|
19858
20223
|
const startOrder = topoSort(buildDependencyGraph(task.containers), task.containers);
|
|
19859
20224
|
const finchRefusals = [];
|
|
@@ -23205,8 +23570,32 @@ function createFrontDoorLambdaRunner(lambda, opts) {
|
|
|
23205
23570
|
let stopLogStream;
|
|
23206
23571
|
let starting;
|
|
23207
23572
|
let stopped = false;
|
|
23573
|
+
const startGuard = createContainerStartGuard({ cancelledCode: "FRONT_DOOR_LAMBDA_STOPPED" });
|
|
23574
|
+
function removePlanTmpDirs(p) {
|
|
23575
|
+
if (p?.inlineTmpDir) try {
|
|
23576
|
+
rmSync(p.inlineTmpDir, {
|
|
23577
|
+
recursive: true,
|
|
23578
|
+
force: true
|
|
23579
|
+
});
|
|
23580
|
+
} catch (err) {
|
|
23581
|
+
logger.debug(`Failed to remove inline-code tmpdir ${p.inlineTmpDir}: ${err instanceof Error ? err.message : String(err)}`);
|
|
23582
|
+
}
|
|
23583
|
+
if (p?.assetTmpDir) try {
|
|
23584
|
+
rmSync(p.assetTmpDir, {
|
|
23585
|
+
recursive: true,
|
|
23586
|
+
force: true
|
|
23587
|
+
});
|
|
23588
|
+
} catch (err) {
|
|
23589
|
+
logger.debug(`Failed to remove zip-asset tmpdir ${p.assetTmpDir}: ${err instanceof Error ? err.message : String(err)}`);
|
|
23590
|
+
}
|
|
23591
|
+
}
|
|
23208
23592
|
async function doStart() {
|
|
23209
|
-
|
|
23593
|
+
const resolved = lambda.kind === "zip" ? await resolveZipImagePlan(lambda, opts) : await resolveContainerImagePlan(lambda, opts);
|
|
23594
|
+
if (stopped) {
|
|
23595
|
+
removePlanTmpDirs(resolved);
|
|
23596
|
+
throw new Error("FrontDoorLambdaRunner stopped while starting");
|
|
23597
|
+
}
|
|
23598
|
+
plan = resolved;
|
|
23210
23599
|
const port = await pickFreePort();
|
|
23211
23600
|
hostPort = port;
|
|
23212
23601
|
const name = `${getEmbedConfig().resourceNamePrefix}-alblambda-${lambda.logicalId}-${process.pid}-${Math.floor(Math.random() * 1e6)}`;
|
|
@@ -23219,20 +23608,20 @@ function createFrontDoorLambdaRunner(lambda, opts) {
|
|
|
23219
23608
|
AWS_LAMBDA_LOG_STREAM_NAME: "local",
|
|
23220
23609
|
...forwardAwsEnv()
|
|
23221
23610
|
};
|
|
23222
|
-
logger.info(`Starting Lambda target container for ${lambda.logicalId} (image=${
|
|
23223
|
-
const id = await runDetached({
|
|
23224
|
-
image:
|
|
23225
|
-
mounts:
|
|
23611
|
+
logger.info(`Starting Lambda target container for ${lambda.logicalId} (image=${resolved.image}, port=${port})...`);
|
|
23612
|
+
const id = await startGuard.run(() => runDetached({
|
|
23613
|
+
image: resolved.image,
|
|
23614
|
+
mounts: resolved.mounts,
|
|
23226
23615
|
env,
|
|
23227
23616
|
...opts.sensitiveEnvKeys && opts.sensitiveEnvKeys.size > 0 && { sensitiveEnvKeys: opts.sensitiveEnvKeys },
|
|
23228
|
-
cmd:
|
|
23617
|
+
cmd: resolved.cmd,
|
|
23229
23618
|
hostPort: port,
|
|
23230
23619
|
host: opts.containerHost,
|
|
23231
23620
|
name,
|
|
23232
|
-
...
|
|
23233
|
-
...
|
|
23234
|
-
...
|
|
23235
|
-
});
|
|
23621
|
+
...resolved.platform !== void 0 && { platform: resolved.platform },
|
|
23622
|
+
...resolved.entryPoint !== void 0 && { entryPoint: resolved.entryPoint },
|
|
23623
|
+
...resolved.workingDir !== void 0 && { workingDir: resolved.workingDir }
|
|
23624
|
+
}), name);
|
|
23236
23625
|
containerId = id;
|
|
23237
23626
|
stopLogStream = opts.streamLogs === false ? void 0 : streamLogs(id);
|
|
23238
23627
|
try {
|
|
@@ -23261,11 +23650,14 @@ function createFrontDoorLambdaRunner(lambda, opts) {
|
|
|
23261
23650
|
async stop() {
|
|
23262
23651
|
if (stopped) return;
|
|
23263
23652
|
stopped = true;
|
|
23653
|
+
const pendingContainer = startGuard.stop();
|
|
23264
23654
|
try {
|
|
23265
23655
|
stopLogStream?.();
|
|
23266
23656
|
} catch (err) {
|
|
23267
23657
|
logger.debug(`stopLogStream(${displayIdent(lambda.logicalId)}) failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
23268
23658
|
}
|
|
23659
|
+
const pendingId = await pendingContainer;
|
|
23660
|
+
containerId ??= pendingId;
|
|
23269
23661
|
if (containerId) {
|
|
23270
23662
|
try {
|
|
23271
23663
|
await removeContainer(containerId);
|
|
@@ -23274,22 +23666,7 @@ function createFrontDoorLambdaRunner(lambda, opts) {
|
|
|
23274
23666
|
}
|
|
23275
23667
|
containerId = void 0;
|
|
23276
23668
|
}
|
|
23277
|
-
|
|
23278
|
-
rmSync(plan.inlineTmpDir, {
|
|
23279
|
-
recursive: true,
|
|
23280
|
-
force: true
|
|
23281
|
-
});
|
|
23282
|
-
} catch (err) {
|
|
23283
|
-
logger.debug(`Failed to remove inline-code tmpdir ${plan.inlineTmpDir}: ${err instanceof Error ? err.message : String(err)}`);
|
|
23284
|
-
}
|
|
23285
|
-
if (plan?.assetTmpDir) try {
|
|
23286
|
-
rmSync(plan.assetTmpDir, {
|
|
23287
|
-
recursive: true,
|
|
23288
|
-
force: true
|
|
23289
|
-
});
|
|
23290
|
-
} catch (err) {
|
|
23291
|
-
logger.debug(`Failed to remove zip-asset tmpdir ${plan.assetTmpDir}: ${err instanceof Error ? err.message : String(err)}`);
|
|
23292
|
-
}
|
|
23669
|
+
removePlanTmpDirs(plan);
|
|
23293
23670
|
}
|
|
23294
23671
|
};
|
|
23295
23672
|
}
|
|
@@ -23916,7 +24293,14 @@ async function runEcsServiceEmulator(targets, options, strategy, extraStateProvi
|
|
|
23916
24293
|
let frontDoorLambdaRunners = [];
|
|
23917
24294
|
let watcher;
|
|
23918
24295
|
let reloadQueue;
|
|
24296
|
+
let sharedNetworkPending;
|
|
24297
|
+
let signalled = false;
|
|
24298
|
+
let stopping = false;
|
|
24299
|
+
const throwIfStopping = () => {
|
|
24300
|
+
if (stopping) throw new LocalStartServiceError("Shutting down: the boot is not continued.");
|
|
24301
|
+
};
|
|
23919
24302
|
const cleanup = singleFlight(async () => {
|
|
24303
|
+
stopping = true;
|
|
23920
24304
|
await stopWatchReloads({
|
|
23921
24305
|
watcher,
|
|
23922
24306
|
queue: reloadQueue,
|
|
@@ -23934,6 +24318,9 @@ async function runEcsServiceEmulator(targets, options, strategy, extraStateProvi
|
|
|
23934
24318
|
frontDoorServers = [];
|
|
23935
24319
|
await Promise.allSettled(frontDoorLambdaRunners.map((r) => r.stop().catch((err) => getLogger().warn(`front-door Lambda target teardown failed: ${err instanceof Error ? err.message : String(err)}`))));
|
|
23936
24320
|
frontDoorLambdaRunners = [];
|
|
24321
|
+
const pendingNetwork = await sharedNetworkPending;
|
|
24322
|
+
sharedNetwork ??= pendingNetwork;
|
|
24323
|
+
sharedNetworkPending = void 0;
|
|
23937
24324
|
if (profileCredsFile) {
|
|
23938
24325
|
try {
|
|
23939
24326
|
await profileCredsFile.dispose();
|
|
@@ -23952,6 +24339,20 @@ async function runEcsServiceEmulator(targets, options, strategy, extraStateProvi
|
|
|
23952
24339
|
}
|
|
23953
24340
|
}, (err) => getLogger().warn(`service cleanup failed: ${err instanceof Error ? err.message : String(err)}`));
|
|
23954
24341
|
try {
|
|
24342
|
+
const onSignal = createShutdownSignalHandler({
|
|
24343
|
+
cleanup: async () => {
|
|
24344
|
+
signalled = true;
|
|
24345
|
+
await cleanup();
|
|
24346
|
+
},
|
|
24347
|
+
stoppingMessage: () => "Stopping service(s)...",
|
|
24348
|
+
forceExitHint: `Run 'docker ps -a --filter name=${getEmbedConfig().resourceNamePrefix}-' and 'docker network ls --filter name=${getEmbedConfig().resourceNamePrefix}-' to find what is left.`,
|
|
24349
|
+
info: (m) => logger.info(m),
|
|
24350
|
+
warn: (m) => logger.warn(m)
|
|
24351
|
+
});
|
|
24352
|
+
sigintHandler = () => onSignal("SIGINT");
|
|
24353
|
+
sigtermHandler = () => onSignal("SIGTERM");
|
|
24354
|
+
process.on("SIGINT", sigintHandler);
|
|
24355
|
+
process.on("SIGTERM", sigtermHandler);
|
|
23955
24356
|
await activateWorkloadAwsWiring(options);
|
|
23956
24357
|
warnIfEmulateRoleViaUnused(options.emulateRoleVia, {
|
|
23957
24358
|
roleFlag: "--assume-role",
|
|
@@ -24002,16 +24403,20 @@ async function runEcsServiceEmulator(targets, options, strategy, extraStateProvi
|
|
|
24002
24403
|
const taskRoleMode = isTaskRoleInEffect(options);
|
|
24003
24404
|
const sidecarCredentials = taskRoleMode ? void 0 : await resolveSharedSidecarCredentials(options);
|
|
24004
24405
|
try {
|
|
24005
|
-
|
|
24406
|
+
const creating = createSharedSvcNetwork({
|
|
24006
24407
|
prefix: options.cluster,
|
|
24007
24408
|
skipPull,
|
|
24008
24409
|
cluster: options.cluster,
|
|
24009
24410
|
...taskRoleMode && { taskRole: true },
|
|
24010
24411
|
...sidecarCredentials !== void 0 && { credentials: sidecarCredentials }
|
|
24011
24412
|
});
|
|
24413
|
+
sharedNetworkPending = creating.catch(() => void 0);
|
|
24414
|
+
sharedNetwork = await creating;
|
|
24415
|
+
sharedNetworkPending = void 0;
|
|
24012
24416
|
} catch (err) {
|
|
24013
24417
|
throw new LocalStartServiceError(`Failed to create shared service network: ${err instanceof Error ? err.message : String(err)}`);
|
|
24014
24418
|
}
|
|
24419
|
+
throwIfStopping();
|
|
24015
24420
|
if (options.profile && sidecarCredentials) profileCredsFile = await writeProfileCredentialsFile(options.profile, sidecarCredentials);
|
|
24016
24421
|
const discovery = {
|
|
24017
24422
|
registry,
|
|
@@ -24019,22 +24424,13 @@ async function runEcsServiceEmulator(targets, options, strategy, extraStateProvi
|
|
|
24019
24424
|
sharedNetwork
|
|
24020
24425
|
};
|
|
24021
24426
|
if (frontDoor && frontDoor.listeners.length > 0) {
|
|
24022
|
-
const built = await buildFrontDoor(frontDoor, options, logger, extraStateProviders)
|
|
24427
|
+
const built = await buildFrontDoor(frontDoor, options, logger, extraStateProviders, (r) => {
|
|
24428
|
+
frontDoorLambdaRunners.push(r);
|
|
24429
|
+
if (stopping) r.stop().catch(() => void 0);
|
|
24430
|
+
});
|
|
24023
24431
|
frontDoorServers = built.servers;
|
|
24024
24432
|
frontDoorByService = built.frontDoorByService;
|
|
24025
|
-
frontDoorLambdaRunners = built.lambdaRunners;
|
|
24026
24433
|
}
|
|
24027
|
-
const onSignal = createShutdownSignalHandler({
|
|
24028
|
-
cleanup,
|
|
24029
|
-
stoppingMessage: () => "Stopping service(s)...",
|
|
24030
|
-
forceExitHint: `Run 'docker ps -a --filter name=${getEmbedConfig().resourceNamePrefix}-' and 'docker network ls --filter name=${getEmbedConfig().resourceNamePrefix}-' to find what is left.`,
|
|
24031
|
-
info: (m) => logger.info(m),
|
|
24032
|
-
warn: (m) => logger.warn(m)
|
|
24033
|
-
});
|
|
24034
|
-
sigintHandler = () => onSignal("SIGINT");
|
|
24035
|
-
sigtermHandler = () => onSignal("SIGTERM");
|
|
24036
|
-
process.on("SIGINT", sigintHandler);
|
|
24037
|
-
process.on("SIGTERM", sigtermHandler);
|
|
24038
24434
|
const { tags: imageOverrideTags, overrides: imageOverrideMap } = await resolveAndBuildImageOverrides({
|
|
24039
24435
|
perTarget: perTarget.map((pt) => pt.boot.target),
|
|
24040
24436
|
stacks,
|
|
@@ -24042,7 +24438,10 @@ async function runEcsServiceEmulator(targets, options, strategy, extraStateProvi
|
|
|
24042
24438
|
extraStateProviders,
|
|
24043
24439
|
logger
|
|
24044
24440
|
});
|
|
24045
|
-
for (const pt of perTarget)
|
|
24441
|
+
for (const pt of perTarget) {
|
|
24442
|
+
throwIfStopping();
|
|
24443
|
+
pt.controller = await bootOneTarget(pt.boot, pt.runState, stacks, options, discovery, skipPull, extraStateProviders, profileCredsFile, frontDoorByService.get(pt.boot.target), strategy.suppressLoadBalancerWarning === true, imageOverrideTags.get(pt.boot.target));
|
|
24444
|
+
}
|
|
24046
24445
|
if (perTarget.length > 0) {
|
|
24047
24446
|
const summary = perTarget.map((pt) => `${pt.controller.service.serviceName} (${pt.controller.activeReplicaCount()} replica(s))`).join(", ");
|
|
24048
24447
|
logger.info(`Service(s) running: ${summary}.`);
|
|
@@ -24106,6 +24505,7 @@ async function runEcsServiceEmulator(targets, options, strategy, extraStateProvi
|
|
|
24106
24505
|
await new Promise(() => {});
|
|
24107
24506
|
} finally {
|
|
24108
24507
|
await cleanup();
|
|
24508
|
+
if (signalled) await new Promise(() => void 0);
|
|
24109
24509
|
if (sigintHandler) process.off("SIGINT", sigintHandler);
|
|
24110
24510
|
if (sigtermHandler) process.off("SIGTERM", sigtermHandler);
|
|
24111
24511
|
}
|
|
@@ -24357,14 +24757,15 @@ async function resolveServiceAndRunnerOpts(boot, stacks, options, discovery, ski
|
|
|
24357
24757
|
const taskStack = stacks.find((s) => s.stackName === service.stack.stackName) ?? service.stack;
|
|
24358
24758
|
const taskNeeds = detectEcsImageResolutionNeeds(taskStack);
|
|
24359
24759
|
if (stateProvider && taskNeeds.needsCrossStackResolver) {
|
|
24360
|
-
const consumerRegion = options.region ??
|
|
24760
|
+
const consumerRegion = options.region ?? namedEnvAwsRegion() ?? process.env["AWS_DEFAULT_REGION"] ?? regionOrAmbientDefault(service.stack.region) ?? "us-east-1";
|
|
24361
24761
|
const resolver = await stateProvider.buildCrossStackResolver(consumerRegion);
|
|
24362
24762
|
if (resolver) await applyCrossStackValuesToTask(service.task, resolver, {
|
|
24363
24763
|
imageContext,
|
|
24364
24764
|
consumerRegion,
|
|
24365
24765
|
profile: options.profile
|
|
24366
24766
|
});
|
|
24367
|
-
} else if (!stateProvider && taskNeeds.needsCrossStackResolver) logger.warn("Container Environment / Secrets entries contain Fn::ImportValue / Fn::GetStackOutput intrinsics. Pass a state-source flag (e.g. --from-cfn-stack or a host-provided extension) to substitute them against deployed state.");
|
|
24767
|
+
} else if (!stateProvider && taskNeeds.needsCrossStackResolver) logger.warn("Container Environment / Secrets / Command entries contain Fn::ImportValue / Fn::GetStackOutput intrinsics. Pass a state-source flag (e.g. --from-cfn-stack or a host-provided extension) to substitute them against deployed state.");
|
|
24768
|
+
assertEcsTaskCommandsResolved(service.task);
|
|
24368
24769
|
const effectiveAssumeRole = resolveEcsAssumeRoleOption(options);
|
|
24369
24770
|
let assumedCredentials;
|
|
24370
24771
|
let resolvedRoleArn;
|
|
@@ -24466,7 +24867,7 @@ async function resolveAlbLambdaTargetEnv(plan, options, extraStateProviders) {
|
|
|
24466
24867
|
for (const [logicalId, lambda] of lambdas) out.set(logicalId, await resolveLambdaContainerEnv(lambda, envOptions, profileCredentials, extraStateProviders));
|
|
24467
24868
|
return out;
|
|
24468
24869
|
}
|
|
24469
|
-
async function buildFrontDoor(plan, options, logger, extraStateProviders) {
|
|
24870
|
+
async function buildFrontDoor(plan, options, logger, extraStateProviders, onLambdaRunner) {
|
|
24470
24871
|
const containerHost = options.containerHost;
|
|
24471
24872
|
const servers = [];
|
|
24472
24873
|
const poolRegistry = /* @__PURE__ */ new Map();
|
|
@@ -24487,6 +24888,7 @@ async function buildFrontDoor(plan, options, logger, extraStateProviders) {
|
|
|
24487
24888
|
...containerEnv !== void 0 && containerEnv.sensitiveEnvKeys.length > 0 && { sensitiveEnvKeys: new Set(containerEnv.sensitiveEnvKeys) }
|
|
24488
24889
|
});
|
|
24489
24890
|
lambdaRegistry.set(t.lambda.logicalId, runner);
|
|
24891
|
+
onLambdaRunner?.(runner);
|
|
24490
24892
|
}
|
|
24491
24893
|
const boundRunner = runner;
|
|
24492
24894
|
return {
|
|
@@ -24816,7 +25218,7 @@ async function buildEcsImageResolutionContext$1(target, stacks, options, statePr
|
|
|
24816
25218
|
if (!roleRecordUsable) ctx.ignoreStateForRoles = true;
|
|
24817
25219
|
const wantsPseudoForEnvOrSecret = !!stateProvider && needs.needsEnvOrSecretSubstitution;
|
|
24818
25220
|
if (needs.needsPseudoParameters || wantsPseudoForEnvOrSecret) {
|
|
24819
|
-
const region = options.region ??
|
|
25221
|
+
const region = options.region ?? namedEnvAwsRegion() ?? process.env["AWS_DEFAULT_REGION"] ?? regionOrAmbientDefault(candidate.region);
|
|
24820
25222
|
if (!region) logger.warn(`Resolver references \${AWS::Region} but ${getEmbedConfig().binaryName} could not determine the target region. Pass --region, set AWS_REGION, or declare env.region on the CDK stack.`);
|
|
24821
25223
|
let accountId;
|
|
24822
25224
|
try {
|
|
@@ -24857,7 +25259,7 @@ async function buildEcsImageResolutionContext$1(target, stacks, options, statePr
|
|
|
24857
25259
|
} else if (!stateProvider && needs.needsStateResources) {
|
|
24858
25260
|
if (!opts.suppressStateWarning && !opts.imageOverridden) logger.warn("Container Image references a same-stack AWS::ECR::Repository. Pass a state-source flag (e.g. --from-cfn-stack or a host-provided extension) to substitute the deployed repository URI, or --image-override to build it from a local Dockerfile.");
|
|
24859
25261
|
} else if (!stateProvider && needs.needsEnvOrSecretSubstitution) {
|
|
24860
|
-
if (!opts.suppressStateWarning) logger.warn("Container Environment / Secrets entries contain CloudFormation intrinsics. Pass a state-source flag (e.g. --from-cfn-stack or a host-provided extension) to substitute them against the deployed state.");
|
|
25262
|
+
if (!opts.suppressStateWarning) logger.warn("Container Environment / Secrets / Command entries contain CloudFormation intrinsics. Pass a state-source flag (e.g. --from-cfn-stack or a host-provided extension) to substitute them against the deployed state; without one an intrinsic Command / EntryPoint / HealthCheck.Command element refuses the run.");
|
|
24861
25263
|
}
|
|
24862
25264
|
return ctx;
|
|
24863
25265
|
}
|
|
@@ -25155,14 +25557,15 @@ async function localRunTaskCommand(target, options, extraStateProviders) {
|
|
|
25155
25557
|
const taskStack = stacks.find((s) => s.stackName === task.stack.stackName) ?? task.stack;
|
|
25156
25558
|
const taskNeeds = detectEcsImageResolutionNeeds(taskStack);
|
|
25157
25559
|
if (stateProvider && taskNeeds.needsCrossStackResolver) {
|
|
25158
|
-
const consumerRegion = options.region ??
|
|
25560
|
+
const consumerRegion = options.region ?? namedEnvAwsRegion() ?? process.env["AWS_DEFAULT_REGION"] ?? regionOrAmbientDefault(task.stack.region) ?? "us-east-1";
|
|
25159
25561
|
const resolver = await stateProvider.buildCrossStackResolver(consumerRegion);
|
|
25160
25562
|
if (resolver) await applyCrossStackValuesToTask(task, resolver, {
|
|
25161
25563
|
imageContext,
|
|
25162
25564
|
consumerRegion,
|
|
25163
25565
|
profile: options.profile
|
|
25164
25566
|
});
|
|
25165
|
-
} else if (!stateProvider && taskNeeds.needsCrossStackResolver) logger.warn("Container Environment / Secrets entries contain Fn::ImportValue / Fn::GetStackOutput intrinsics. Pass a state-source flag (e.g. --from-cfn-stack or a host-provided extension) to substitute them against deployed state.");
|
|
25567
|
+
} else if (!stateProvider && taskNeeds.needsCrossStackResolver) logger.warn("Container Environment / Secrets / Command entries contain Fn::ImportValue / Fn::GetStackOutput intrinsics. Pass a state-source flag (e.g. --from-cfn-stack or a host-provided extension) to substitute them against deployed state.");
|
|
25568
|
+
assertEcsTaskCommandsResolved(task);
|
|
25166
25569
|
const onSignal = createShutdownSignalHandler({
|
|
25167
25570
|
cleanup,
|
|
25168
25571
|
stoppingMessage: () => "Stopping task...",
|
|
@@ -25312,7 +25715,7 @@ async function buildEcsImageResolutionContext(candidate, stateProvider, options,
|
|
|
25312
25715
|
if (!roleRecordUsable) ctx.ignoreStateForRoles = true;
|
|
25313
25716
|
const wantsPseudoForEnvOrSecret = !!stateProvider && needs.needsEnvOrSecretSubstitution;
|
|
25314
25717
|
if (needs.needsPseudoParameters || wantsPseudoForEnvOrSecret) {
|
|
25315
|
-
const region = options.region ??
|
|
25718
|
+
const region = options.region ?? namedEnvAwsRegion() ?? process.env["AWS_DEFAULT_REGION"] ?? regionOrAmbientDefault(candidate.region);
|
|
25316
25719
|
if (!region) logger.warn(`Resolver references \${AWS::Region} but ${getEmbedConfig().binaryName} could not determine the target region. Pass --region, set AWS_REGION, or declare env.region on the CDK stack.`);
|
|
25317
25720
|
let accountId;
|
|
25318
25721
|
try {
|
|
@@ -25352,7 +25755,7 @@ async function buildEcsImageResolutionContext(candidate, stateProvider, options,
|
|
|
25352
25755
|
if (needs.needsEnvOrSecretSubstitution && stateProviderFor) await loadMixedModeContainerStates(ctx, candidate, stateProviderFor);
|
|
25353
25756
|
} else if (!stateProvider && needs.needsStateResources) {
|
|
25354
25757
|
if (!options.imageOverride?.length) logger.warn("Container Image references a same-stack AWS::ECR::Repository. Pass a state-source flag (e.g. --from-cfn-stack or a host-provided extension) to substitute the deployed repository URI, or --image-override to build it from a local Dockerfile. Otherwise the resolver will surface its existing error.");
|
|
25355
|
-
} else if (!stateProvider && needs.needsEnvOrSecretSubstitution) logger.warn("Container Environment / Secrets entries contain CloudFormation intrinsics (Ref / Fn::GetAtt / Fn::Sub / Fn::Join). Pass a state-source flag (e.g. --from-cfn-stack or a host-provided extension) to substitute them against deployed state. Without a state source
|
|
25758
|
+
} else if (!stateProvider && needs.needsEnvOrSecretSubstitution) logger.warn("Container Environment / Secrets / Command entries contain CloudFormation intrinsics (Ref / Fn::GetAtt / Fn::Sub / Fn::Join). Pass a state-source flag (e.g. --from-cfn-stack or a host-provided extension) to substitute them against deployed state. Without a state source the Environment / Secrets entries are dropped (per-key warnings will follow), and an intrinsic Command / EntryPoint / HealthCheck.Command element refuses the run.");
|
|
25356
25759
|
return ctx;
|
|
25357
25760
|
}
|
|
25358
25761
|
function pickCandidateStack(target, stacks) {
|
|
@@ -29117,6 +29520,7 @@ async function bootLambdaUrlOrigins(distribution, stacks, opts) {
|
|
|
29117
29520
|
containerEnv: containerEnv.env,
|
|
29118
29521
|
...containerEnv.sensitiveEnvKeys.length > 0 && { sensitiveEnvKeys: new Set(containerEnv.sensitiveEnvKeys) }
|
|
29119
29522
|
});
|
|
29523
|
+
opts.runnerSink?.push(runner);
|
|
29120
29524
|
logger.info(`Booting Lambda Function URL origin container for ${functionLogicalId} (the backing Lambda runs locally via RIE)...`);
|
|
29121
29525
|
await runner.start();
|
|
29122
29526
|
} catch (err) {
|
|
@@ -29139,6 +29543,14 @@ async function drainWebFunctionServes(serves) {
|
|
|
29139
29543
|
await Promise.all(batch.map((s) => s.teardown().catch(() => void 0)));
|
|
29140
29544
|
}
|
|
29141
29545
|
}
|
|
29546
|
+
async function drainLambdaRunners(runners) {
|
|
29547
|
+
let done = 0;
|
|
29548
|
+
while (done < runners.length) {
|
|
29549
|
+
const batch = runners.slice(done);
|
|
29550
|
+
done = runners.length;
|
|
29551
|
+
await Promise.all(batch.map((r) => r.stop().catch(() => void 0)));
|
|
29552
|
+
}
|
|
29553
|
+
}
|
|
29142
29554
|
const WEB_FUNCTION_ORIGIN_READY_TIMEOUT_MS = 6e4;
|
|
29143
29555
|
async function bootWebFunctionOrigins(distribution, stacks, opts) {
|
|
29144
29556
|
const logger = getLogger();
|
|
@@ -29207,6 +29619,7 @@ async function bootLambdaEdgeFunctions(distribution, stacks, opts) {
|
|
|
29207
29619
|
containerEnv: containerEnv.env,
|
|
29208
29620
|
...containerEnv.sensitiveEnvKeys.length > 0 && { sensitiveEnvKeys: new Set(containerEnv.sensitiveEnvKeys) }
|
|
29209
29621
|
});
|
|
29622
|
+
opts.runnerSink?.push(runner);
|
|
29210
29623
|
logger.info(`Booting Lambda@Edge container for ${functionLogicalId} (the function runs locally via RIE)...`);
|
|
29211
29624
|
await runner.start();
|
|
29212
29625
|
runners.push(runner);
|
|
@@ -29383,12 +29796,13 @@ async function localStartCloudFrontCommand(target, options, extraStateProviders,
|
|
|
29383
29796
|
await attachKvsModules(initial.distribution, initial.stacks, options, profileCredentials, logger, extraStateProviders);
|
|
29384
29797
|
const bootOpts = buildLambdaBootOptions(options, profileCredentials, extraStateProviders);
|
|
29385
29798
|
const webFunctionServes = [];
|
|
29799
|
+
const bootRunners = [];
|
|
29386
29800
|
let bootAborted = false;
|
|
29387
29801
|
const onBootSignal = (signal) => {
|
|
29388
29802
|
if (bootAborted) return;
|
|
29389
29803
|
bootAborted = true;
|
|
29390
|
-
logger.info(`Received ${signal} during start-up; removing the web function containers...`);
|
|
29391
|
-
drainWebFunctionServes(webFunctionServes).then(() => process.exit(signalExitCode(signal)));
|
|
29804
|
+
logger.info(`Received ${signal} during start-up; removing the web function containers and the Lambda containers started so far...`);
|
|
29805
|
+
Promise.all([drainWebFunctionServes(webFunctionServes), drainLambdaRunners(bootRunners)]).then(() => process.exit(signalExitCode(signal)));
|
|
29392
29806
|
};
|
|
29393
29807
|
const bootSigint = () => onBootSignal("SIGINT");
|
|
29394
29808
|
const bootSigterm = () => onBootSignal("SIGTERM");
|
|
@@ -29396,14 +29810,18 @@ async function localStartCloudFrontCommand(target, options, extraStateProviders,
|
|
|
29396
29810
|
process.off("SIGINT", bootSigint);
|
|
29397
29811
|
process.off("SIGTERM", bootSigterm);
|
|
29398
29812
|
};
|
|
29399
|
-
|
|
29400
|
-
|
|
29401
|
-
process.on("SIGTERM", bootSigterm);
|
|
29402
|
-
}
|
|
29403
|
-
const { invokers: lambdaInvokers, runners: lambdaRunners } = await bootLambdaUrlOrigins(initial.distribution, initial.stacks, bootOpts);
|
|
29404
|
-
const { invokers: edgeInvokers, runners: edgeRunners } = await bootLambdaEdgeFunctions(initial.distribution, initial.stacks, bootOpts);
|
|
29813
|
+
process.on("SIGINT", bootSigint);
|
|
29814
|
+
process.on("SIGTERM", bootSigterm);
|
|
29405
29815
|
let server;
|
|
29406
29816
|
try {
|
|
29817
|
+
const { invokers: lambdaInvokers } = await bootLambdaUrlOrigins(initial.distribution, initial.stacks, {
|
|
29818
|
+
...bootOpts,
|
|
29819
|
+
runnerSink: bootRunners
|
|
29820
|
+
});
|
|
29821
|
+
const { invokers: edgeInvokers } = await bootLambdaEdgeFunctions(initial.distribution, initial.stacks, {
|
|
29822
|
+
...bootOpts,
|
|
29823
|
+
runnerSink: bootRunners
|
|
29824
|
+
});
|
|
29407
29825
|
const webFunctions = await bootWebFunctionOrigins(initial.distribution, initial.stacks, {
|
|
29408
29826
|
...bootOpts,
|
|
29409
29827
|
sink: webFunctionServes
|
|
@@ -29424,7 +29842,7 @@ async function localStartCloudFrontCommand(target, options, extraStateProviders,
|
|
|
29424
29842
|
...webFunctions.targets.size > 0 && { webFunctionOrigins: webFunctions.targets }
|
|
29425
29843
|
});
|
|
29426
29844
|
} catch (err) {
|
|
29427
|
-
await Promise.all([...
|
|
29845
|
+
await Promise.all([...bootRunners.map((r) => r.stop().catch(() => void 0)), ...webFunctionServes.map((s) => s.teardown().catch(() => void 0))]);
|
|
29428
29846
|
if (bootAborted) return await new Promise(() => void 0);
|
|
29429
29847
|
disarmBootSignals();
|
|
29430
29848
|
throw err;
|
|
@@ -29476,7 +29894,7 @@ async function localStartCloudFrontCommand(target, options, extraStateProviders,
|
|
|
29476
29894
|
try {
|
|
29477
29895
|
await server.close();
|
|
29478
29896
|
} catch {}
|
|
29479
|
-
await Promise.all([...
|
|
29897
|
+
await Promise.all([...bootRunners.map((r) => r.stop().catch((err) => {
|
|
29480
29898
|
logger.debug(`Lambda runner stop failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
29481
29899
|
})), ...webFunctionServes.map((s) => s.teardown().catch((err) => {
|
|
29482
29900
|
logger.debug(`Web function server teardown failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -29850,6 +30268,21 @@ function resolveAgentCoreServePlan(protocol) {
|
|
|
29850
30268
|
};
|
|
29851
30269
|
}
|
|
29852
30270
|
async function localStartAgentCoreCommand(target, options, extraStateProviders, hostSynthesizer) {
|
|
30271
|
+
let boot;
|
|
30272
|
+
try {
|
|
30273
|
+
await serveAgentCore(target, options, extraStateProviders, hostSynthesizer, (b) => {
|
|
30274
|
+
boot = b;
|
|
30275
|
+
});
|
|
30276
|
+
} catch (err) {
|
|
30277
|
+
if (boot) {
|
|
30278
|
+
await boot.teardown().catch(() => void 0);
|
|
30279
|
+
if (boot.signalled()) await new Promise(() => void 0);
|
|
30280
|
+
boot.detachSignals();
|
|
30281
|
+
}
|
|
30282
|
+
throw err;
|
|
30283
|
+
}
|
|
30284
|
+
}
|
|
30285
|
+
async function serveAgentCore(target, options, extraStateProviders, hostSynthesizer, registerBoot) {
|
|
29853
30286
|
const logger = getLogger();
|
|
29854
30287
|
if (options.verbose) logger.setLevel("debug");
|
|
29855
30288
|
let containerId;
|
|
@@ -29861,9 +30294,12 @@ async function localStartAgentCoreCommand(target, options, extraStateProviders,
|
|
|
29861
30294
|
let reloadQueue;
|
|
29862
30295
|
let shuttingDown = false;
|
|
29863
30296
|
let tornDown = false;
|
|
29864
|
-
const
|
|
29865
|
-
|
|
30297
|
+
const startGuard = createContainerStartGuard({ cancelledCode: "LOCAL_START_AGENTCORE_CANCELLED" });
|
|
30298
|
+
let teardownPromise;
|
|
30299
|
+
const teardown = () => teardownPromise ??= doTeardown();
|
|
30300
|
+
const doTeardown = async () => {
|
|
29866
30301
|
tornDown = true;
|
|
30302
|
+
const pendingContainer = startGuard.stop();
|
|
29867
30303
|
await stopWatchReloads({
|
|
29868
30304
|
watcher,
|
|
29869
30305
|
queue: reloadQueue,
|
|
@@ -29879,6 +30315,7 @@ async function localStartAgentCoreCommand(target, options, extraStateProviders,
|
|
|
29879
30315
|
} catch (err) {
|
|
29880
30316
|
logger.debug(`streamLogs stop failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
29881
30317
|
}
|
|
30318
|
+
containerId ??= await pendingContainer;
|
|
29882
30319
|
if (containerId) try {
|
|
29883
30320
|
await removeContainer(containerId);
|
|
29884
30321
|
} catch (err) {
|
|
@@ -29891,6 +30328,28 @@ async function localStartAgentCoreCommand(target, options, extraStateProviders,
|
|
|
29891
30328
|
await profileCredsFile.dispose();
|
|
29892
30329
|
} catch {}
|
|
29893
30330
|
};
|
|
30331
|
+
const shutdown = createShutdownSignalHandler({
|
|
30332
|
+
cleanup: async () => {
|
|
30333
|
+
shuttingDown = true;
|
|
30334
|
+
await teardown().catch(() => void 0);
|
|
30335
|
+
},
|
|
30336
|
+
stoppingMessage: (signal) => `Received ${signal}, shutting down...`,
|
|
30337
|
+
forceExitHint: `Run 'docker ps -a --filter name=${getEmbedConfig().resourceNamePrefix}-' to find what is left.`,
|
|
30338
|
+
info: (m) => logger.info(m),
|
|
30339
|
+
warn: (m) => logger.warn(m)
|
|
30340
|
+
});
|
|
30341
|
+
const onSigint = () => shutdown("SIGINT");
|
|
30342
|
+
const onSigterm = () => shutdown("SIGTERM");
|
|
30343
|
+
process.on("SIGINT", onSigint);
|
|
30344
|
+
process.on("SIGTERM", onSigterm);
|
|
30345
|
+
registerBoot({
|
|
30346
|
+
teardown,
|
|
30347
|
+
detachSignals: () => {
|
|
30348
|
+
process.off("SIGINT", onSigint);
|
|
30349
|
+
process.off("SIGTERM", onSigterm);
|
|
30350
|
+
},
|
|
30351
|
+
signalled: () => shuttingDown
|
|
30352
|
+
});
|
|
29894
30353
|
await activateWorkloadAwsWiring(options);
|
|
29895
30354
|
warnIfEmulateRoleViaUnused(options.emulateRoleVia, {
|
|
29896
30355
|
roleFlag: "--assume-role",
|
|
@@ -29944,31 +30403,20 @@ async function localStartAgentCoreCommand(target, options, extraStateProviders,
|
|
|
29944
30403
|
const containerHost = options.containerHost;
|
|
29945
30404
|
const containerName = `${getEmbedConfig().resourceNamePrefix}-agentcore-${process.pid}-${Math.random().toString(36).slice(2, 8)}`;
|
|
29946
30405
|
logger.info(`Starting agent container (image=${image}, port=${containerHostPort} -> ${plan.containerPortLabel})...`);
|
|
29947
|
-
|
|
30406
|
+
const bootPort = containerHostPort;
|
|
30407
|
+
containerId = await startGuard.run(() => runDetached({
|
|
29948
30408
|
image,
|
|
29949
30409
|
mounts: [],
|
|
29950
30410
|
env: dockerEnv,
|
|
29951
30411
|
cmd: [],
|
|
29952
|
-
hostPort:
|
|
30412
|
+
hostPort: bootPort,
|
|
29953
30413
|
host: containerHost,
|
|
29954
30414
|
platform: options.platform,
|
|
29955
30415
|
name: containerName,
|
|
29956
30416
|
...plan.containerPort !== void 0 && { containerPort: plan.containerPort },
|
|
29957
30417
|
...sensitiveEnvKeys.size > 0 && { sensitiveEnvKeys }
|
|
29958
|
-
});
|
|
30418
|
+
}), containerName);
|
|
29959
30419
|
stopLogs = streamLogs(containerId);
|
|
29960
|
-
const shutdown = createShutdownSignalHandler({
|
|
29961
|
-
cleanup: async () => {
|
|
29962
|
-
shuttingDown = true;
|
|
29963
|
-
await teardown().catch(() => void 0);
|
|
29964
|
-
},
|
|
29965
|
-
stoppingMessage: (signal) => `Received ${signal}, shutting down...`,
|
|
29966
|
-
forceExitHint: `Run 'docker ps -a --filter name=${getEmbedConfig().resourceNamePrefix}-' to find what is left.`,
|
|
29967
|
-
info: (m) => logger.info(m),
|
|
29968
|
-
warn: (m) => logger.warn(m)
|
|
29969
|
-
});
|
|
29970
|
-
process.on("SIGINT", () => shutdown("SIGINT"));
|
|
29971
|
-
process.on("SIGTERM", () => shutdown("SIGTERM"));
|
|
29972
30420
|
try {
|
|
29973
30421
|
if (plan.readyPath === void 0) await waitForAgentCorePing(containerHost, containerHostPort, options.timeout);
|
|
29974
30422
|
else await waitForAgentCoreHttpReady(containerHost, containerHostPort, plan.readyPath, options.timeout);
|
|
@@ -36794,5 +37242,5 @@ function addStudioSpecificOptions(cmd) {
|
|
|
36794
37242
|
return cmd;
|
|
36795
37243
|
}
|
|
36796
37244
|
|
|
36797
|
-
export { postHook as $, AGENTCORE_HTTP_PROTOCOL as $a, probeHostGatewaySupport as $i, addImageOverrideOptions as $n, readProfileEndpointSettings as $o, resolveApiTargetSubset as $r, classifyS3Error as $t, microvmFidelityWarnings as A, isCfnFlagPresent as Aa, translateLambdaResponse as Ai, stripCloudFrontImport as An, AUTH_OFF_PLACEHOLDER_CREDENTIALS as Ao, A2A_CONTAINER_PORT as Ar, readContainerLogTail as At, MICROVM_WS_BASE_PROTOCOL as B, countTargets as Ba, ConnectionRegistry as Bi, createLocalStartAlbCommand as Bn, collectHostEndpointOverrides as Bo, AGENTCORE_SESSION_ID_HEADER as Br, parseWebFunctionBuildConfig as Bt, addListSpecificOptions as C, substituteEnvVarsFromState as Ca, attachAuthorizers as Ci, WEB_FUNCTION_REVISION_TYPE as Cn, assumedRoleRecorded as Co, setShadowReadyTimeoutMs as Cr, parseKvsFileOverrides as Ct, buildMicrovmLambdaView as D, UNNAMED_WORKLOAD as Da, isFunctionUrlOacFronted as Di, compileCloudFrontFunction as Dn, resetWorkloadIdentity as Do, createLocalInvokeAgentCoreCommand as Dr, WEB_FUNCTION_CONTAINER_PORT as Dt, addStartMicrovmSpecificOptions as E, LocalStateSourceError as Ea, buildCorsConfigFromCloudFrontChain as Ei, resolveWebFunctionTarget as En, recordAssumedRole as Eo, addInvokeAgentCoreSpecificOptions as Er, RecentOutput as Et, microvmImageTag as F, CfnLocalStateProvider as Fa, pickResponseTemplate as Fi, findFileAssetForObjectKey as Fn, HOST_DEFAULT_CREDENTIALS_MISS_TTL_MS as Fo, MCP_PROTOCOL_VERSION as Fr, buildNodeEntryFileStart as Ft, startMicrovmFrontDoor as G, filterWebSocketApisByIdentifiers as Ga, buildDisconnectEvent as Gi, addStartServiceSpecificOptions as Gn, getContainerJavaTruststorePath as Go, SUPPORTED_CODE_RUNTIMES as Gr, readWebFunctionServiceConfig as Gt, PROXY_PORT_HEADER as H, availableWebSocketApiIdentifiers as Ha, handleConnectionsRequest as Hi, resolveAlbTarget as Hn, effectiveLoopbackPorts as Ho, waitForAgentCoreHttpReady as Hr, WEB_FUNCTION_HTTP_ENDPOINT_ENV as Ht, planMicrovmPorts as I, collectSsmParameterRefs as Ia, selectIntegrationResponse as Ii, isBucketDeploymentResource as In, activateWorkloadAwsWiring as Io, mcpInvokeOnce as Ir, defaultWebFunctionPlatform as It, MICROVM_HOOK_PATH_PREFIX as J, discoverRoutes as Ja, createFileWatcher as Ji, addRunTaskSpecificOptions as Jn, loopbackForwarderPlan as Jo, renderCodeDockerfile as Jr, idFromArn as Jt, stripMicrovmProxyHeaders as K, parseSelectionExpressionPath as Ka, buildMessageEvent as Ki, createLocalStartServiceCommand as Kn, javaTruststoreToolOptions as Ko, buildAgentCoreCodeImage as Kr, webFunctionAssumeRole as Kt, readExposedPorts as L, resolveSsmParameters as La, tryParseStatus as Li, resolveBucketDeploymentObjectKey as Ln, applyWorkloadAwsWiringToEnv as Lo, parseSseForJsonRpc as Lr, resolveWebFunctionRuntime as Lt, DEFAULT_TERMINATE_HOOK_TIMEOUT_MS as M, resolveCfnFallbackRegion as Ma, buildHttpApiV2Event as Mi, createLocalFileKvsDataSource as Mn, DEFAULT_AWS_EMULATOR_URL as Mo, a2aInvokeOnce as Mr, waitForWebFunctionReady as Mt, LocalMicrovm as N, resolveCfnRegion as Na, buildRestV1Event as Ni, createUnboundCloudFrontModule as Nn, EMULATOR_SCRUBBED_ENV_KEYS as No, MCP_CONTAINER_PORT as Nr, watchContainerExit as Nt, createLocalStartMicrovmCommand as O, createLocalStateProvider as Oa, matchPreflight as Oi, runViewerRequest as On, workloadClientConfig as Oo, bridgeAgentCoreWs as Or, containerFailure as Ot, buildMicrovmImage as P, resolveCfnStackName as Pa, evaluateResponseParameters as Pi, bucketDeploymentSourceObjectKeys as Pn, HOST_CA_TRUST_ENV_KEYS as Po, MCP_PATH as Pr, WEB_FUNCTION_RUNTIMES as Pt, pollBuildHook as Q, AGENTCORE_AGUI_PROTOCOL as Qa, HOST_GATEWAY_MIN_VERSION as Qi, addEcsAssumeRoleOptions as Qn, readEmulatorRunFiles as Qo, createWatchPredicates as Qr, resolveDeployedOriginBucket as Qt, setContainerPaused as R, resolveWatchConfig as Ra, VtlEvaluationError as Ri, addAlbSpecificOptions as Rn, awsEmulatorEnvName as Ro, AGENTCORE_SIGV4_SERVICE as Rr, supportedWebFunctionRuntimes as Rt, StudioEventBus as S, substituteAgainstStateAsync as Sa, invokeTokenAuthorizer as Si, WEB_FUNCTION_ENDPOINT_TYPE as Sn, SECOND_ASSUME_MESSAGE as So, SOFT_RELOAD_COMPLETION_LOG_SUFFIX as Sr, normalizeKvsFileKeys as St, formatTargetListing as T, materializeLayerFromArn as Ta, buildCorsConfigByApiId as Ti, WebFunctionResolutionError as Tn, readEnvCallerCredentials as To, attachContainerLogStreamer as Tr, resolveCloudFrontTarget as Tt, rewriteUpgradeResponseHead as U, discoverWebSocketApis as Ua, parseConnectionsPath as Ui, isApplicationLoadBalancer as Un, getActiveWorkloadAwsWiring as Uo, waitForAgentCorePing as Ur, buildWebFunctionLambdaView as Ut, MicrovmStateError as V, listTargets as Va, buildMgmtEndpointEnvUrl as Vi, parseLbPortOverrides as Vn, displayEndpointValue as Vo, invokeAgentCore as Vr, resolveWebFunctionArtifact as Vt, selectTargetPort as W, discoverWebSocketApisOrThrow as Wa, buildConnectEvent as Wi, resolveAlbFrontDoor as Wn, getContainerCaBundlePath as Wo, downloadAndExtractS3Bundle as Wr, finalizeWebFunctionEnv as Wt, callRuntimeHook as X, resolveLambdaArnIntrinsic as Xa, createLocalInvokeCommand as Xi, MAX_TASKS_SUBNET_RANGE_CAP as Xn, parseAwsEndpoint as Xo, addStartApiSpecificOptions as Xr, createDeployedKvsDataSource as Xt, MicrovmHookError as Y, pickRefLogicalId as Ya, addInvokeSpecificOptions as Yi, createLocalRunTaskCommand as Yn, mergeJavaToolOptions as Yo, toCmdArgv as Yr, resolveKvsModulesForDistribution as Yt, generateMicrovmId as Z, AGENTCORE_A2A_PROTOCOL as Za, HOST_DOCKER_INTERNAL_GATEWAY as Zi, addCommonEcsServiceOptions as Zn, probeAwsEmulatorHealth as Zo, createLocalStartApiCommand as Zr, resolveDeployedKvsArnByName as Zt, filterStudioTargetGroups as _, resolveRuntimeFileExtension as _a, verifyJwtViaDiscovery as _i, pickKvsLogicalIdFromArn as _n, parseDynamicReference as _o, isLocalCdkAssetImage as _r, attachAgentCoreWsBridge as _t, createLocalStudioCommand as a, buildLoopbackForwarderDockerArgs as aa, filterRoutesByApiIdentifiers as ai, serveLambdaUrlOrigin as an, derivePseudoParametersFromRegion as ao, resolveSharedSidecarCredentials as ar, writeCaBundleFile as as, disposeMicrovmCodeArtifact as at, renderStudioHtml as b, assertEcsTaskImagesResolvable as ba, evaluateCachedLambdaPolicy as bi, pickWebFunctionEndpointLogicalIdFromOrigin as bn, addAwsEndpointOptions as bo, CloudMapRegistry as br, addStartCloudFrontSpecificOptions as bt, startStudioProxy as c, ensureForwarderImage as ca, startApiServer as ci, buildEdgeRequestEvent as cn, tryResolveImageFnJoin as co, buildImageOverrideTag as cr, isRealAwsHost as cs, resolveMicrovmImageTarget as ct, createStudioDispatcher as d, buildContainerImage as da, defaultCredentialsLoader as di, httpHeadersToEdge as dn, DynamicReferenceResolver as do, mergeForService as dr, rewriteSqsQueueUrlsInEnv as ds, createLocalStartWebFunctionCommand as dt, resolveHostGatewayExtraHosts as ea, createAuthorizerCache as ei, createS3OriginReader as en, AGENTCORE_MCP_PROTOCOL as eo, buildEcsImageResolutionContext$1 as er, resolveAwsEmulatorOption as es, runHookBody as et, filterStudioCustomResources as f, dockerRegistryEnv as fa, buildCognitoJwksUrl as fi, CLOUDFRONT_DISTRIBUTION_TYPE as fn, containsDynamicReference as fo, parseImageOverrideFlags as fr, sqsEmulatorOriginOf as fs, addStartAgentCoreSpecificOptions as ft, annotatePinnedEcsTargets as g, resolveRuntimeCodeMountPath as ga, verifyJwtAuthorizer as gi, pickFunctionUrlLogicalIdFromOrigin as gn, keysOverriddenBy as go, imageOverrideKeyAliases as gr, resolveProfileCredentials as gs, startAgentCoreHttpServer as gt, annotateEcsTaskPinnedTargets as h, stripEcrCredentials as ha, verifyCognitoJwt as hi, isCloudFrontDistribution as hn, keysNotFromTemplate as ho, describePinnedImageUri as hr, buildStsClientConfig as hs, selectServeInboundAuth as ht, coerceStopRequest as i, awaitLoopbackForwarderStatus as ia, filterRoutesByApiIdentifier as ii, serveFromStaticOrigin as in, resolveAgentCoreTarget as io, resolveEcsAssumeRoleOption as ir, takeAwsEmulatorStateSourceHint as is, MicrovmResolutionError as it, readRunHookPayload as j, rejectExplicitCfnStackWithMultipleStacks as ja, applyAuthorizerOverlay as ji, createCloudFrontModule as jn, CA_TRUST_ENV_KEYS as jo, A2A_PATH as jr, startWebFunctionContainer as jt, finalizeMicrovmEnv as k, groupWorkloadsRoutedApart as ka, matchRoute as ki, runViewerResponse as kn, workloadStsClientConfig as ko, invokeAgentCoreWs as kr, planWebFunctionContainer as kt, relayServeRequest as l, startLoopbackForwarder as la, resolveSelectionExpression as li, buildEdgeResponseEvent as ln, LocalInvokeBuildError as lo, canonicalizeImageOverrideKeys as lr, realSqsHostnames as ls, s3KeyOfUri as lt, annotateAlbPinnedBackingServices as m, noImplicitEcrPullArgs as ma, createJwksCache as mi, extractKvsAssociations as mn, firstUsableRegion as mo, runImageOverrideBuilds as mr, createMixedModeTlsMaterials as ms, buildAgentCoreServeAuthCheck as mt, coerceRunRequest as n, withWorkloadAwsWiring as na, buildStageMap as ni, startCloudFrontServer as nn, AgentCoreResolutionError as no, parseMaxTasks as nr, resolveWorkloadAwsWiring as ns, MICROVM_DEFAULT_INGRESS_PORT as nt, resolveServeBaseUrl as o, buildNamespaceOwnerForwarderDockerArgs as oa, groupRoutesByServer as oi, applyEdgeRequestResult as on, formatStateRemedy as oo, runEcsServiceEmulator as or, MIXED_MODE_RESIGN_BODY_CAP_BYTES as os, readMicrovmImageConfig as ot, isCustomResourceLambdaTarget as p, isEcrRegistryConfigKey as pa, buildJwksUrlFromIssuer as pi, describeS3OriginDomain as pn, deployedFillMayBeSecret as po, resolveImageOverrides as pr, buildJavaTrustStore as ps, createLocalStartAgentCoreCommand as pt, MAX_RUN_HOOK_PAYLOAD_BYTES as q, webSocketApiMatchesIdentifier as qa, classifySourceChange as qi, serviceStrategy as qn, logMixedModeForWorkload as qo, computeCodeImageTag as qr, webFunctionFidelityWarnings as qt, coerceServeRequest as r, LOOPBACK_FORWARDER_IMAGE as ra, availableApiIdentifiers as ri, resolveErrorResponseCandidates as rn, pickAgentCoreCandidateStack as ro, parseRestartPolicy as rr, setActiveWorkloadAwsWiring as rs, MICROVM_IMAGE_TYPE as rt, createStudioServeManager as s, describeForwarderFailure as sa, readMtlsMaterialsFromDisk as si, applyEdgeResponseResult as sn, substituteImagePlaceholders as so, ImageOverrideError as sr, REAL_SQS_QUEUE_URL as ss, resolveMicrovmCodeArtifact as st, addStudioSpecificOptions as t, attachLoopbackForwarder as ta, attachStageContext as ti, matchBehavior as tn, AGENTCORE_RUNTIME_TYPE as to, ecsClusterOption as tr, resolveHostDefaultCredentials as ts, waitForAppAnswer as tt, reinvoke as u, architectureToPlatform as ua, resolveServiceIntegrationParameters as ui, edgeHeadersToHttp as un, DynamicReferenceResolutionError as uo, enforceImageOverrideOrphans as ur, repointLocalSqsQueueUrlsInEnv as us, addStartWebFunctionSpecificOptions as ut, startStudioServer as v, resolveRuntimeImage as va, buildMethodArn as vi, pickLambdaEdgeFunctionLogicalId as vn, resolveDynamicReferencesInEnv as vo, listPinnedTargets as vr, startAgentCoreWsBridge as vt, createLocalListCommand as w, substituteEnvVarsFromStateAsync as wa, applyCorsResponseHeaders as wi, WEB_FUNCTION_TYPE as wn, deployAccountStsClientConfig as wo, getContainerNetworkIp as wr, parseOriginOverrides as wt, createStudioStore as x, substituteAgainstState as xa, invokeRequestAuthorizer as xi, resolveCloudFrontDistribution as xn, awsEndpointOptions as xo, DEFAULT_SHADOW_READY_TIMEOUT_MS as xr, createLocalStartCloudFrontCommand as xt, toStudioTargetGroups as y, EcsTaskResolutionError as ya, computeRequestIdentityHash as yi, pickTargetFunctionLogicalId as yn, withoutKeys as yo, buildCloudMapIndex as yr, LocalStartCloudFrontError as yt, MICROVM_CONTROL_PATH as z, resolveSingleTarget as za, bufferToBody as zi, albStrategy as zn, awsEmulatorSqsHostBlocks as zo, signAgentCoreInvocation as zr, disposeWebFunctionArtifact as zt };
|
|
36798
|
-
//# sourceMappingURL=local-studio-
|
|
37245
|
+
export { postHook as $, AGENTCORE_A2A_PROTOCOL as $a, probeHostGatewaySupport as $i, addImageOverrideOptions as $n, loopbackForwarderPlan as $o, resolveApiTargetSubset as $r, classifyS3Error as $t, microvmFidelityWarnings as A, createLocalStateProvider as Aa, translateLambdaResponse as Ai, stripCloudFrontImport as An, readEnvCallerCredentials as Ao, A2A_CONTAINER_PORT as Ar, readContainerLogTail as At, MICROVM_WS_BASE_PROTOCOL as B, resolveWatchConfig as Ba, ConnectionRegistry as Bi, createLocalStartAlbCommand as Bn, HOST_DEFAULT_CREDENTIALS_MISS_TTL_MS as Bo, AGENTCORE_SESSION_ID_HEADER as Br, parseWebFunctionBuildConfig as Bt, addListSpecificOptions as C, substituteAgainstState as Ca, attachAuthorizers as Ci, WEB_FUNCTION_REVISION_TYPE as Cn, resolveDynamicReferencesInEnv as Co, setShadowReadyTimeoutMs as Cr, parseKvsFileOverrides as Ct, buildMicrovmLambdaView as D, materializeLayerFromArn as Da, isFunctionUrlOacFronted as Di, compileCloudFrontFunction as Dn, SECOND_ASSUME_MESSAGE as Do, createLocalInvokeAgentCoreCommand as Dr, WEB_FUNCTION_CONTAINER_PORT as Dt, addStartMicrovmSpecificOptions as E, substituteEnvVarsFromStateAsync as Ea, buildCorsConfigFromCloudFrontChain as Ei, resolveWebFunctionTarget as En, awsEndpointOptions as Eo, addInvokeAgentCoreSpecificOptions as Er, RecentOutput as Et, microvmImageTag as F, resolveCfnRegion as Fa, pickResponseTemplate as Fi, findFileAssetForObjectKey as Fn, AUTH_OFF_PLACEHOLDER_CREDENTIALS as Fo, MCP_PROTOCOL_VERSION as Fr, buildNodeEntryFileStart as Ft, startMicrovmFrontDoor as G, discoverWebSocketApis as Ga, buildDisconnectEvent as Gi, addStartServiceSpecificOptions as Gn, collectHostEndpointOverrides as Go, SUPPORTED_CODE_RUNTIMES as Gr, readWebFunctionServiceConfig as Gt, PROXY_PORT_HEADER as H, countTargets as Ha, handleConnectionsRequest as Hi, resolveAlbTarget as Hn, applyWorkloadAwsWiringToEnv as Ho, waitForAgentCoreHttpReady as Hr, WEB_FUNCTION_HTTP_ENDPOINT_ENV as Ht, planMicrovmPorts as I, resolveCfnStackName as Ia, selectIntegrationResponse as Ii, isBucketDeploymentResource as In, CA_TRUST_ENV_KEYS as Io, mcpInvokeOnce as Ir, defaultWebFunctionPlatform as It, MICROVM_HOOK_PATH_PREFIX as J, parseSelectionExpressionPath as Ja, createFileWatcher as Ji, addRunTaskSpecificOptions as Jn, getActiveWorkloadAwsWiring as Jo, renderCodeDockerfile as Jr, idFromArn as Jt, stripMicrovmProxyHeaders as K, discoverWebSocketApisOrThrow as Ka, buildMessageEvent as Ki, createLocalStartServiceCommand as Kn, displayEndpointValue as Ko, buildAgentCoreCodeImage as Kr, webFunctionAssumeRole as Kt, readExposedPorts as L, CfnLocalStateProvider as La, tryParseStatus as Li, resolveBucketDeploymentObjectKey as Ln, DEFAULT_AWS_EMULATOR_URL as Lo, parseSseForJsonRpc as Lr, resolveWebFunctionRuntime as Lt, DEFAULT_TERMINATE_HOOK_TIMEOUT_MS as M, isCfnFlagPresent as Ma, buildHttpApiV2Event as Mi, createLocalFileKvsDataSource as Mn, resetWorkloadIdentity as Mo, a2aInvokeOnce as Mr, waitForWebFunctionReady as Mt, LocalMicrovm as N, rejectExplicitCfnStackWithMultipleStacks as Na, buildRestV1Event as Ni, createUnboundCloudFrontModule as Nn, workloadClientConfig as No, MCP_CONTAINER_PORT as Nr, watchContainerExit as Nt, createLocalStartMicrovmCommand as O, LocalStateSourceError as Oa, matchPreflight as Oi, runViewerRequest as On, assumedRoleRecorded as Oo, bridgeAgentCoreWs as Or, containerFailure as Ot, buildMicrovmImage as P, resolveCfnFallbackRegion as Pa, evaluateResponseParameters as Pi, bucketDeploymentSourceObjectKeys as Pn, workloadStsClientConfig as Po, MCP_PATH as Pr, WEB_FUNCTION_RUNTIMES as Pt, pollBuildHook as Q, resolveLambdaArnIntrinsic as Qa, HOST_GATEWAY_MIN_VERSION as Qi, addEcsAssumeRoleOptions as Qn, logMixedModeForWorkload as Qo, createWatchPredicates as Qr, resolveDeployedOriginBucket as Qt, setContainerPaused as R, collectSsmParameterRefs as Ra, VtlEvaluationError as Ri, addAlbSpecificOptions as Rn, EMULATOR_SCRUBBED_ENV_KEYS as Ro, AGENTCORE_SIGV4_SERVICE as Rr, supportedWebFunctionRuntimes as Rt, StudioEventBus as S, containsCrossStackIntrinsic as Sa, invokeTokenAuthorizer as Si, WEB_FUNCTION_ENDPOINT_TYPE as Sn, parseDynamicReference as So, SOFT_RELOAD_COMPLETION_LOG_SUFFIX as Sr, normalizeKvsFileKeys as St, formatTargetListing as T, substituteEnvVarsFromState as Ta, buildCorsConfigByApiId as Ti, WebFunctionResolutionError as Tn, addAwsEndpointOptions as To, attachContainerLogStreamer as Tr, resolveCloudFrontTarget as Tt, rewriteUpgradeResponseHead as U, listTargets as Ua, parseConnectionsPath as Ui, isApplicationLoadBalancer as Un, awsEmulatorEnvName as Uo, waitForAgentCorePing as Ur, buildWebFunctionLambdaView as Ut, MicrovmStateError as V, resolveSingleTarget as Va, buildMgmtEndpointEnvUrl as Vi, parseLbPortOverrides as Vn, activateWorkloadAwsWiring as Vo, invokeAgentCore as Vr, resolveWebFunctionArtifact as Vt, selectTargetPort as W, availableWebSocketApiIdentifiers as Wa, buildConnectEvent as Wi, resolveAlbFrontDoor as Wn, awsEmulatorSqsHostBlocks as Wo, downloadAndExtractS3Bundle as Wr, finalizeWebFunctionEnv as Wt, callRuntimeHook as X, discoverRoutes as Xa, createLocalInvokeCommand as Xi, MAX_TASKS_SUBNET_RANGE_CAP as Xn, getContainerJavaTruststorePath as Xo, addStartApiSpecificOptions as Xr, createDeployedKvsDataSource as Xt, MicrovmHookError as Y, webSocketApiMatchesIdentifier as Ya, addInvokeSpecificOptions as Yi, createLocalRunTaskCommand as Yn, getContainerCaBundlePath as Yo, toCmdArgv as Yr, resolveKvsModulesForDistribution as Yt, generateMicrovmId as Z, pickRefLogicalId as Za, HOST_DOCKER_INTERNAL_GATEWAY as Zi, addCommonEcsServiceOptions as Zn, javaTruststoreToolOptions as Zo, createLocalStartApiCommand as Zr, resolveDeployedKvsArnByName as Zt, filterStudioTargetGroups as _, resolveRuntimeFileExtension as _a, verifyJwtViaDiscovery as _i, pickKvsLogicalIdFromArn as _n, containsDynamicReference as _o, isLocalCdkAssetImage as _r, sqsEmulatorOriginOf as _s, attachAgentCoreWsBridge as _t, createLocalStudioCommand as a, buildLoopbackForwarderDockerArgs as aa, filterRoutesByApiIdentifiers as ai, serveLambdaUrlOrigin as an, pickAgentCoreCandidateStack as ao, resolveSharedSidecarCredentials as ar, resolveAwsEmulatorOption as as, disposeMicrovmCodeArtifact as at, renderStudioHtml as b, assertEcsTaskCommandsResolved as ba, evaluateCachedLambdaPolicy as bi, pickWebFunctionEndpointLogicalIdFromOrigin as bn, keysNotFromTemplate as bo, CloudMapRegistry as br, buildStsClientConfig as bs, addStartCloudFrontSpecificOptions as bt, startStudioProxy as c, ensureForwarderImage as ca, startApiServer as ci, buildEdgeRequestEvent as cn, formatStateRemedy as co, buildImageOverrideTag as cr, setActiveWorkloadAwsWiring as cs, resolveMicrovmImageTarget as ct, createStudioDispatcher as d, buildContainerImage as da, defaultCredentialsLoader as di, httpHeadersToEdge as dn, LocalInvokeBuildError as do, mergeForService as dr, MIXED_MODE_RESIGN_BODY_CAP_BYTES as ds, createLocalStartWebFunctionCommand as dt, resolveHostGatewayExtraHosts as ea, createAuthorizerCache as ei, createS3OriginReader as en, AGENTCORE_AGUI_PROTOCOL as eo, buildEcsImageResolutionContext$1 as er, mergeJavaToolOptions as es, runHookBody as et, filterStudioCustomResources as f, dockerRegistryEnv as fa, buildCognitoJwksUrl as fi, CLOUDFRONT_DISTRIBUTION_TYPE as fn, ambientDefaultRegion as fo, parseImageOverrideFlags as fr, REAL_SQS_QUEUE_URL as fs, addStartAgentCoreSpecificOptions as ft, annotatePinnedEcsTargets as g, resolveRuntimeCodeMountPath as ga, verifyJwtAuthorizer as gi, pickFunctionUrlLogicalIdFromOrigin as gn, DynamicReferenceResolver as go, imageOverrideKeyAliases as gr, rewriteSqsQueueUrlsInEnv as gs, startAgentCoreHttpServer as gt, annotateEcsTaskPinnedTargets as h, stripEcrCredentials as ha, verifyCognitoJwt as hi, isCloudFrontDistribution as hn, DynamicReferenceResolutionError as ho, describePinnedImageUri as hr, repointLocalSqsQueueUrlsInEnv as hs, selectServeInboundAuth as ht, coerceStopRequest as i, awaitLoopbackForwarderStatus as ia, filterRoutesByApiIdentifier as ii, serveFromStaticOrigin as in, AgentCoreResolutionError as io, resolveEcsAssumeRoleOption as ir, readProfileEndpointSettings as is, MicrovmResolutionError as it, readRunHookPayload as j, groupWorkloadsRoutedApart as ja, applyAuthorizerOverlay as ji, createCloudFrontModule as jn, recordAssumedRole as jo, A2A_PATH as jr, startWebFunctionContainer as jt, finalizeMicrovmEnv as k, UNNAMED_WORKLOAD as ka, matchRoute as ki, runViewerResponse as kn, deployAccountStsClientConfig as ko, invokeAgentCoreWs as kr, planWebFunctionContainer as kt, relayServeRequest as l, startLoopbackForwarder as la, resolveSelectionExpression as li, buildEdgeResponseEvent as ln, substituteImagePlaceholders as lo, canonicalizeImageOverrideKeys as lr, takeAwsEmulatorStateSourceHint as ls, s3KeyOfUri as lt, annotateAlbPinnedBackingServices as m, noImplicitEcrPullArgs as ma, createJwksCache as mi, extractKvsAssociations as mn, setAmbientDefaultRegion as mo, runImageOverrideBuilds as mr, realSqsHostnames as ms, buildAgentCoreServeAuthCheck as mt, coerceRunRequest as n, withWorkloadAwsWiring as na, buildStageMap as ni, startCloudFrontServer as nn, AGENTCORE_MCP_PROTOCOL as no, parseMaxTasks as nr, probeAwsEmulatorHealth as ns, MICROVM_DEFAULT_INGRESS_PORT as nt, resolveServeBaseUrl as o, buildNamespaceOwnerForwarderDockerArgs as oa, groupRoutesByServer as oi, applyEdgeRequestResult as on, resolveAgentCoreTarget as oo, runEcsServiceEmulator as or, resolveHostDefaultCredentials as os, readMicrovmImageConfig as ot, isCustomResourceLambdaTarget as p, isEcrRegistryConfigKey as pa, buildJwksUrlFromIssuer as pi, describeS3OriginDomain as pn, namedEnvAwsRegion as po, resolveImageOverrides as pr, isRealAwsHost as ps, createLocalStartAgentCoreCommand as pt, MAX_RUN_HOOK_PAYLOAD_BYTES as q, filterWebSocketApisByIdentifiers as qa, classifySourceChange as qi, serviceStrategy as qn, effectiveLoopbackPorts as qo, computeCodeImageTag as qr, webFunctionFidelityWarnings as qt, coerceServeRequest as r, LOOPBACK_FORWARDER_IMAGE as ra, availableApiIdentifiers as ri, resolveErrorResponseCandidates as rn, AGENTCORE_RUNTIME_TYPE as ro, parseRestartPolicy as rr, readEmulatorRunFiles as rs, MICROVM_IMAGE_TYPE as rt, createStudioServeManager as s, describeForwarderFailure as sa, readMtlsMaterialsFromDisk as si, applyEdgeResponseResult as sn, derivePseudoParametersFromRegion as so, ImageOverrideError as sr, resolveWorkloadAwsWiring as ss, resolveMicrovmCodeArtifact as st, addStudioSpecificOptions as t, attachLoopbackForwarder as ta, attachStageContext as ti, matchBehavior as tn, AGENTCORE_HTTP_PROTOCOL as to, ecsClusterOption as tr, parseAwsEndpoint as ts, waitForAppAnswer as tt, reinvoke as u, architectureToPlatform as ua, resolveServiceIntegrationParameters as ui, edgeHeadersToHttp as un, tryResolveImageFnJoin as uo, enforceImageOverrideOrphans as ur, writeCaBundleFile as us, addStartWebFunctionSpecificOptions as ut, startStudioServer as v, resolveRuntimeImage as va, buildMethodArn as vi, pickLambdaEdgeFunctionLogicalId as vn, deployedFillMayBeSecret as vo, listPinnedTargets as vr, buildJavaTrustStore as vs, startAgentCoreWsBridge as vt, createLocalListCommand as w, substituteAgainstStateAsync as wa, applyCorsResponseHeaders as wi, WEB_FUNCTION_TYPE as wn, withoutKeys as wo, getContainerNetworkIp as wr, parseOriginOverrides as wt, createStudioStore as x, assertEcsTaskImagesResolvable as xa, invokeRequestAuthorizer as xi, resolveCloudFrontDistribution as xn, keysOverriddenBy as xo, DEFAULT_SHADOW_READY_TIMEOUT_MS as xr, resolveProfileCredentials as xs, createLocalStartCloudFrontCommand as xt, toStudioTargetGroups as y, EcsTaskResolutionError as ya, computeRequestIdentityHash as yi, pickTargetFunctionLogicalId as yn, firstUsableRegion as yo, buildCloudMapIndex as yr, createMixedModeTlsMaterials as ys, LocalStartCloudFrontError as yt, MICROVM_CONTROL_PATH as z, resolveSsmParameters as za, bufferToBody as zi, albStrategy as zn, HOST_CA_TRUST_ENV_KEYS as zo, signAgentCoreInvocation as zr, disposeWebFunctionArtifact as zt };
|
|
37246
|
+
//# sourceMappingURL=local-studio-B0Wlk_VO.js.map
|