@go-to-k/cdkd 0.209.1 → 0.210.1

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/README.md CHANGED
@@ -251,10 +251,11 @@ The Docker-backed commands above require Docker. Pass `--from-state`
251
251
  substitute deployed physical IDs into intrinsic-valued env vars /
252
252
  secrets / image URIs; without either, intrinsic values are dropped with
253
253
  a per-key warning (matches `sam local *`). The two flags are mutually
254
- exclusive. `start-cloudfront` is the partial exception: a
255
- CloudFront-Functions + S3-origin distribution serves entirely in-process
256
- (no Docker), and it carries cdk-local's `--from-cfn-stack` but not cdkd's
257
- `--from-state` (its factory lacks the state-provider seam issue #766).
254
+ exclusive. `start-cloudfront` carries both `--from-state` and
255
+ `--from-cfn-stack` too (since cdk-local 0.128.0 / issue #766); a
256
+ CloudFront-Functions + S3-origin distribution still serves entirely
257
+ in-process (no Docker), while a Lambda Function URL origin runs via the
258
+ RIE container.
258
259
 
259
260
  ### `local invoke`
260
261
 
package/dist/cli.js CHANGED
@@ -43823,6 +43823,7 @@ function extractLambdaProperties(stack, logicalId, resource, resources) {
43823
43823
  handler,
43824
43824
  memoryMb,
43825
43825
  timeoutSec,
43826
+ architecture: extractArchitecture(props, logicalId),
43826
43827
  codePath,
43827
43828
  layers,
43828
43829
  ...ephemeralStorageMb !== void 0 && { ephemeralStorageMb },
@@ -43910,6 +43911,24 @@ function extractImageUri$1(value, logicalId, stackName, resources, region) {
43910
43911
  }
43911
43912
  }
43912
43913
  /**
43914
+ * Parse `Properties.Architectures` into the single arch cdkd threads to
43915
+ * `--platform`. CFn types it as an array, but CDK / Lambda allow exactly
43916
+ * one entry; default `x86_64` matches the AWS-side default when the
43917
+ * property is absent. Shared by BOTH the ZIP and IMAGE variants (issue
43918
+ * #768) so the ZIP container run pins `--platform` the same way the IMAGE
43919
+ * path always has.
43920
+ */
43921
+ function extractArchitecture(props, logicalId) {
43922
+ const arches = props["Architectures"];
43923
+ if (Array.isArray(arches) && arches.length > 0) {
43924
+ const first = arches[0];
43925
+ if (first === "arm64") return "arm64";
43926
+ if (first === "x86_64") return "x86_64";
43927
+ throw new LocalInvokeResolutionError(`Lambda '${logicalId}' has unsupported Architectures value '${String(first)}'. cdkd local invoke supports x86_64 and arm64.`);
43928
+ }
43929
+ return "x86_64";
43930
+ }
43931
+ /**
43913
43932
  * Build the IMAGE-variant `ResolvedLambda` from a Lambda template entry
43914
43933
  * with `Code.ImageUri`. `ImageConfig` and `Architectures` are both
43915
43934
  * optional in CFn — the defaults match the AWS-side defaults.
@@ -43921,14 +43940,6 @@ function extractImageLambdaProperties(args) {
43921
43940
  if (Array.isArray(rawImageConfig["Command"])) imageConfig.command = rawImageConfig["Command"].filter((s) => typeof s === "string");
43922
43941
  if (Array.isArray(rawImageConfig["EntryPoint"])) imageConfig.entryPoint = rawImageConfig["EntryPoint"].filter((s) => typeof s === "string");
43923
43942
  if (typeof rawImageConfig["WorkingDirectory"] === "string") imageConfig.workingDirectory = rawImageConfig["WorkingDirectory"];
43924
- const arches = props["Architectures"];
43925
- let architecture = "x86_64";
43926
- if (Array.isArray(arches) && arches.length > 0) {
43927
- const first = arches[0];
43928
- if (first === "arm64") architecture = "arm64";
43929
- else if (first === "x86_64") architecture = "x86_64";
43930
- else throw new LocalInvokeResolutionError(`Lambda '${logicalId}' has unsupported Architectures value '${String(first)}'. cdkd local invoke supports x86_64 and arm64.`);
43931
- }
43932
43943
  return {
43933
43944
  kind: "image",
43934
43945
  stack,
@@ -43938,7 +43949,7 @@ function extractImageLambdaProperties(args) {
43938
43949
  timeoutSec,
43939
43950
  imageUri,
43940
43951
  imageConfig,
43941
- architecture,
43952
+ architecture: extractArchitecture(props, logicalId),
43942
43953
  layers: [],
43943
43954
  ...ephemeralStorageMb !== void 0 && { ephemeralStorageMb }
43944
43955
  };
@@ -46532,6 +46543,7 @@ function createContainerPool(specs, options) {
46532
46543
  hostPort,
46533
46544
  host: spec.containerHost,
46534
46545
  name,
46546
+ platform: spec.platform,
46535
46547
  ...spec.debugPort !== void 0 && { debugPort: spec.debugPort },
46536
46548
  ...spec.tmpfs !== void 0 && { tmpfs: spec.tmpfs },
46537
46549
  ...spec.extraHosts !== void 0 && { extraHosts: spec.extraHosts }
@@ -47464,6 +47476,7 @@ async function buildContainerSpec(args) {
47464
47476
  if (lambda.kind === "zip") {
47465
47477
  codeDir = lambda.codePath ?? materializeInlineCode$1(lambda.handler, lambda.inlineCode ?? "", resolveRuntimeFileExtension(lambda.runtime), inlineTmpDirs);
47466
47478
  optDir = await materializeLambdaLayers$1(lambda.layers, layerTmpDirs, layerRoleArn);
47479
+ platform = architectureToPlatform(lambda.architecture);
47467
47480
  } else {
47468
47481
  imageRef = (await resolveContainerImageForStartApi(lambda, skipPull)).imageRef;
47469
47482
  platform = architectureToPlatform(lambda.architecture);
@@ -47530,6 +47543,7 @@ async function buildContainerSpec(args) {
47530
47543
  kind: "zip",
47531
47544
  lambda,
47532
47545
  codeDir,
47546
+ platform,
47533
47547
  env: dockerEnv,
47534
47548
  containerHost,
47535
47549
  ...optDir !== void 0 && { optDir },
@@ -47681,6 +47695,7 @@ function resolveLambdaByLogicalId(logicalId, stacks) {
47681
47695
  if (!inlineCode) codePath = resolveAssetCodePath(stack, logicalId, resource);
47682
47696
  const layers = resolveLambdaLayers(stack, logicalId, props);
47683
47697
  const ephemeralStorageMb = extractEphemeralStorageMb(props, logicalId);
47698
+ const architecture = extractStartApiArchitecture(props, logicalId);
47684
47699
  return {
47685
47700
  kind: "zip",
47686
47701
  stack,
@@ -47692,6 +47707,7 @@ function resolveLambdaByLogicalId(logicalId, stacks) {
47692
47707
  timeoutSec,
47693
47708
  codePath,
47694
47709
  layers,
47710
+ architecture,
47695
47711
  ...inlineCode !== void 0 && { inlineCode },
47696
47712
  ...ephemeralStorageMb !== void 0 && { ephemeralStorageMb }
47697
47713
  };
@@ -47741,6 +47757,23 @@ function extractImageUri(value, logicalId, stackName, resources, region) {
47741
47757
  }
47742
47758
  }
47743
47759
  /**
47760
+ * Parse `Properties.Architectures` into the single arch cdkd threads to
47761
+ * `--platform`. Defaults to `x86_64` (the AWS default) when absent; CDK
47762
+ * only ever sets one entry. Shared by BOTH the ZIP and IMAGE start-api
47763
+ * resolvers (issue #768) so the ZIP container run pins `--platform` the
47764
+ * same way the IMAGE path always has.
47765
+ */
47766
+ function extractStartApiArchitecture(props, logicalId) {
47767
+ const arches = props["Architectures"];
47768
+ if (Array.isArray(arches) && arches.length > 0) {
47769
+ const first = arches[0];
47770
+ if (first === "arm64") return "arm64";
47771
+ if (first === "x86_64") return "x86_64";
47772
+ throw new Error(`Lambda '${logicalId}' has unsupported Architectures value '${String(first)}'. cdkd local start-api supports x86_64 and arm64.`);
47773
+ }
47774
+ return "x86_64";
47775
+ }
47776
+ /**
47744
47777
  * Build the IMAGE-variant `ResolvedStartApiLambda` from a Lambda
47745
47778
  * template entry with `Code.ImageUri`. Mirrors
47746
47779
  * `lambda-resolver.ts:extractImageLambdaProperties` but trimmed to the
@@ -47753,14 +47786,7 @@ function resolveImageLambda(args) {
47753
47786
  if (Array.isArray(rawImageConfig["Command"])) imageConfig.command = rawImageConfig["Command"].filter((s) => typeof s === "string");
47754
47787
  if (Array.isArray(rawImageConfig["EntryPoint"])) imageConfig.entryPoint = rawImageConfig["EntryPoint"].filter((s) => typeof s === "string");
47755
47788
  if (typeof rawImageConfig["WorkingDirectory"] === "string") imageConfig.workingDirectory = rawImageConfig["WorkingDirectory"];
47756
- const arches = props["Architectures"];
47757
- let architecture = "x86_64";
47758
- if (Array.isArray(arches) && arches.length > 0) {
47759
- const first = arches[0];
47760
- if (first === "arm64") architecture = "arm64";
47761
- else if (first === "x86_64") architecture = "x86_64";
47762
- else throw new Error(`Lambda '${logicalId}' has unsupported Architectures value '${String(first)}'. cdkd local start-api supports x86_64 and arm64.`);
47763
- }
47789
+ const architecture = extractStartApiArchitecture(props, logicalId);
47764
47790
  const ephemeralStorageMb = extractEphemeralStorageMb(props, logicalId);
47765
47791
  return {
47766
47792
  kind: "image",
@@ -50809,14 +50835,17 @@ function createLocalInvokeAgentCoreCommand() {
50809
50835
  * `--stack-region`) live in cdk-local's `addStartAgentCoreSpecificOptions` and
50810
50836
  * are auto-inherited.
50811
50837
  *
50812
- * UNLIKE `start-cloudfront`, this command DOES bind deployed state: cdk-local's
50813
- * factory accepts an `extraStateProviders` option (the same seam the
50814
- * heavy-wrapper `cdkd local *` commands use), so cdkd threads its S3-backed
50815
- * `--from-state` factory in via `cdkdExtraStateProviders` and layers the
50816
- * cdkd-specific `--from-state` / `--state-bucket` / `--state-prefix` flags on
50817
- * top of cdk-local's inherited `--from-cfn-stack` / `--stack-region` (issue
50818
- * #766). The factory's internal `createLocalStateProvider` call picks cdkd's
50819
- * `fromState` factory transparently when `--from-state` is passed.
50838
+ * Like `start-cloudfront` / `start-alb` / `start-service`, this command binds
50839
+ * deployed state through cdk-local's `extraStateProviders` seam: the factory
50840
+ * accepts an `extraStateProviders` option (the same seam those commands use), so
50841
+ * cdkd threads its S3-backed `--from-state` factory in via
50842
+ * `cdkdExtraStateProviders` and layers the cdkd-specific `--from-state` /
50843
+ * `--state-bucket` / `--state-prefix` flags on top of cdk-local's inherited
50844
+ * `--from-cfn-stack` / `--stack-region` (issue #766; the `start-agentcore`
50845
+ * factory carried the seam from the start, the `start-cloudfront` factory gained
50846
+ * it in cdk-local 0.128.0). The factory's internal `createLocalStateProvider`
50847
+ * call picks cdkd's `fromState` factory transparently when `--from-state` is
50848
+ * passed.
50820
50849
  *
50821
50850
  * The active cdkd embed config is re-handed to the factory so branding stays
50822
50851
  * cdkd: cdk-local's factory calls `setEmbedConfig(opts.embedConfig)`, and
@@ -50871,16 +50900,17 @@ function createLocalStartAlbCommand() {
50871
50900
  * binding a Function URL origin's backing Lambda + a deployed-S3 origin's bucket
50872
50901
  * name to deployed state) live in cdk-local and are auto-inherited.
50873
50902
  *
50874
- * UNLIKE `start-agentcore` / `start-alb` / `start-service`, this command does
50875
- * NOT thread cdkd's S3-backed `--from-state` source: cdk-local's
50876
- * `CreateLocalStartCloudFrontCommandOptions` accepts only `embedConfig`, not the
50877
- * `extraStateProviders` seam (the factory's internal `createLocalStateProvider`
50878
- * calls pass no fourth argument). So `--from-state` / `--state-bucket` /
50879
- * `--state-prefix` and `cdkdExtraStateProviders` threading are intentionally
50880
- * absent here start-cloudfront stays exempt from issue #766 until cdk-local
50881
- * adds `extraStateProviders` to its start-cloudfront factory. Until then the
50882
- * `--from-cfn-stack` flag (CloudFormation-backed deployed state) is the only
50883
- * state source on this command.
50903
+ * As of cdk-local 0.128.0 (go-to-k/cdk-local#426 / #436) the start-cloudfront
50904
+ * factory accepts the `extraStateProviders` seam — the same one
50905
+ * `start-agentcore` / `start-alb` / `start-service` use — so cdkd now threads
50906
+ * its S3-backed `--from-state` factory in via `cdkdExtraStateProviders` and
50907
+ * layers the cdkd-specific `--from-state` / `--state-bucket` / `--state-prefix`
50908
+ * flags on top of cdk-local's inherited `--from-cfn-stack` / `--stack-region`
50909
+ * (issue #766). The factory's internal `createLocalStateProvider` calls pick
50910
+ * cdkd's `fromState` factory transparently when `--from-state` is passed, so a
50911
+ * Function URL origin's backing Lambda + a deployed-S3 origin's bucket name can
50912
+ * be bound to cdkd-managed state (after a prior `cdkd deploy`), not just to a
50913
+ * CloudFormation stack.
50884
50914
  *
50885
50915
  * The active cdkd embed config is re-handed to the factory so branding stays
50886
50916
  * cdkd: cdk-local's factory calls `setEmbedConfig(opts.embedConfig)`, and
@@ -50889,7 +50919,14 @@ function createLocalStartAlbCommand() {
50889
50919
  * cdk-local's `cdkl` defaults.
50890
50920
  */
50891
50921
  function createLocalStartCloudFrontCommand$1() {
50892
- return createLocalStartCloudFrontCommand({ embedConfig: getEmbedConfig() });
50922
+ const cmd = createLocalStartCloudFrontCommand({
50923
+ embedConfig: getEmbedConfig(),
50924
+ extraStateProviders: cdkdExtraStateProviders
50925
+ });
50926
+ cmd.addOption(new Option("--from-state", "Read cdkd's S3 state for the target stack and substitute Ref / Fn::GetAtt / Fn::Sub / Fn::ImportValue / Fn::GetStackOutput intrinsics when binding a Lambda Function URL origin's backing Lambda and a deployed-S3 origin's bucket name. Mutually exclusive with --from-cfn-stack.").default(false));
50927
+ cmd.addOption(new Option("--state-bucket <bucket>", "S3 bucket for --from-state. Falls back to CDKD_STATE_BUCKET env or cdk.json context.cdkd.stateBucket."));
50928
+ cmd.addOption(new Option("--state-prefix <prefix>", "S3 key prefix for --from-state state files.").default("cdkd"));
50929
+ return cmd;
50893
50930
  }
50894
50931
 
50895
50932
  //#endregion
@@ -51192,6 +51229,7 @@ async function resolveZipImagePlan(lambda, options) {
51192
51229
  }],
51193
51230
  extraMounts: layerPlan.mount ? [layerPlan.mount] : [],
51194
51231
  cmd: [lambda.handler],
51232
+ platform: architectureToPlatform(lambda.architecture),
51195
51233
  ...inlineTmpDir !== void 0 && { inlineTmpDir },
51196
51234
  ...layerPlan.tmpDir !== void 0 && { layersTmpDir: layerPlan.tmpDir },
51197
51235
  ...layerPlan.extraTmpDirs.length > 0 && { layerArnTmpDirs: layerPlan.extraTmpDirs },
@@ -52836,7 +52874,7 @@ function reorderArgs(argv) {
52836
52874
  async function main() {
52837
52875
  installPipeCloseHandler();
52838
52876
  const program = new Command();
52839
- program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.209.1");
52877
+ program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.210.1");
52840
52878
  program.addCommand(createBootstrapCommand());
52841
52879
  program.addCommand(createSynthCommand());
52842
52880
  program.addCommand(createListCommand());