cdk-local 0.26.0 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { W as createLocalInvokeCommand, o as createLocalRunTaskCommand, r as createLocalStartServiceCommand, s as createLocalStartApiCommand, t as createLocalListCommand } from "./local-list-
|
|
2
|
+
import { W as createLocalInvokeCommand, o as createLocalRunTaskCommand, r as createLocalStartServiceCommand, s as createLocalStartApiCommand, t as createLocalListCommand } from "./local-list-KUEmeW9J.js";
|
|
3
3
|
import { Command } from "commander";
|
|
4
4
|
|
|
5
5
|
//#region src/cli/index.ts
|
|
6
6
|
const program = new Command();
|
|
7
|
-
program.name("cdkl").description("Run AWS CDK stacks locally with Docker.").version("0.
|
|
7
|
+
program.name("cdkl").description("Run AWS CDK stacks locally with Docker.").version("0.27.0");
|
|
8
8
|
program.addCommand(createLocalInvokeCommand());
|
|
9
9
|
program.addCommand(createLocalStartApiCommand());
|
|
10
10
|
program.addCommand(createLocalRunTaskCommand());
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { c as getEmbedConfig, l as resetEmbedConfig, u as setEmbedConfig } from "./docker-cmd-DvoehoBl.js";
|
|
2
|
-
import { $ as materializeLayerFromArn, A as matchRoute, B as parseConnectionsPath, C as evaluateCachedLambdaPolicy, D as buildCorsConfigByApiId, E as applyCorsResponseHeaders, F as HOST_GATEWAY_MIN_VERSION, G as resolveRuntimeCodeMountPath, H as buildDisconnectEvent, I as probeHostGatewaySupport, J as substituteAgainstState, K as resolveRuntimeFileExtension, L as ConnectionRegistry, M as applyAuthorizerOverlay, N as buildHttpApiV2Event, O as buildCorsConfigFromCloudFrontChain, P as buildRestV1Event, Q as resolveEnvVars, R as buildMgmtEndpointEnvUrl, S as computeRequestIdentityHash, T as invokeTokenAuthorizer, U as buildMessageEvent, V as buildConnectEvent, W as createLocalInvokeCommand, X as substituteEnvVarsFromState, Y as substituteAgainstStateAsync, Z as substituteEnvVarsFromStateAsync, _ as buildJwksUrlFromIssuer, _t as pickRefLogicalId, a as getContainerNetworkIp, at as isCfnFlagPresent, b as verifyJwtAuthorizer, c as createAuthorizerCache, ct as resolveCfnRegion, d as availableApiIdentifiers, dt as countTargets, et as derivePseudoParametersFromRegion, f as filterRoutesByApiIdentifier, ft as listTargets, g as buildCognitoJwksUrl, gt as discoverRoutes, h as resolveServiceIntegrationParameters, ht as parseSelectionExpressionPath, i as CloudMapRegistry, it as createLocalStateProvider, j as translateLambdaResponse, k as matchPreflight, l as attachStageContext, lt as resolveCfnStackName, m as resolveSelectionExpression, mt as discoverWebSocketApisOrThrow, n as formatTargetListing, nt as tryResolveImageFnJoin, o as createLocalRunTaskCommand, ot as rejectExplicitCfnStackWithMultipleStacks, p as groupRoutesByServer, pt as discoverWebSocketApis, q as resolveRuntimeImage, r as createLocalStartServiceCommand, rt as LocalStateSourceError, s as createLocalStartApiCommand, st as resolveCfnFallbackRegion, t as createLocalListCommand, tt as substituteImagePlaceholders, u as buildStageMap, ut as CfnLocalStateProvider, v as createJwksCache, vt as resolveLambdaArnIntrinsic, w as invokeRequestAuthorizer, x as buildMethodArn, y as verifyCognitoJwt, z as handleConnectionsRequest } from "./local-list-
|
|
2
|
+
import { $ as materializeLayerFromArn, A as matchRoute, B as parseConnectionsPath, C as evaluateCachedLambdaPolicy, D as buildCorsConfigByApiId, E as applyCorsResponseHeaders, F as HOST_GATEWAY_MIN_VERSION, G as resolveRuntimeCodeMountPath, H as buildDisconnectEvent, I as probeHostGatewaySupport, J as substituteAgainstState, K as resolveRuntimeFileExtension, L as ConnectionRegistry, M as applyAuthorizerOverlay, N as buildHttpApiV2Event, O as buildCorsConfigFromCloudFrontChain, P as buildRestV1Event, Q as resolveEnvVars, R as buildMgmtEndpointEnvUrl, S as computeRequestIdentityHash, T as invokeTokenAuthorizer, U as buildMessageEvent, V as buildConnectEvent, W as createLocalInvokeCommand, X as substituteEnvVarsFromState, Y as substituteAgainstStateAsync, Z as substituteEnvVarsFromStateAsync, _ as buildJwksUrlFromIssuer, _t as pickRefLogicalId, a as getContainerNetworkIp, at as isCfnFlagPresent, b as verifyJwtAuthorizer, c as createAuthorizerCache, ct as resolveCfnRegion, d as availableApiIdentifiers, dt as countTargets, et as derivePseudoParametersFromRegion, f as filterRoutesByApiIdentifier, ft as listTargets, g as buildCognitoJwksUrl, gt as discoverRoutes, h as resolveServiceIntegrationParameters, ht as parseSelectionExpressionPath, i as CloudMapRegistry, it as createLocalStateProvider, j as translateLambdaResponse, k as matchPreflight, l as attachStageContext, lt as resolveCfnStackName, m as resolveSelectionExpression, mt as discoverWebSocketApisOrThrow, n as formatTargetListing, nt as tryResolveImageFnJoin, o as createLocalRunTaskCommand, ot as rejectExplicitCfnStackWithMultipleStacks, p as groupRoutesByServer, pt as discoverWebSocketApis, q as resolveRuntimeImage, r as createLocalStartServiceCommand, rt as LocalStateSourceError, s as createLocalStartApiCommand, st as resolveCfnFallbackRegion, t as createLocalListCommand, tt as substituteImagePlaceholders, u as buildStageMap, ut as CfnLocalStateProvider, v as createJwksCache, vt as resolveLambdaArnIntrinsic, w as invokeRequestAuthorizer, x as buildMethodArn, y as verifyCognitoJwt, z as handleConnectionsRequest } from "./local-list-KUEmeW9J.js";
|
|
3
3
|
|
|
4
4
|
export { CfnLocalStateProvider, CloudMapRegistry, ConnectionRegistry, HOST_GATEWAY_MIN_VERSION, LocalStateSourceError, applyAuthorizerOverlay, applyCorsResponseHeaders, attachStageContext, availableApiIdentifiers, buildCognitoJwksUrl, buildConnectEvent, buildCorsConfigByApiId, buildCorsConfigFromCloudFrontChain, buildDisconnectEvent, buildHttpApiV2Event, buildJwksUrlFromIssuer, buildMessageEvent, buildMethodArn, buildMgmtEndpointEnvUrl, buildRestV1Event, buildStageMap, computeRequestIdentityHash, countTargets, createAuthorizerCache, createJwksCache, createLocalInvokeCommand, createLocalListCommand, createLocalRunTaskCommand, createLocalStartApiCommand, createLocalStartServiceCommand, createLocalStateProvider, derivePseudoParametersFromRegion, discoverRoutes, discoverWebSocketApis, discoverWebSocketApisOrThrow, evaluateCachedLambdaPolicy, filterRoutesByApiIdentifier, formatTargetListing, getContainerNetworkIp, getEmbedConfig, groupRoutesByServer, handleConnectionsRequest, invokeRequestAuthorizer, invokeTokenAuthorizer, isCfnFlagPresent, listTargets, matchPreflight, matchRoute, materializeLayerFromArn, parseConnectionsPath, parseSelectionExpressionPath, pickRefLogicalId, probeHostGatewaySupport, rejectExplicitCfnStackWithMultipleStacks, resetEmbedConfig, resolveCfnFallbackRegion, resolveCfnRegion, resolveCfnStackName, resolveEnvVars, resolveLambdaArnIntrinsic, resolveRuntimeCodeMountPath, resolveRuntimeFileExtension, resolveRuntimeImage, resolveSelectionExpression, resolveServiceIntegrationParameters, setEmbedConfig, substituteAgainstState, substituteAgainstStateAsync, substituteEnvVarsFromState, substituteEnvVarsFromStateAsync, substituteImagePlaceholders, translateLambdaResponse, tryResolveImageFnJoin, verifyCognitoJwt, verifyJwtAuthorizer };
|
|
@@ -16402,18 +16402,18 @@ const METADATA_ENDPOINT_IP = "169.254.170.2";
|
|
|
16402
16402
|
const DEFAULT_METADATA_ENDPOINT_SUBNET = "169.254.170.0/24";
|
|
16403
16403
|
/**
|
|
16404
16404
|
* Pure-functional subnet allocator. `cdkl run-task` uses the
|
|
16405
|
-
* default subnet; `cdkl start-service`
|
|
16406
|
-
*
|
|
16407
|
-
*
|
|
16408
|
-
*
|
|
16409
|
-
*
|
|
16410
|
-
* docker's `--subnet`
|
|
16405
|
+
* default subnet (octet 170); `cdkl start-service` uses a SINGLE
|
|
16406
|
+
* shared network at the fixed octet `SHARED_SVC_SUBNET_OCTET = 171`
|
|
16407
|
+
* (one octet up from run-task so the two CLI variants can coexist on
|
|
16408
|
+
* the same host). The link-local 169.254.0.0/16 space is reserved
|
|
16409
|
+
* AWS-wide for cloud metadata so collisions with user workloads are
|
|
16410
|
+
* unlikely, but the fixed /24 still keeps docker's `--subnet`
|
|
16411
|
+
* allocator from rejecting "Pool overlaps".
|
|
16411
16412
|
*
|
|
16412
16413
|
* `subnetOctet` is the second-from-last byte of the network: 170 →
|
|
16413
16414
|
* 169.254.170.0/24 (default), 171 → 169.254.171.0/24, etc. Valid
|
|
16414
|
-
* range is 1..254
|
|
16415
|
-
*
|
|
16416
|
-
* keeps the allocation logic in one place.
|
|
16415
|
+
* range is 1..254 — exported here so callers keep the CIDR /
|
|
16416
|
+
* sidecar-IP derivation in one place.
|
|
16417
16417
|
*/
|
|
16418
16418
|
function buildEndpointSubnet(subnetOctet) {
|
|
16419
16419
|
if (subnetOctet < 1 || subnetOctet > 254 || !Number.isInteger(subnetOctet)) throw new Error(`buildEndpointSubnet: subnetOctet must be an integer in 1..254 (got ${subnetOctet}).`);
|
|
@@ -16445,7 +16445,9 @@ const SHARED_SVC_SUBNET_OCTET = 171;
|
|
|
16445
16445
|
* CLI tears down ONCE at the end of the run.
|
|
16446
16446
|
*/
|
|
16447
16447
|
async function createSharedSvcNetwork(options = {}) {
|
|
16448
|
-
const
|
|
16448
|
+
const prefix = options.prefix ?? getEmbedConfig().resourceNamePrefix;
|
|
16449
|
+
await sweepOrphanedSvcNetworks(prefix);
|
|
16450
|
+
const networkName = `${prefix}-svc-${randomBytes(4).toString("hex")}`;
|
|
16449
16451
|
const { cidr, sidecarIp } = buildEndpointSubnet(171);
|
|
16450
16452
|
return {
|
|
16451
16453
|
networkName,
|
|
@@ -16462,6 +16464,81 @@ async function createSharedSvcNetwork(options = {}) {
|
|
|
16462
16464
|
};
|
|
16463
16465
|
}
|
|
16464
16466
|
/**
|
|
16467
|
+
* Startup orphan sweep for the shared `cdkl start-service` network
|
|
16468
|
+
* (Issue #93, design Option 1). When a `start-service` run is interrupted
|
|
16469
|
+
* before its end-of-run teardown, the shared `<prefix>-svc-<rand>` network
|
|
16470
|
+
* and its `<prefix>-svc-<rand>-metadata` sidecar LEAK. Because
|
|
16471
|
+
* `start-service` pins a single fixed subnet (`SHARED_SVC_SUBNET_OCTET`),
|
|
16472
|
+
* the next run's `docker network create` always fails with
|
|
16473
|
+
* "Pool overlaps with other one on this address space" — a state that,
|
|
16474
|
+
* unlike a port conflict, never self-heals. This sweep detects and removes
|
|
16475
|
+
* leaked `<prefix>-svc-*` networks that have NO live owner before the next
|
|
16476
|
+
* run re-creates the network.
|
|
16477
|
+
*
|
|
16478
|
+
* Classification heuristic: a `<prefix>-svc-*` network is ORPHANED when its
|
|
16479
|
+
* only attached container is its own `<name>-metadata` sidecar (or it has
|
|
16480
|
+
* zero attached containers). A network that still has a non-metadata
|
|
16481
|
+
* (user replica) container attached is a live concurrent run and is LEFT
|
|
16482
|
+
* untouched. Caveat: "only the metadata sidecar attached ⇒ orphan" can
|
|
16483
|
+
* misclassify a network in the sub-second window between sidecar start and
|
|
16484
|
+
* the first replica attach — so a second `start-service` launched in that
|
|
16485
|
+
* window could reclaim a concurrently-starting run's network out from under
|
|
16486
|
+
* it. This is an accepted limitation, not a benign one: start-service pins a
|
|
16487
|
+
* single fixed subnet, so two concurrent same-prefix runs were never
|
|
16488
|
+
* supported (the second run's `docker network create` already fails with
|
|
16489
|
+
* "Pool overlaps"). The sweep therefore cannot regress a
|
|
16490
|
+
* previously-working scenario.
|
|
16491
|
+
*
|
|
16492
|
+
* Resilient by design: a `docker network ls` / `inspect` failure must not
|
|
16493
|
+
* abort the run — it logs at debug and skips, matching the idempotent
|
|
16494
|
+
* teardown style in this file. Returns the list of swept network names.
|
|
16495
|
+
*/
|
|
16496
|
+
async function sweepOrphanedSvcNetworks(prefix) {
|
|
16497
|
+
const logger = getLogger().child("ecs-network");
|
|
16498
|
+
const filter = `${prefix}-svc-`;
|
|
16499
|
+
let names;
|
|
16500
|
+
try {
|
|
16501
|
+
const { stdout } = await execFileAsync$2(getDockerCmd(), [
|
|
16502
|
+
"network",
|
|
16503
|
+
"ls",
|
|
16504
|
+
"--filter",
|
|
16505
|
+
`name=${filter}`,
|
|
16506
|
+
"--format",
|
|
16507
|
+
"{{.Name}}"
|
|
16508
|
+
]);
|
|
16509
|
+
names = stdout.split("\n").map((n) => n.trim()).filter((n) => n.length > 0);
|
|
16510
|
+
} catch (err) {
|
|
16511
|
+
const e = err;
|
|
16512
|
+
logger.debug(`docker network ls (sweep) failed: ${e.stderr || e.message || String(err)}`);
|
|
16513
|
+
return [];
|
|
16514
|
+
}
|
|
16515
|
+
const swept = [];
|
|
16516
|
+
for (const name of names) {
|
|
16517
|
+
let attached;
|
|
16518
|
+
try {
|
|
16519
|
+
const { stdout } = await execFileAsync$2(getDockerCmd(), [
|
|
16520
|
+
"network",
|
|
16521
|
+
"inspect",
|
|
16522
|
+
name,
|
|
16523
|
+
"--format",
|
|
16524
|
+
"{{range .Containers}}{{.Name}} {{end}}"
|
|
16525
|
+
]);
|
|
16526
|
+
attached = stdout.split(/\s+/).map((c) => c.trim()).filter((c) => c.length > 0);
|
|
16527
|
+
} catch (err) {
|
|
16528
|
+
const e = err;
|
|
16529
|
+
logger.debug(`docker network inspect ${name} (sweep) failed: ${e.stderr || e.message || String(err)}`);
|
|
16530
|
+
continue;
|
|
16531
|
+
}
|
|
16532
|
+
const sidecarName = `${name}-metadata`;
|
|
16533
|
+
if (attached.some((c) => c !== sidecarName)) continue;
|
|
16534
|
+
logger.info(`Reclaiming orphaned shared network ${name} (no live owner)...`);
|
|
16535
|
+
await removeContainer(sidecarName);
|
|
16536
|
+
await destroyNetworkOnly(name);
|
|
16537
|
+
swept.push(name);
|
|
16538
|
+
}
|
|
16539
|
+
return swept;
|
|
16540
|
+
}
|
|
16541
|
+
/**
|
|
16465
16542
|
* Internal helper shared by `createTaskNetwork` (per-task) and
|
|
16466
16543
|
* `createSharedSvcNetwork` (per-CLI-run). Creates the docker network,
|
|
16467
16544
|
* pulls the sidecar image, and starts the sidecar at the documented
|
|
@@ -19123,4 +19200,4 @@ function createLocalListCommand(opts = {}) {
|
|
|
19123
19200
|
|
|
19124
19201
|
//#endregion
|
|
19125
19202
|
export { materializeLayerFromArn as $, matchRoute as A, parseConnectionsPath as B, evaluateCachedLambdaPolicy as C, buildCorsConfigByApiId as D, applyCorsResponseHeaders as E, HOST_GATEWAY_MIN_VERSION as F, resolveRuntimeCodeMountPath as G, buildDisconnectEvent as H, probeHostGatewaySupport as I, substituteAgainstState as J, resolveRuntimeFileExtension as K, ConnectionRegistry as L, applyAuthorizerOverlay as M, buildHttpApiV2Event as N, buildCorsConfigFromCloudFrontChain as O, buildRestV1Event as P, resolveEnvVars as Q, buildMgmtEndpointEnvUrl as R, computeRequestIdentityHash as S, invokeTokenAuthorizer as T, buildMessageEvent as U, buildConnectEvent as V, createLocalInvokeCommand as W, substituteEnvVarsFromState as X, substituteAgainstStateAsync as Y, substituteEnvVarsFromStateAsync as Z, buildJwksUrlFromIssuer as _, pickRefLogicalId as _t, getContainerNetworkIp as a, isCfnFlagPresent as at, verifyJwtAuthorizer as b, createAuthorizerCache as c, resolveCfnRegion as ct, availableApiIdentifiers as d, countTargets as dt, derivePseudoParametersFromRegion as et, filterRoutesByApiIdentifier as f, listTargets as ft, buildCognitoJwksUrl as g, discoverRoutes as gt, resolveServiceIntegrationParameters as h, parseSelectionExpressionPath as ht, CloudMapRegistry as i, createLocalStateProvider as it, translateLambdaResponse as j, matchPreflight as k, attachStageContext as l, resolveCfnStackName as lt, resolveSelectionExpression as m, discoverWebSocketApisOrThrow as mt, formatTargetListing as n, tryResolveImageFnJoin as nt, createLocalRunTaskCommand as o, rejectExplicitCfnStackWithMultipleStacks as ot, groupRoutesByServer as p, discoverWebSocketApis as pt, resolveRuntimeImage as q, createLocalStartServiceCommand as r, LocalStateSourceError as rt, createLocalStartApiCommand as s, resolveCfnFallbackRegion as st, createLocalListCommand as t, substituteImagePlaceholders as tt, buildStageMap as u, CfnLocalStateProvider as ut, createJwksCache as v, resolveLambdaArnIntrinsic as vt, invokeRequestAuthorizer as w, buildMethodArn as x, verifyCognitoJwt as y, handleConnectionsRequest as z };
|
|
19126
|
-
//# sourceMappingURL=local-list-
|
|
19203
|
+
//# sourceMappingURL=local-list-KUEmeW9J.js.map
|