@go-to-k/cdkd 0.275.3 → 0.275.4

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-CHL0hb1m.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-BxpwCQGo.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
  /**
@@ -43955,13 +43999,14 @@ async function deployCommand(stacks, options) {
43955
43999
  let deployInterrupted = false;
43956
44000
  const topLevelSigintHandler = () => {
43957
44001
  if (deployInterrupted) {
43958
- process.stderr.write("\nForce exit\n");
44002
+ 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
44003
  process.exit(130);
43960
44004
  }
43961
44005
  process.stderr.write("\nInterrupted — waiting for in-progress operations to complete...\n");
43962
44006
  deployInterrupted = true;
43963
44007
  };
43964
44008
  process.on("SIGINT", topLevelSigintHandler);
44009
+ const unforwardSigterm = forwardSigtermToSigint();
43965
44010
  try {
43966
44011
  logger.info(cyan(synthesisStatusMessage(app, "Synthesizing CDK app...")));
43967
44012
  const synthesizer = new Synthesizer();
@@ -44101,6 +44146,7 @@ async function deployCommand(stacks, options) {
44101
44146
  return withSkipPrefix(skipPrefix, () => runStackInner(stackInfo));
44102
44147
  };
44103
44148
  const runStackInner = async (stackInfo) => {
44149
+ if (deployInterrupted) throw new DeployCancelledError(`Deploy interrupted before stack '${stackInfo.stackName}' started — not starting it.`);
44104
44150
  const stackRegion = stackInfo.region || baseRegion;
44105
44151
  logger.info(`\n${cyan("Deploying stack:")} ${bold(cyan(stackInfo.stackName))}${stackRegion !== baseRegion ? gray(` (region: ${stackRegion})`) : ""}`);
44106
44152
  switchRegion(stackRegion);
@@ -44267,6 +44313,7 @@ async function deployCommand(stacks, options) {
44267
44313
  }
44268
44314
  });
44269
44315
  } finally {
44316
+ unforwardSigterm();
44270
44317
  process.removeListener("SIGINT", topLevelSigintHandler);
44271
44318
  awsClients.destroy();
44272
44319
  }
@@ -46911,6 +46958,7 @@ async function destroyCommand(stackArgs, options) {
46911
46958
  ...options.profile && { profile: options.profile }
46912
46959
  });
46913
46960
  setAwsClients(awsClients);
46961
+ const unforwardSigterm = forwardSigtermToSigint();
46914
46962
  try {
46915
46963
  const stateConfig = {
46916
46964
  bucket: stateBucket,
@@ -47120,6 +47168,7 @@ async function destroyCommand(stackArgs, options) {
47120
47168
  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
47169
  if (interrupted) throw new PartialFailureError(`Destroy interrupted by Ctrl-C. State preserved — re-run 'cdkd destroy' to finish.`);
47122
47170
  } finally {
47171
+ unforwardSigterm();
47123
47172
  awsClients.destroy();
47124
47173
  }
47125
47174
  }
@@ -50478,6 +50527,7 @@ async function stateDestroyCommand(stackArgs, options) {
50478
50527
  registerAllProviders(providerRegistry);
50479
50528
  providerRegistry.setCustomResourceResponseBucket(setup.bucket);
50480
50529
  if (options.allowUnsupportedTypes?.length) providerRegistry.allowUnsupportedTypes(options.allowUnsupportedTypes);
50530
+ const unforwardSigterm = forwardSigtermToSigint();
50481
50531
  try {
50482
50532
  const stateRefs = await setup.stateBackend.listStacks();
50483
50533
  const knownStackNames = new Set(stateRefs.map((r) => r.stackName));
@@ -50577,6 +50627,7 @@ async function stateDestroyCommand(stackArgs, options) {
50577
50627
  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
50628
  if (interrupted) throw new PartialFailureError(`Destroy interrupted by Ctrl-C. State preserved — re-run 'cdkd state destroy' to finish.`);
50579
50629
  } finally {
50630
+ unforwardSigterm();
50580
50631
  setup.dispose();
50581
50632
  }
50582
50633
  }
@@ -51194,6 +51245,7 @@ async function rollbackCommand(stackArg, options) {
51194
51245
  interrupted = true;
51195
51246
  };
51196
51247
  process.on("SIGINT", sigintHandler);
51248
+ const unforwardSigterm = forwardSigtermToSigint();
51197
51249
  try {
51198
51250
  const stateData = await setup.stateBackend.getState(stackName, region);
51199
51251
  const journal = await setup.stateBackend.loadRollbackJournal(stackName, region);
@@ -51333,6 +51385,7 @@ async function rollbackCommand(stackArg, options) {
51333
51385
  if (totalWarnings > 0) throw new PartialFailureError(`Rollback completed with ${totalWarnings} skipped/unrecoverable operation(s) (see warnings above).`);
51334
51386
  logger.info(`\nRollback of '${stackName}' (${region}) complete.`);
51335
51387
  } finally {
51388
+ unforwardSigterm();
51336
51389
  process.removeListener("SIGINT", sigintHandler);
51337
51390
  await setup.lockManager.releaseLock(stackName, region).catch((err) => {
51338
51391
  logger.warn(`Failed to release lock for '${stackName}' (${region}): ${err instanceof Error ? err.message : String(err)}`);
@@ -63571,7 +63624,7 @@ function createMigrateCommand() {
63571
63624
  */
63572
63625
  function buildProgram() {
63573
63626
  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");
63627
+ program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.275.4");
63575
63628
  program.hook("preAction", (_thisCommand, actionCommand) => {
63576
63629
  const { profile } = actionCommand.optsWithGlobals();
63577
63630
  if (profile !== void 0) process.env["AWS_PROFILE"] = profile;