@go-to-k/cdkd 0.275.3 → 0.275.5

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,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import { $ as WorkGraph, A as slowCcOperationTimeoutMs, At as warnDeprecatedNoPrefixCliFlag, B as applyRoleArnIfSet, Bt as resolveBucketRegion, C as yellow, Ct as resolveAutoAssetStorage, D as ProviderRegistry, Dt as resolveStateBucketWithDefaultAndSource, E as clearOnUpdateRemoval, Et as resolveStateBucketWithDefault, F as refStateLookupFromResource, Ft as uploadCfnTemplate, G as DagBuilder, H as describeTypeWithThrottleRetry, Ht as getAwsClients, I as WAFv2WebACLProvider, It as expectedOwnerParam, J as S3StateBackend, K as TemplateParser, Kt as CdkdError, L as normalizeAwsTagsToCfn, Lt as AssemblyReader, M as isTerminationProtectionPropagationError, Mt as CFN_TEMPLATE_URL_LIMIT, N as IntrinsicFunctionResolver, Nt as MIGRATE_TMP_PREFIX, O as findActionableSilentDrops, Ot as resolveUseCdkBootstrapAssets, P as cfnRefValueFromPhysicalId, Pt as findLargeInlineResources, Q as stringifyValue, Qt as LocalStartServiceError, R as resolveExplicitPhysicalId, Rt as processStackMessages, S as red, St as resolveApp, T as collectInlinePolicyNamesManagedBySiblings, Tt as resolveSkipPrefix, U as withRetry, Ut as resetAwsClients, V as DiffCalculator, Vt as AwsClients, W as isRetryableTransientError, Wt as setAwsClients, X as shouldRetainResource, Xt as LocalInvokeBuildError$1, Y as rebuildClientForBucketRegion, Yt as DeployCancelledError, Z as AssetPublisher, Zt as LocalMigrateError, _ as formatResourceLine, _t as getDockerImageBySourceHash, a as DeploymentEventsStore, an as ResourceUpdateNotSupportedError, at as BOOTSTRAP_MARKER_PREFIX, b as gray, bt as getDefaultStateBucketName, c as replayFailedOperations, ct as parseBootstrapMarker, d as IMPLICIT_DELETE_DEPENDENCIES, dt as buildDockerImage, en as MissingCdkCliError, et as buildAssetRedirectMap, f as computeImplicitDeleteEdges, fn as normalizeAwsError, ft as formatDockerLoginError, g as renderStatefulReason, gt as AssetManifestLoader, h as isStatefulRecreateTargetSync, ht as runDockerStreaming, i as DeploymentEventsReader, in as ResourceTimeoutError, it as AssetModeResolver, j as disableInstanceApiTermination, jt as CFN_TEMPLATE_BODY_LIMIT, k as CloudControlProvider, kt as stateBucketExistenceConfirmed, l as replayRollback, lt as validateAssetBucketName, m as MULTI_REGION_RECREATE_BLOCKED_TYPES, mt as runDockerForeground, n as DEFAULT_RESOURCE_WARN_AFTER_MS, nn as PartialFailureError, nt as loadPublishableAssetManifest, o as planFailedOps, on as StackHasActiveImportsError, ot as ensureAssetStorage, p as extractDeploymentEventError, pn as withErrorHandling, pt as getDockerCmd, q as LockManager, r as DeployEngine, rn as ProvisioningError, rt as rewriteTemplateAssetReferences, s as planRollback, sn as StackTerminationProtectionError, st as getBootstrapMarkerKey, t as DEFAULT_RESOURCE_TIMEOUT_MS, tn as NestedStackChildDirectDestroyError, tt as createAssetRedirectResolver, u as withResourceDeadline, ut as validateContainerRepoName, v as bold, vt as Synthesizer, w as IAMRoleProvider, wt as resolveCaptureObservedState, x as green, xt as getLegacyStateBucketName, y as cyan, yt as synthesisStatusMessage, z as assertRegionMatch } from "./deploy-engine-_U0eVWNU.js";
2
+ import { $ as WorkGraph, A as slowCcOperationTimeoutMs, At as warnDeprecatedNoPrefixCliFlag, B as applyRoleArnIfSet, Bt as resolveBucketRegion, C as yellow, Ct as resolveAutoAssetStorage, D as ProviderRegistry, Dt as resolveStateBucketWithDefaultAndSource, E as clearOnUpdateRemoval, Et as resolveStateBucketWithDefault, F as refStateLookupFromResource, Ft as uploadCfnTemplate, G as DagBuilder, H as describeTypeWithThrottleRetry, Ht as getAwsClients, I as WAFv2WebACLProvider, It as expectedOwnerParam, J as S3StateBackend, K as TemplateParser, Kt as CdkdError, L as normalizeAwsTagsToCfn, Lt as AssemblyReader, M as isTerminationProtectionPropagationError, Mt as CFN_TEMPLATE_URL_LIMIT, N as IntrinsicFunctionResolver, Nt as MIGRATE_TMP_PREFIX, O as findActionableSilentDrops, Ot as resolveUseCdkBootstrapAssets, P as cfnRefValueFromPhysicalId, Pt as findLargeInlineResources, Q as stringifyValue, Qt as LocalStartServiceError, R as resolveExplicitPhysicalId, Rt as processStackMessages, S as red, St as resolveApp, T as collectInlinePolicyNamesManagedBySiblings, Tt as resolveSkipPrefix, U as withRetry, Ut as resetAwsClients, V as DiffCalculator, Vt as AwsClients, W as isRetryableTransientError, Wt as setAwsClients, X as shouldRetainResource, Xt as LocalInvokeBuildError$1, Y as rebuildClientForBucketRegion, Yt as DeployCancelledError, Z as AssetPublisher, Zt as LocalMigrateError, _ as formatResourceLine, _t as getDockerImageBySourceHash, a as DeploymentEventsStore, an as ResourceUpdateNotSupportedError, at as BOOTSTRAP_MARKER_PREFIX, b as gray, bt as getDefaultStateBucketName, c as replayFailedOperations, ct as parseBootstrapMarker, d as IMPLICIT_DELETE_DEPENDENCIES, dt as buildDockerImage, en as MissingCdkCliError, et as buildAssetRedirectMap, f as computeImplicitDeleteEdges, fn as normalizeAwsError, ft as formatDockerLoginError, g as renderStatefulReason, gt as AssetManifestLoader, h as isStatefulRecreateTargetSync, ht as runDockerStreaming, i as DeploymentEventsReader, in as ResourceTimeoutError, it as AssetModeResolver, j as disableInstanceApiTermination, jt as CFN_TEMPLATE_BODY_LIMIT, k as CloudControlProvider, kt as stateBucketExistenceConfirmed, l as replayRollback, lt as validateAssetBucketName, m as MULTI_REGION_RECREATE_BLOCKED_TYPES, mt as runDockerForeground, n as DEFAULT_RESOURCE_WARN_AFTER_MS, nn as PartialFailureError, nt as loadPublishableAssetManifest, o as planFailedOps, on as StackHasActiveImportsError, ot as ensureAssetStorage, p as extractDeploymentEventError, pn as withErrorHandling, pt as getDockerCmd, q as LockManager, r as DeployEngine, rn as ProvisioningError, rt as rewriteTemplateAssetReferences, s as planRollback, sn as StackTerminationProtectionError, st as getBootstrapMarkerKey, t as DEFAULT_RESOURCE_TIMEOUT_MS, tn as NestedStackChildDirectDestroyError, tt as createAssetRedirectResolver, u as withResourceDeadline, ut as validateContainerRepoName, v as bold, vt as Synthesizer, w as IAMRoleProvider, wt as resolveCaptureObservedState, x as green, xt as getLegacyStateBucketName, y as cyan, yt as synthesisStatusMessage, z as assertRegionMatch } from "./deploy-engine-rn1TQits.js";
3
3
  import { a as getLiveRenderer, c as PATTERN_B_RESOURCE_TYPES, d as generateResourceNameWithFallback, f as withSkipPrefix, i as runStackBuffered, n as getLogger, o as PATTERN_B_NAME_OPTIONS, p as withStackName, s as PATTERN_B_NAME_PROPERTIES, u as generateResourceName } from "./logger-BYMEE-BS.js";
