@go-to-k/cdkd 0.116.1 → 0.117.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
@@ -35783,6 +35783,7 @@ function extractLambdaProperties(stack, logicalId, resource, resources) {
35783
35783
  const props = resource.Properties ?? {};
35784
35784
  const memoryMb = typeof props["MemorySize"] === "number" ? props["MemorySize"] : 128;
35785
35785
  const timeoutSec = typeof props["Timeout"] === "number" ? props["Timeout"] : 3;
35786
+ const ephemeralStorageMb = extractEphemeralStorageMb(props, logicalId);
35786
35787
  const code = props["Code"] ?? {};
35787
35788
  const imageUri = extractImageUri(code["ImageUri"], logicalId, stack.stackName, resources);
35788
35789
  if (imageUri !== void 0) return extractImageLambdaProperties({
@@ -35792,7 +35793,8 @@ function extractLambdaProperties(stack, logicalId, resource, resources) {
35792
35793
  memoryMb,
35793
35794
  timeoutSec,
35794
35795
  props,
35795
- imageUri
35796
+ imageUri,
35797
+ ...ephemeralStorageMb !== void 0 && { ephemeralStorageMb }
35796
35798
  });
35797
35799
  const runtime = typeof props["Runtime"] === "string" ? props["Runtime"] : "";
35798
35800
  const handler = typeof props["Handler"] === "string" ? props["Handler"] : "";
@@ -35813,10 +35815,44 @@ function extractLambdaProperties(stack, logicalId, resource, resources) {
35813
35815
  timeoutSec,
35814
35816
  codePath,
35815
35817
  layers,
35818
+ ...ephemeralStorageMb !== void 0 && { ephemeralStorageMb },
35816
35819
  ...inlineCode !== void 0 && { inlineCode }
35817
35820
  };
35818
35821
  }
35819
35822
  /**
35823
+ * Parse `Properties.EphemeralStorage.Size` (issue #440). CFn shape:
35824
+ * `{ EphemeralStorage: { Size: <MiB> } }`. CDK's
35825
+ * `cdk.Size.gibibytes(N)` serializes to `N * 1024`. AWS-side range is
35826
+ * 512..10240 MiB (the deployed function rejects anything outside that
35827
+ * range at create time); cdkd rejects > 10240 here so a misconfigured
35828
+ * template fails fast at `cdkd local invoke` boot rather than hanging
35829
+ * on a `docker run` that AWS would have refused anyway. The 512 floor
35830
+ * is AWS's minimum (the default when `EphemeralStorage` is omitted is
35831
+ * also 512), but we deliberately accept values DOWN to 1 so users can
35832
+ * exercise the cap with a deliberately-small `/tmp` in local tests —
35833
+ * `--tmpfs /tmp:size=Nm` itself enforces no lower bound; the only
35834
+ * cross-check is "would AWS accept this?", which the deploy side
35835
+ * already gates upstream.
35836
+ *
35837
+ * Returns `undefined` when the property is absent, NaN, < 1, or
35838
+ * non-numeric. Hard-rejects > 10240. Intrinsic-valued sizes (the
35839
+ * `{ Ref: 'SomeParam' }` shape that's uncommon for EphemeralStorage
35840
+ * but theoretically valid) drop to `undefined` with a one-line warn
35841
+ * via the calling logger — local invoke can't resolve those without
35842
+ * the template's Parameters context the deploy engine has, and the
35843
+ * fallback (no `--tmpfs`) is safer than guessing.
35844
+ */
35845
+ function extractEphemeralStorageMb(props, logicalId) {
35846
+ const raw = props["EphemeralStorage"];
35847
+ if (raw === void 0 || raw === null) return void 0;
35848
+ if (typeof raw !== "object" || Array.isArray(raw)) return void 0;
35849
+ const size = raw["Size"];
35850
+ if (typeof size !== "number") return;
35851
+ if (!Number.isFinite(size) || size < 1) return void 0;
35852
+ if (size > 10240) throw new LocalInvokeResolutionError(`Lambda '${logicalId}' has Properties.EphemeralStorage.Size = ${size} MiB, which exceeds the AWS limit of 10240 MiB. AWS would reject the function at deploy time; cap the value to <= 10240 (10 GiB) and retry.`);
35853
+ return Math.floor(size);
35854
+ }
35855
+ /**
35820
35856
  * Extract the `Code.ImageUri` value across the shapes CDK actually synthesizes.
35821
35857
  *
35822
35858
  * Supported shapes:
@@ -35868,7 +35904,7 @@ function extractImageUri(value, logicalId, stackName, resources) {
35868
35904
  * optional in CFn — the defaults match the AWS-side defaults.
35869
35905
  */
35870
35906
  function extractImageLambdaProperties(args) {
35871
- const { stack, logicalId, resource, memoryMb, timeoutSec, props, imageUri } = args;
35907
+ const { stack, logicalId, resource, memoryMb, timeoutSec, ephemeralStorageMb, props, imageUri } = args;
35872
35908
  const rawImageConfig = props["ImageConfig"] ?? {};
35873
35909
  const imageConfig = {};
35874
35910
  if (Array.isArray(rawImageConfig["Command"])) imageConfig.command = rawImageConfig["Command"].filter((s) => typeof s === "string");
@@ -35892,7 +35928,8 @@ function extractImageLambdaProperties(args) {
35892
35928
  imageUri,
35893
35929
  imageConfig,
35894
35930
  architecture,
35895
- layers: []
35931
+ layers: [],
35932
+ ...ephemeralStorageMb !== void 0 && { ephemeralStorageMb }
35896
35933
  };
35897
35934
  }
35898
35935
  /**
@@ -37432,6 +37469,7 @@ async function runDetached(opts) {
37432
37469
  args.push("-v", `${mount.hostPath}:${mount.containerPath}${ro}`);
37433
37470
  }
37434
37471
  for (const [k, v] of Object.entries(opts.env)) args.push("-e", `${k}=${v}`);
37472
+ if (opts.tmpfs) args.push("--tmpfs", `${opts.tmpfs.target}:rw,size=${opts.tmpfs.sizeMb}m`);
37435
37473
  if (opts.workingDir) args.push("--workdir", opts.workingDir);
37436
37474
  let entryPointTail = [];
37437
37475
  if (opts.entryPoint && opts.entryPoint.length > 0) {
@@ -38882,7 +38920,8 @@ function createContainerPool(specs, options) {
38882
38920
  hostPort,
38883
38921
  host: spec.containerHost,
38884
38922
  name,
38885
- ...spec.debugPort !== void 0 && { debugPort: spec.debugPort }
38923
+ ...spec.debugPort !== void 0 && { debugPort: spec.debugPort },
38924
+ ...spec.tmpfs !== void 0 && { tmpfs: spec.tmpfs }
38886
38925
  });
38887
38926
  const stopLogStream = streamingEnabled ? streamLogs(containerId) : () => void 0;
38888
38927
  try {
@@ -42313,13 +42352,18 @@ async function buildContainerSpec(args) {
42313
42352
  if (stsRegion) dockerEnv["AWS_REGION"] = stsRegion;
42314
42353
  } else forwardAwsEnv$1(dockerEnv);
42315
42354
  if (debugPort !== void 0) dockerEnv["NODE_OPTIONS"] = `--inspect-brk=0.0.0.0:${debugPort}`;
42355
+ const tmpfs = lambda.ephemeralStorageMb !== void 0 ? {
42356
+ target: "/tmp",
42357
+ sizeMb: lambda.ephemeralStorageMb
42358
+ } : void 0;
42316
42359
  return {
42317
42360
  lambda,
42318
42361
  codeDir,
42319
42362
  env: dockerEnv,
42320
42363
  containerHost,
42321
42364
  ...optDir !== void 0 && { optDir },
42322
- ...debugPort !== void 0 && { debugPort }
42365
+ ...debugPort !== void 0 && { debugPort },
42366
+ ...tmpfs !== void 0 && { tmpfs }
42323
42367
  };
42324
42368
  }
42325
42369
  /**
@@ -42371,6 +42415,7 @@ function resolveLambdaByLogicalId(logicalId, stacks) {
42371
42415
  let codePath = null;
42372
42416
  if (!inlineCode) codePath = resolveAssetCodePath(stack, logicalId, resource);
42373
42417
  const layers = resolveLambdaLayers(stack, logicalId, props);
42418
+ const ephemeralStorageMb = extractEphemeralStorageMb(props, logicalId);
42374
42419
  return {
42375
42420
  kind: "zip",
42376
42421
  stack,
@@ -42382,7 +42427,8 @@ function resolveLambdaByLogicalId(logicalId, stacks) {
42382
42427
  timeoutSec,
42383
42428
  codePath,
42384
42429
  layers,
42385
- ...inlineCode !== void 0 && { inlineCode }
42430
+ ...inlineCode !== void 0 && { inlineCode },
42431
+ ...ephemeralStorageMb !== void 0 && { ephemeralStorageMb }
42386
42432
  };
42387
42433
  }
42388
42434
  throw new Error(`No AWS::Lambda::Function resource named '${logicalId}' found in target stacks. This is likely a synthesis bug — the route-discovery phase resolved a route to this logical ID.`);
@@ -43940,7 +43986,8 @@ async function localInvokeCommand(target, options) {
43940
43986
  ...debugPort !== void 0 && { debugPort },
43941
43987
  ...imagePlan.platform !== void 0 && { platform: imagePlan.platform },
43942
43988
  ...imagePlan.entryPoint !== void 0 && { entryPoint: imagePlan.entryPoint },
43943
- ...imagePlan.workingDir !== void 0 && { workingDir: imagePlan.workingDir }
43989
+ ...imagePlan.workingDir !== void 0 && { workingDir: imagePlan.workingDir },
43990
+ ...imagePlan.tmpfs !== void 0 && { tmpfs: imagePlan.tmpfs }
43944
43991
  });
43945
43992
  stopLogs = streamLogs(containerId);
43946
43993
  sigintHandler = () => {
@@ -43987,6 +44034,7 @@ async function resolveZipImagePlan(lambda, options) {
43987
44034
  await pullImage(image, options.pull === false);
43988
44035
  const layerPlan = materializeLambdaLayers(lambda.layers);
43989
44036
  const containerCodePath = resolveRuntimeCodeMountPath(lambda.runtime);
44037
+ const tmpfs = resolveTmpfsForLambda(lambda);
43990
44038
  return {
43991
44039
  image,
43992
44040
  mounts: [{
@@ -43997,7 +44045,36 @@ async function resolveZipImagePlan(lambda, options) {
43997
44045
  extraMounts: layerPlan.mount ? [layerPlan.mount] : [],
43998
44046
  cmd: [lambda.handler],
43999
44047
  ...inlineTmpDir !== void 0 && { inlineTmpDir },
44000
- ...layerPlan.tmpDir !== void 0 && { layersTmpDir: layerPlan.tmpDir }
44048
+ ...layerPlan.tmpDir !== void 0 && { layersTmpDir: layerPlan.tmpDir },
44049
+ ...tmpfs !== void 0 && { tmpfs }
44050
+ };
44051
+ }
44052
+ /**
44053
+ * Build the `--tmpfs /tmp:rw,size=<N>m` plan for a Lambda (issue #440).
44054
+ *
44055
+ * The shape is identical for ZIP and IMAGE Lambdas — `--tmpfs` overlays
44056
+ * mount-time inside any container, regardless of whether the image is a
44057
+ * public Lambda base image (ZIP path) or a user-built container Lambda.
44058
+ * Returns `undefined` when the template did not declare
44059
+ * `EphemeralStorage`, in which case the caller emits no `--tmpfs` flag
44060
+ * and the container's `/tmp` is whatever the base image provides
44061
+ * (matches pre-#440 behavior). The lambda-resolver's
44062
+ * `extractEphemeralStorageMb` already enforces the AWS 10240 MiB
44063
+ * ceiling at parse time.
44064
+ *
44065
+ * Target path is always `/tmp` — AWS Lambda's `/tmp` is the ONLY
44066
+ * sized-tmpfs surface the `EphemeralStorage.Size` property controls,
44067
+ * and the constant is centralized here so a future fixture / docs
44068
+ * update has a single grep target.
44069
+ */
44070
+ function resolveTmpfsForLambda(lambda) {
44071
+ if (lambda.ephemeralStorageMb === void 0) return void 0;
44072
+ const logger = getLogger();
44073
+ if (lambda.kind === "image") logger.info(`Lambda ${lambda.logicalId}: capping /tmp at ${lambda.ephemeralStorageMb} MiB via --tmpfs (overlays any base-image /tmp content)`);
44074
+ else logger.debug(`Lambda ${lambda.logicalId}: applying EphemeralStorage cap via --tmpfs /tmp:size=${lambda.ephemeralStorageMb}m`);
44075
+ return {
44076
+ target: "/tmp",
44077
+ sizeMb: lambda.ephemeralStorageMb
44001
44078
  };
44002
44079
  }
44003
44080
  /**
@@ -44065,6 +44142,7 @@ async function resolveContainerImagePlan(lambda, options) {
44065
44142
  ...options.region !== void 0 && { region: options.region }
44066
44143
  });
44067
44144
  }
44145
+ const tmpfs = resolveTmpfsForLambda(lambda);
44068
44146
  return {
44069
44147
  image: imageRef,
44070
44148
  mounts: [],
@@ -44072,7 +44150,8 @@ async function resolveContainerImagePlan(lambda, options) {
44072
44150
  cmd: lambda.imageConfig.command ?? [],
44073
44151
  platform,
44074
44152
  ...lambda.imageConfig.entryPoint && lambda.imageConfig.entryPoint.length > 0 && { entryPoint: lambda.imageConfig.entryPoint },
44075
- ...lambda.imageConfig.workingDirectory !== void 0 && { workingDir: lambda.imageConfig.workingDirectory }
44153
+ ...lambda.imageConfig.workingDirectory !== void 0 && { workingDir: lambda.imageConfig.workingDirectory },
44154
+ ...tmpfs !== void 0 && { tmpfs }
44076
44155
  };
44077
44156
  }
44078
44157
  /**
@@ -45642,7 +45721,7 @@ function reorderArgs(argv) {
45642
45721
  */
45643
45722
  async function main() {
45644
45723
  const program = new Command();
45645
- program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.116.1");
45724
+ program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.117.0");
45646
45725
  program.addCommand(createBootstrapCommand());
45647
45726
  program.addCommand(createSynthCommand());
45648
45727
  program.addCommand(createListCommand());