@go-to-k/cdkd 0.159.2 → 0.159.3

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
@@ -54606,7 +54606,7 @@ function resolveLambdaByLogicalId(logicalId, stacks) {
54606
54606
  const memoryMb = typeof props["MemorySize"] === "number" ? props["MemorySize"] : 128;
54607
54607
  const timeoutSec = typeof props["Timeout"] === "number" ? props["Timeout"] : 3;
54608
54608
  const code = props["Code"] ?? {};
54609
- const imageUri = extractImageUri(code["ImageUri"]);
54609
+ const imageUri = extractImageUri(code["ImageUri"], logicalId, stack.stackName, stack.template.Resources ?? {});
54610
54610
  if (imageUri !== void 0) return resolveImageLambda({
54611
54611
  stack,
54612
54612
  logicalId,
@@ -54645,25 +54645,47 @@ function resolveLambdaByLogicalId(logicalId, stacks) {
54645
54645
  /**
54646
54646
  * Extract `Code.ImageUri` across the shapes CDK actually synthesizes.
54647
54647
  * Mirrors the simpler subset of `lambda-resolver.ts:extractImageUri`
54648
- * scoped to the shapes `cdkd local start-api` consumes — flat string
54649
- * and `Fn::Sub` (the canonical asset shape for
54650
- * `lambda.DockerImageCode.fromImageAsset`). `Fn::Join` shapes for
54651
- * `lambda.DockerImageCode.fromEcr` are deferred to a follow-up: the
54652
- * start-api boot flow doesn't yet load cdkd state up front, and the
54653
- * `Fn::Join` resolver needs it to recover same-stack ECR repository
54654
- * URIs. When the user hits the unsupported shape, the downstream
54655
- * resolveLocalBuildPlan / pullEcrImage path surfaces a clear error.
54648
+ * scoped to the shapes `cdkd local start-api` consumes — flat string,
54649
+ * `Fn::Sub` (the canonical asset shape for
54650
+ * `lambda.DockerImageCode.fromImageAsset`), and `Fn::Join` (the
54651
+ * canonical shape for `lambda.DockerImageCode.fromImageAsset` in
54652
+ * CDK 2.x, which emits a `Fn::Join` over the literal bootstrap ECR
54653
+ * URI with `${AWS::URLSuffix}` issue #627).
54654
+ *
54655
+ * The `Fn::Join` arm routes through the shared
54656
+ * `tryResolveImageFnJoin` helper (`src/local/intrinsic-image.ts`) used
54657
+ * by `cdkd local invoke`. Like the sibling `lambda-resolver.ts`, we
54658
+ * pass `undefined` for the `ImageResolutionContext` — start-api
54659
+ * doesn't load cdkd state up front, so same-stack ECR refs surface
54660
+ * as `needs-state` and pseudo-parameter-only shapes (`Ref:
54661
+ * AWS::URLSuffix`) surface as `not-applicable`. Both cases throw a
54662
+ * clear error that names the actual root cause instead of falling
54663
+ * through to the ZIP branch's misleading "no Runtime" hard error.
54664
+ *
54665
+ * Pseudo-parameter substitution (`${AWS::URLSuffix}` → `amazonaws.com`)
54666
+ * is deliberately not implemented here — `lambda-resolver.ts` (the
54667
+ * canonical sibling) also defers it, and shipping one-sided support
54668
+ * would surprise users. Tracked separately as the issue's optional
54669
+ * follow-up.
54656
54670
  *
54657
54671
  * Returns `undefined` when the field is absent or non-recognized,
54658
54672
  * which routes the caller to the ZIP branch (with its existing
54659
54673
  * "no Runtime / no Handler" validations).
54660
54674
  */
54661
- function extractImageUri(value) {
54675
+ function extractImageUri(value, logicalId, stackName, resources) {
54662
54676
  if (typeof value === "string" && value.length > 0) return value;
54663
54677
  if (value && typeof value === "object" && !Array.isArray(value)) {
54664
- const sub = value["Fn::Sub"];
54678
+ const obj = value;
54679
+ const sub = obj["Fn::Sub"];
54665
54680
  if (typeof sub === "string" && sub.length > 0) return sub;
54666
54681
  if (Array.isArray(sub) && typeof sub[0] === "string") return sub[0];
54682
+ if ("Fn::Join" in obj) {
54683
+ const joinResolved = tryResolveImageFnJoin(value, resources, void 0);
54684
+ if (joinResolved.kind === "resolved") return joinResolved.uri;
54685
+ if (joinResolved.kind === "needs-state") throw new Error(`Lambda '${logicalId}' in ${stackName} references same-stack ECR repository '${joinResolved.repoLogicalId}' via Fn::Join. cdkd local start-api cannot resolve the repository URI without state — deploy the stack first (so cdkd records the repository physical id), rebuild via lambda.DockerImageCode.fromImageAsset, or pin a public image.`);
54686
+ if (joinResolved.kind === "unsupported-join") throw new Error(`Lambda '${logicalId}' in ${stackName} has an unsupported Fn::Join Code.ImageUri shape: ${joinResolved.reason}. cdkd local start-api recognizes the canonical CDK 2.x lambda.DockerImageCode.fromEcr Fn::Join shape (delimiter "" with nested Fn::Select/Fn::Split over an ECR Repository Arn GetAtt + Ref to the repo).`);
54687
+ throw new Error(`Lambda '${logicalId}' in ${stackName} has an Fn::Join Code.ImageUri that cdkd local start-api cannot resolve. The shape likely references AWS pseudo parameters (e.g. \${AWS::URLSuffix}) — the canonical CDK 2.x lambda.DockerImageCode.fromImageAsset synthesized shape. Workarounds: pin a fully-literal public image URI, or wait for the follow-up that substitutes \${AWS::URLSuffix} against the current region.`);
54688
+ }
54667
54689
  }
54668
54690
  }
54669
54691
  /**
@@ -59491,7 +59513,7 @@ function reorderArgs(argv) {
59491
59513
  */
59492
59514
  async function main() {
59493
59515
  const program = new Command();
59494
- program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.159.2");
59516
+ program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.159.3");
59495
59517
  program.addCommand(createBootstrapCommand());
59496
59518
  program.addCommand(createSynthCommand());
59497
59519
  program.addCommand(createListCommand());