4
- import { t as ASGProvider } from "./asg-provider-UUnRzwMx.js";
4
+ import { t as ASGProvider } from "./asg-provider-D6Y0zhd3.js";
5
5
  import { AsyncLocalStorage } from "node:async_hooks";
6
6
  import { createHash, randomBytes, randomUUID } from "node:crypto";
7
7
  import { CopyObjectCommand, CreateBucketCommand, DeleteBucketAnalyticsConfigurationCommand, DeleteBucketCommand, DeleteBucketCorsCommand, DeleteBucketIntelligentTieringConfigurationCommand, DeleteBucketInventoryConfigurationCommand, DeleteBucketLifecycleCommand, DeleteBucketMetricsConfigurationCommand, DeleteBucketPolicyCommand, DeleteBucketReplicationCommand, DeleteBucketTaggingCommand, DeleteBucketWebsiteCommand, DeleteObjectsCommand, GetBucketAccelerateConfigurationCommand, GetBucketCorsCommand, GetBucketEncryptionCommand, GetBucketLifecycleConfigurationCommand, GetBucketLocationCommand, GetBucketLoggingCommand, GetBucketNotificationConfigurationCommand, GetBucketPolicyCommand, GetBucketReplicationCommand, GetBucketTaggingCommand, GetBucketVersioningCommand, GetBucketWebsiteCommand, GetObjectCommand, GetObjectLockConfigurationCommand, GetPublicAccessBlockCommand, HeadBucketCommand, ListBucketAnalyticsConfigurationsCommand, ListBucketIntelligentTieringConfigurationsCommand, ListBucketInventoryConfigurationsCommand, ListBucketMetricsConfigurationsCommand, ListObjectVersionsCommand, ListObjectsV2Command, NoSuchBucket, PutBucketAccelerateConfigurationCommand, PutBucketAnalyticsConfigurationCommand, PutBucketCorsCommand, PutBucketEncryptionCommand, PutBucketIntelligentTieringConfigurationCommand, PutBucketInventoryConfigurationCommand, PutBucketLifecycleConfigurationCommand, PutBucketLoggingCommand, PutBucketMetricsConfigurationCommand, PutBucketNotificationConfigurationCommand, PutBucketOwnershipControlsCommand, PutBucketPolicyCommand, PutBucketReplicationCommand, PutBucketTaggingCommand, PutBucketVersioningCommand, PutBucketWebsiteCommand, PutObjectCommand, PutObjectLockConfigurationCommand, PutPublicAccessBlockCommand, S3Client, S3ServiceException } from "@aws-sdk/client-s3";
