@go-to-k/cdkd 0.159.2 → 0.160.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,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { _ as withSkipPrefix, a as runDockerStreaming, c as getLogger, d as getLiveRenderer, f as PATTERN_B_NAME_PROPERTIES, g as generateResourceNameWithFallback, h as generateResourceName, i as runDockerForeground, n as formatDockerLoginError, p as PATTERN_B_RESOURCE_TYPES, r as getDockerCmd, u as runStackBuffered, v as withStackName } from "./docker-cmd-iDMcWcre.js";
3
- import { $ as CdkdError, A as shouldRetainResource, B as resolveSkipPrefix, C as IntrinsicFunctionResolver, D as TemplateParser, E as DagBuilder, F as Synthesizer, G as CFN_TEMPLATE_URL_LIMIT, H as resolveStateBucketWithDefaultAndSource, I as getDefaultStateBucketName, J as uploadCfnTemplate, K as MIGRATE_TMP_PREFIX, L as getLegacyStateBucketName, M as stringifyValue, N as WorkGraph, O as LockManager, P as buildDockerImage, R as resolveApp, S as assertRegionMatch, T as DiffCalculator, U as warnDeprecatedNoPrefixCliFlag, V as resolveStateBucketWithDefault, W as CFN_TEMPLATE_BODY_LIMIT, Y as AssemblyReader, Z as resolveBucketRegion, _ as matchesCdkPath, a as withRetry, b as ProviderRegistry, bt as withErrorHandling, c as bold, ct as PartialFailureError, d as green, dt as ResourceUpdateNotSupportedError, f as red, ft as RouteDiscoveryError, g as CDK_PATH_TAG, h as collectInlinePolicyNamesManagedBySiblings, i as withResourceDeadline, it as LocalStartServiceError, j as AssetPublisher, k as S3StateBackend, l as cyan, lt as ProvisioningError, m as IAMRoleProvider, mt as StackTerminationProtectionError, n as DEFAULT_RESOURCE_WARN_AFTER_MS, nt as LocalInvokeBuildError, o as IMPLICIT_DELETE_DEPENDENCIES, ot as MissingCdkCliError, p as yellow, pt as StackHasActiveImportsError, q as findLargeInlineResources, r as DeployEngine, rt as LocalMigrateError, s as formatResourceLine, st as NestedStackChildDirectDestroyError, t as DEFAULT_RESOURCE_TIMEOUT_MS, u as gray, ut as ResourceTimeoutError, v as normalizeAwsTagsToCfn, w as applyRoleArnIfSet, x as CloudControlProvider, y as resolveExplicitPhysicalId, yt as normalizeAwsError, z as resolveCaptureObservedState } from "./deploy-engine-BzrECC3i.js";
3
+ import { $ as CdkdError, A as shouldRetainResource, B as resolveSkipPrefix, C as IntrinsicFunctionResolver, D as TemplateParser, E as DagBuilder, F as Synthesizer, G as CFN_TEMPLATE_URL_LIMIT, H as resolveStateBucketWithDefaultAndSource, I as getDefaultStateBucketName, J as uploadCfnTemplate, K as MIGRATE_TMP_PREFIX, L as getLegacyStateBucketName, M as stringifyValue, N as WorkGraph, O as LockManager, P as buildDockerImage, R as resolveApp, S as assertRegionMatch, T as DiffCalculator, U as warnDeprecatedNoPrefixCliFlag, V as resolveStateBucketWithDefault, W as CFN_TEMPLATE_BODY_LIMIT, Y as AssemblyReader, Z as resolveBucketRegion, _ as matchesCdkPath, a as withRetry, b as ProviderRegistry, bt as withErrorHandling, c as bold, ct as PartialFailureError, d as green, dt as ResourceUpdateNotSupportedError, f as red, ft as RouteDiscoveryError, g as CDK_PATH_TAG, h as collectInlinePolicyNamesManagedBySiblings, i as withResourceDeadline, it as LocalStartServiceError, j as AssetPublisher, k as S3StateBackend, l as cyan, lt as ProvisioningError, m as IAMRoleProvider, mt as StackTerminationProtectionError, n as DEFAULT_RESOURCE_WARN_AFTER_MS, nt as LocalInvokeBuildError, o as IMPLICIT_DELETE_DEPENDENCIES, ot as MissingCdkCliError, p as yellow, pt as StackHasActiveImportsError, q as findLargeInlineResources, r as DeployEngine, rt as LocalMigrateError, s as formatResourceLine, st as NestedStackChildDirectDestroyError, t as DEFAULT_RESOURCE_TIMEOUT_MS, u as gray, ut as ResourceTimeoutError, v as normalizeAwsTagsToCfn, w as applyRoleArnIfSet, x as CloudControlProvider, y as resolveExplicitPhysicalId, yt as normalizeAwsError, z as resolveCaptureObservedState } from "./deploy-engine-BXWv-yRb.js";
4
4
  import { a as setAwsClients, i as resetAwsClients, r as getAwsClients, t as AwsClients } from "./aws-clients-B15NAPbL.js";