@@ -1507,6 +1507,50 @@ function createListCommand() {
1507
1507
  return cmd;
1508
1508
  }
1509
1509
 
1510
+ //#endregion
1511
+ //#region src/utils/interrupt-signals.ts
1512
+ /**
1513
+ * SIGTERM -> SIGINT forwarding for the deploy / destroy / rollback commands
1514
+ * (issue #1342).
1515
+ *
1516
+ * CI runners rarely deliver a clean Ctrl-C: GitHub Actions escalates
1517
+ * SIGINT -> SIGTERM (~7.5s later) -> SIGKILL (~2.5s after that) on job
1518
+ * cancellation, and GitLab CI / `docker stop` / Kubernetes send SIGTERM
1519
+ * directly. cdkd's graceful-interrupt handling (the top-level command
1520
+ * handlers, the deploy engine's partial-state save, and the per-provider
1521
+ * poll-abort listeners in CustomResource / ACM / CloudFront / Route53) is
1522
+ * registered on SIGINT only, so an unhandled SIGTERM killed the process
1523
+ * mid-run, skipped every `finally`, and stranded the stack lock for its
1524
+ * full TTL.
1525
+ *
1526
+ * Re-emitting SIGTERM as SIGINT routes it through the exact same graceful
1527
+ * path with ONE registration per command, covering every current and future
1528
+ * SIGINT listener. The "second signal escalates to force-quit" semantics
1529
+ * compose correctly: under GitHub Actions the initial SIGINT starts the
1530
+ * graceful drain, and the follow-up SIGTERM (delivered when the runner is
1531
+ * ~2.5s from SIGKILL) becomes the force-quit that fires the best-effort
1532
+ * lock release before the process dies. In SIGTERM-only environments the
1533
+ * first SIGTERM starts the full graceful drain.
1534
+ */
1535
+ /**
1536
+ * Forward SIGTERM deliveries to the process's SIGINT listeners.
1537
+ *
1538
+ * Returns an unregister function. Callers register at command start and
1539
+ * unregister in their outermost `finally` so the listener never leaks across
1540
+ * commands (or into `cdkd local start-api`, which owns a real SIGTERM
1541
+ * handler of its own).
1542
+ */
1543
+ function forwardSigtermToSigint() {
1544
+ const handler = () => {
1545
+ if (process.listenerCount("SIGINT") === 0) process.exit(143);
1546
+ process.emit("SIGINT", "SIGINT");
1547
+ };
1548
+ process.on("SIGTERM", handler);
1549
+ return () => {
1550
+ process.removeListener("SIGTERM", handler);
1551
+ };
1552
+ }
1553
+
1510
1554
  //#endregion
1511
1555
  //#region src/deployment/recreate-targets.ts
1512
1556
  /**
@@ -42579,16 +42623,50 @@ async function runDestroyForStack(stackName, state, ctx) {
42579
42623
  destroyProviderRegistry.setCustomResourceResponseBucket(ctx.stateBucket);
42580
42624
  if (ctx.allowUnsupportedTypes?.length) destroyProviderRegistry.allowUnsupportedTypes(ctx.allowUnsupportedTypes);
42581
42625
  }
42626
+ const renderer = getLiveRenderer();
42627
+ let draining = false;
42628
+ let lockHeld = false;
42629
+ const sigintHandler = () => {
42630
+ if (draining) {
42631
+ if (lockHeld) {
42632
+ ctx.lockManager.releaseLock(stackName, regionForState).catch(() => {});
42633
+ process.stderr.write(`\nForce-quit: stack lock may not be released. If the next run reports a lock, run: cdkd force-unlock ${stackName}\n`);
42634
+ }
42635
+ process.exit(130);
42636
+ }
42637
+ draining = true;
42638
+ renderer.printAbove(() => {
42639
+ process.stderr.write("\nInterrupted — finishing in-flight deletes, then flushing state and releasing the lock (press Ctrl-C again to force-quit)...\n");
42640
+ });
42641
+ };
42642
+ process.setMaxListeners(Math.max(process.getMaxListeners(), 100));
42643
+ process.on("SIGINT", sigintHandler);
42582
42644
  logger.info(`\nAcquiring lock for stack ${stackName}...`);
42583
- await ctx.lockManager.acquireLock(stackName, regionForState, void 0, "destroy");
42645
+ try {
42646
+ await ctx.lockManager.acquireLock(stackName, regionForState, void 0, "destroy");
42647
+ } catch (error) {
42648
+ process.removeListener("SIGINT", sigintHandler);
42649
+ throw error;
42650
+ }
42651
+ lockHeld = true;
42584
42652
  if (needsStrongRefCheck) {
42585
- const consumers = await scanActiveConsumers(stackName, regionForState, ctx);
42586
- if (consumers.length > 0) {
42653
+ const releaseThenUnregister = async () => {
42587
42654
  try {
42588
42655
  await ctx.lockManager.releaseLock(stackName, regionForState);
42589
42656
  } catch (releaseErr) {
42590
- logger.warn(`Failed to release lock after strong-ref refusal: ${releaseErr instanceof Error ? releaseErr.message : String(releaseErr)}`);
42657
+ logger.warn(`Failed to release lock after strong-ref refusal/failure: ${releaseErr instanceof Error ? releaseErr.message : String(releaseErr)}`);
42591
42658
  }
42659
+ process.removeListener("SIGINT", sigintHandler);
42660
+ };
42661
+ let consumers;
42662
+ try {
42663
+ consumers = await scanActiveConsumers(stackName, regionForState, ctx);
42664
+ } catch (error) {
42665
+ await releaseThenUnregister();
42666
+ throw error;
42667
+ }
42668
+ if (consumers.length > 0) {
42669
+ await releaseThenUnregister();
42592
42670
  throw new StackHasActiveImportsError(stackName, regionForState, consumers);
42593
42671
  }
42594
42672
  }
@@ -42613,22 +42691,7 @@ async function runDestroyForStack(stackName, state, ctx) {
42613
42691
  }
42614
42692
  });
42615
42693
  };
42616
- const renderer = getLiveRenderer();
42617
42694
  renderer.start();
42618
- let draining = false;
42619
- const sigintHandler = () => {
42620
- if (draining) {
42621
- ctx.lockManager.releaseLock(stackName, regionForState).catch(() => {});
42622
- process.stderr.write(`\nForce-quit: stack lock may not be released. If the next run reports a lock, run: cdkd force-unlock ${stackName}\n`);
42623
- process.exit(130);
42624
- }
42625
- draining = true;
42626
- renderer.printAbove(() => {
42627
- process.stderr.write("\nInterrupted — finishing in-flight deletes, then flushing state and releasing the lock (press Ctrl-C again to force-quit)...\n");
42628
- });
42629
- };
42630
- process.setMaxListeners(Math.max(process.getMaxListeners(), 100));
42631
- process.on("SIGINT", sigintHandler);
42632
42695
  try {
42633
42696
  logger.info("Building dependency graph...");
42634
42697
  const template = {
@@ -43955,13 +44018,14 @@ async function deployCommand(stacks, options) {
43955
44018
  let deployInterrupted = false;
43956
44019
  const topLevelSigintHandler = () => {
43957
44020
  if (deployInterrupted) {
43958
- process.stderr.write("\nForce exit\n");
44021
+ process.stderr.write("\nForce-quit: stack locks may not be released. If the next run reports a lock, run: cdkd force-unlock <stackName>\n");
43959
44022
  process.exit(130);
43960
44023
  }
43961
44024
  process.stderr.write("\nInterrupted — waiting for in-progress operations to complete...\n");
43962
44025
  deployInterrupted = true;
43963
44026
  };
43964
44027
  process.on("SIGINT", topLevelSigintHandler);
44028
+ const unforwardSigterm = forwardSigtermToSigint();
43965
44029
  try {
43966
44030
  logger.info(cyan(synthesisStatusMessage(app, "Synthesizing CDK app...")));
43967
44031
  const synthesizer = new Synthesizer();
@@ -44101,6 +44165,7 @@ async function deployCommand(stacks, options) {
44101
44165
  return withSkipPrefix(skipPrefix, () => runStackInner(stackInfo));
44102
44166
  };
44103
44167
  const runStackInner = async (stackInfo) => {
44168
+ if (deployInterrupted) throw new DeployCancelledError(`Deploy interrupted before stack '${stackInfo.stackName}' started — not starting it.`);
44104
44169
  const stackRegion = stackInfo.region || baseRegion;
44105
44170
  logger.info(`\n${cyan("Deploying stack:")} ${bold(cyan(stackInfo.stackName))}${stackRegion !== baseRegion ? gray(` (region: ${stackRegion})`) : ""}`);
44106
44171
  switchRegion(stackRegion);
@@ -44267,6 +44332,7 @@ async function deployCommand(stacks, options) {
44267
44332
  }
44268
44333
  });
44269
44334
  } finally {
44335
+ unforwardSigterm();
44270
44336
  process.removeListener("SIGINT", topLevelSigintHandler);
44271
44337
  awsClients.destroy();
44272
44338
  }
@@ -46911,6 +46977,7 @@ async function destroyCommand(stackArgs, options) {
46911
46977
  ...options.profile && { profile: options.profile }
46912
46978
  });
46913
46979
  setAwsClients(awsClients);
46980
+ const unforwardSigterm = forwardSigtermToSigint();
46914
46981
  try {
46915
46982
  const stateConfig = {
46916
46983
  bucket: stateBucket,
@@ -47120,6 +47187,7 @@ async function destroyCommand(stackArgs, options) {
47120
47187
  if (totalErrors > 0) throw new PartialFailureError(`Destroy completed with ${totalErrors} resource error(s). State preserved — inspect 'cdkd state show <stack>' and re-run 'cdkd destroy' to retry. If the same resource keeps failing, 'cdkd state orphan <stack>' removes the state record without deleting AWS resources.`);
47121
47188
  if (interrupted) throw new PartialFailureError(`Destroy interrupted by Ctrl-C. State preserved — re-run 'cdkd destroy' to finish.`);
47122
47189
  } finally {
47190
+ unforwardSigterm();
47123
47191
  awsClients.destroy();
47124
47192
  }
47125
47193
  }
@@ -50478,6 +50546,7 @@ async function stateDestroyCommand(stackArgs, options) {
50478
50546
  registerAllProviders(providerRegistry);
50479
50547
  providerRegistry.setCustomResourceResponseBucket(setup.bucket);
50480
50548
  if (options.allowUnsupportedTypes?.length) providerRegistry.allowUnsupportedTypes(options.allowUnsupportedTypes);
50549
+ const unforwardSigterm = forwardSigtermToSigint();
50481
50550
  try {
50482
50551
  const stateRefs = await setup.stateBackend.listStacks();
50483
50552
  const knownStackNames = new Set(stateRefs.map((r) => r.stackName));
@@ -50577,6 +50646,7 @@ async function stateDestroyCommand(stackArgs, options) {
50577
50646
  if (totalErrors > 0) throw new PartialFailureError(`Destroy completed with ${totalErrors} resource error(s). State preserved — inspect 'cdkd state show <stack>' and re-run 'cdkd state destroy' to retry. If the same resource keeps failing, 'cdkd state orphan <stack>' removes the state record without deleting AWS resources.`);
50578
50647
  if (interrupted) throw new PartialFailureError(`Destroy interrupted by Ctrl-C. State preserved — re-run 'cdkd state destroy' to finish.`);
50579
50648
  } finally {
50649
+ unforwardSigterm();
50580
50650
  setup.dispose();
50581
50651
  }
50582
50652
  }
@@ -51187,13 +51257,20 @@ async function rollbackCommand(stackArg, options) {
51187
51257
  const providerRegistry = new ProviderRegistry();
51188
51258
  registerAllProviders(providerRegistry);
51189
51259
  providerRegistry.setCustomResourceResponseBucket(setup.bucket);
51190
- await setup.lockManager.acquireLockWithRetry(stackName, region, void 0, "rollback");
51191
51260
  let interrupted = false;
51192
51261
  const sigintHandler = () => {
51193
51262
  process.stderr.write("\nInterrupted — stopping rollback after the current operation...\n");
51194
51263
  interrupted = true;
51195
51264
  };
51196
51265
  process.on("SIGINT", sigintHandler);
51266
+ const unforwardSigterm = forwardSigtermToSigint();
51267
+ try {
51268
+ await setup.lockManager.acquireLockWithRetry(stackName, region, void 0, "rollback");
51269
+ } catch (error) {
51270
+ unforwardSigterm();
51271
+ process.removeListener("SIGINT", sigintHandler);
51272
+ throw error;
51273
+ }
51197
51274
  try {
51198
51275
  const stateData = await setup.stateBackend.getState(stackName, region);
51199
51276
  const journal = await setup.stateBackend.loadRollbackJournal(stackName, region);
@@ -51333,6 +51410,7 @@ async function rollbackCommand(stackArg, options) {
51333
51410
  if (totalWarnings > 0) throw new PartialFailureError(`Rollback completed with ${totalWarnings} skipped/unrecoverable operation(s) (see warnings above).`);
51334
51411
  logger.info(`\nRollback of '${stackName}' (${region}) complete.`);
51335
51412
  } finally {
51413
+ unforwardSigterm();
51336
51414
  process.removeListener("SIGINT", sigintHandler);
51337
51415
  await setup.lockManager.releaseLock(stackName, region).catch((err) => {
51338
51416
  logger.warn(`Failed to release lock for '${stackName}' (${region}): ${err instanceof Error ? err.message : String(err)}`);
@@ -63571,7 +63649,7 @@ function createMigrateCommand() {
63571
63649
  */
63572
63650
  function buildProgram() {
63573
63651
  const program = new Command();
63574
- program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.275.3");
63652
+ program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.275.5");
63575
63653
  program.hook("preAction", (_thisCommand, actionCommand) => {
63576
63654
  const { profile } = actionCommand.optsWithGlobals();
63577
63655
  if (profile !== void 0) process.env["AWS_PROFILE"] = profile;