5
5
  import { AsyncLocalStorage } from "node:async_hooks";
6
6
  import { createHash, createHmac, createPublicKey, createVerify, randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
@@ -32190,7 +32190,10 @@ async function runDestroyForStack(stackName, state, ctx) {
32190
32190
  const baseLabel = `Deleting ${logicalId} (${resource.resourceType})`;
32191
32191
  renderer.addTask(logicalId, baseLabel);
32192
32192
  try {
32193
- const provider = destroyProviderRegistry.getProvider(resource.resourceType);
32193
+ const provider = destroyProviderRegistry.getProviderFor({
32194
+ resourceType: resource.resourceType,
32195
+ provisionedBy: resource.provisionedBy
32196
+ }).provider;
32194
32197
  const providerMinTimeoutMs = provider.getMinResourceTimeoutMs?.() ?? 0;
32195
32198
  const warnAfterMs = ctx.resourceWarnAfterByType?.[resource.resourceType] ?? ctx.resourceWarnAfterMs ?? 3e5;
32196
32199
  const globalTimeoutMs = ctx.resourceTimeoutMs ?? 18e5;
@@ -34306,7 +34309,7 @@ async function loadStateOrEmpty(stackName, region, stateBackend) {
34306
34309
  region,
34307
34310
  resources: {},
34308
34311
  outputs: {},
34309
- version: 6,
34312
+ version: 7,
34310
34313
  lastModified: Date.now()
34311
34314
  };
34312
34315
  }
@@ -35078,7 +35081,10 @@ async function runDriftForStack(stackName, region, stateBackend, providerRegistr
35078
35081
  }
35079
35082
  let provider;
35080
35083
  try {
35081
- provider = providerRegistry.getProvider(resource.resourceType);
35084
+ provider = providerRegistry.getProviderFor({
35085
+ resourceType: resource.resourceType,
35086
+ provisionedBy: resource.provisionedBy
35087
+ }).provider;
35082
35088
  } catch {
35083
35089
  outcomes.push({
35084
35090
  kind: "unsupported",
@@ -35355,7 +35361,10 @@ async function runRevert(reports, providerRegistry, stateConfig, awsClients, opt
35355
35361
  logger.error(` ✗ ${report.stackName}/${outcome.logicalId} (${outcome.resourceType}): resource missing from state; skipped.`);
35356
35362
  return;
35357
35363
  }
35358
- const provider = providerRegistry.getProvider(outcome.resourceType);
35364
+ const provider = providerRegistry.getProviderFor({
35365
+ resourceType: outcome.resourceType,
35366
+ provisionedBy: stateResource.provisionedBy
35367
+ }).provider;
35359
35368
  const desiredProperties = stateResource.observedProperties ?? stateResource.properties ?? {};
35360
35369
  const newProperties = buildRevertNewProperties(outcome.changes, desiredProperties, outcome.awsProperties);
35361
35370
  try {
@@ -35871,7 +35880,10 @@ var AttributeFetcher = class {
35871
35880
  };
35872
35881
  let provider;
35873
35882
  try {
35874
- provider = this.providerRegistry.getProvider(orphan.resourceType);
35883
+ provider = this.providerRegistry.getProviderFor({
35884
+ resourceType: orphan.resourceType,
35885
+ provisionedBy: orphan.provisionedBy
35886
+ }).provider;
35875
35887
  } catch (err) {
35876
35888
  return {
35877
35889
  ok: false,
@@ -39741,6 +39753,8 @@ function renderStateBlock(state, lockInfo) {
39741
39753
  lines.push(logicalId);
39742
39754
  lines.push(` Type: ${resource.resourceType}`);
39743
39755
  lines.push(` PhysicalID: ${resource.physicalId}`);
39756
+ const provisionedBy = resource.provisionedBy ?? "(sdk, legacy default)";
39757
+ lines.push(` ProvisionedBy: ${provisionedBy}`);
39744
39758
  const deps = resource.dependencies ?? [];
39745
39759
  lines.push(` Dependencies: ${deps.length > 0 ? deps.join(", ") : "(none)"}`);
39746
39760
  const attrEntries = Object.entries(resource.attributes ?? {});
@@ -40371,7 +40385,10 @@ async function refreshObservedForStack(stackName, region, stateBackend, lockMana
40371
40385
  for (const [, resource] of entries) {
40372
40386
  let provider;
40373
40387
  try {
40374
- provider = providerRegistry.getProvider(resource.resourceType);
40388
+ provider = providerRegistry.getProviderFor({
40389
+ resourceType: resource.resourceType,
40390
+ provisionedBy: resource.provisionedBy
40391
+ }).provider;
40375
40392
  } catch {
40376
40393
  wouldUnsupported++;
40377
40394
  continue;
@@ -40400,7 +40417,10 @@ async function refreshObservedForStack(stackName, region, stateBackend, lockMana
40400
40417
  }
40401
40418
  let provider;
40402
40419
  try {
40403
- provider = providerRegistry.getProvider(resource.resourceType);
40420
+ provider = providerRegistry.getProviderFor({
40421
+ resourceType: resource.resourceType,
40422
+ provisionedBy: resource.provisionedBy
40423
+ }).provider;
40404
40424
  } catch {
40405
40425
  unsupported++;
40406
40426
  return;
@@ -40939,11 +40959,12 @@ function buildStackState(stackName, region, rows, templateParser, template, exis
40939
40959
  resourceType: row.resourceType,
40940
40960
  properties: tmplResource.Properties ?? {},
40941
40961
  attributes: {},
40942
- dependencies: [...deps]
40962
+ dependencies: [...deps],
40963
+ provisionedBy: "sdk"
40943
40964
  };
40944
40965
  }
40945
40966
  return {
40946
- version: 6,
40967
+ version: 7,
40947
40968
  stackName,
40948
40969
  region,
40949
40970
  resources,
@@ -41136,7 +41157,10 @@ async function captureObservedForImportedResources(stackState, providerRegistry,
41136
41157
  if (entries.length === 0) return;
41137
41158
  await Promise.all(entries.map(async ([logicalId, resource]) => {
41138
41159
  try {
41139
- const provider = providerRegistry.getProvider(resource.resourceType);
41160
+ const provider = providerRegistry.getProviderFor({
41161
+ resourceType: resource.resourceType,
41162
+ provisionedBy: resource.provisionedBy
41163
+ }).provider;
41140
41164
  if (!provider.readCurrentState) return;
41141
41165
  const observed = await provider.readCurrentState(resource.physicalId, logicalId, resource.resourceType, resource.properties ?? {}, buildReadCurrentStateContext(stackState, logicalId));
41142
41166
  if (observed !== void 0) resource.observedProperties = observed;
@@ -54606,7 +54630,7 @@ function resolveLambdaByLogicalId(logicalId, stacks) {
54606
54630
  const memoryMb = typeof props["MemorySize"] === "number" ? props["MemorySize"] : 128;
54607
54631
  const timeoutSec = typeof props["Timeout"] === "number" ? props["Timeout"] : 3;
54608
54632
  const code = props["Code"] ?? {};
54609
- const imageUri = extractImageUri(code["ImageUri"]);
54633
+ const imageUri = extractImageUri(code["ImageUri"], logicalId, stack.stackName, stack.template.Resources ?? {});
54610
54634
  if (imageUri !== void 0) return resolveImageLambda({
54611
54635
  stack,
54612
54636
  logicalId,
@@ -54645,25 +54669,47 @@ function resolveLambdaByLogicalId(logicalId, stacks) {
54645
54669
  /**
54646
54670
  * Extract `Code.ImageUri` across the shapes CDK actually synthesizes.
54647
54671
  * 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.
54672
+ * scoped to the shapes `cdkd local start-api` consumes — flat string,
54673
+ * `Fn::Sub` (the canonical asset shape for
54674
+ * `lambda.DockerImageCode.fromImageAsset`), and `Fn::Join` (the
54675
+ * canonical shape for `lambda.DockerImageCode.fromImageAsset` in
54676
+ * CDK 2.x, which emits a `Fn::Join` over the literal bootstrap ECR
54677
+ * URI with `${AWS::URLSuffix}` issue #627).
54678
+ *
54679
+ * The `Fn::Join` arm routes through the shared
54680
+ * `tryResolveImageFnJoin` helper (`src/local/intrinsic-image.ts`) used
54681
+ * by `cdkd local invoke`. Like the sibling `lambda-resolver.ts`, we
54682
+ * pass `undefined` for the `ImageResolutionContext` — start-api
54683
+ * doesn't load cdkd state up front, so same-stack ECR refs surface
54684
+ * as `needs-state` and pseudo-parameter-only shapes (`Ref:
54685
+ * AWS::URLSuffix`) surface as `not-applicable`. Both cases throw a
54686
+ * clear error that names the actual root cause instead of falling
54687
+ * through to the ZIP branch's misleading "no Runtime" hard error.
54688
+ *
54689
+ * Pseudo-parameter substitution (`${AWS::URLSuffix}` → `amazonaws.com`)
54690
+ * is deliberately not implemented here — `lambda-resolver.ts` (the
54691
+ * canonical sibling) also defers it, and shipping one-sided support
54692
+ * would surprise users. Tracked separately as the issue's optional
54693
+ * follow-up.
54656
54694
  *
54657
54695
  * Returns `undefined` when the field is absent or non-recognized,
54658
54696
  * which routes the caller to the ZIP branch (with its existing
54659
54697
  * "no Runtime / no Handler" validations).
54660
54698
  */
54661
- function extractImageUri(value) {
54699
+ function extractImageUri(value, logicalId, stackName, resources) {
54662
54700
  if (typeof value === "string" && value.length > 0) return value;
54663
54701
  if (value && typeof value === "object" && !Array.isArray(value)) {
54664
- const sub = value["Fn::Sub"];
54702
+ const obj = value;
54703
+ const sub = obj["Fn::Sub"];
54665
54704
  if (typeof sub === "string" && sub.length > 0) return sub;
54666
54705
  if (Array.isArray(sub) && typeof sub[0] === "string") return sub[0];
54706
+ if ("Fn::Join" in obj) {
54707
+ const joinResolved = tryResolveImageFnJoin(value, resources, void 0);
54708
+ if (joinResolved.kind === "resolved") return joinResolved.uri;
54709
+ 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.`);
54710
+ 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).`);
54711
+ 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.`);
54712
+ }
54667
54713
  }
54668
54714
  }
54669
54715
  /**
@@ -59491,7 +59537,7 @@ function reorderArgs(argv) {
59491
59537
  */
59492
59538
  async function main() {
59493
59539
  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");
59540
+ program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.160.0");
59495
59541
  program.addCommand(createBootstrapCommand());
59496
59542
  program.addCommand(createSynthCommand());
59497
59543
  program.addCommand(createListCommand());