@go-to-k/cdkd 0.275.2 → 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-D30XI_UX.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-2hct1hkv.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
  /**
@@ -41386,16 +41430,33 @@ var S3DirectoryBucketProvider = class {
41386
41430
  /**
41387
41431
  * Delete an S3 Express Directory Bucket
41388
41432
  *
41389
- * Must empty the bucket before deletion. Directory buckets do not support
41390
- * versioning, so only current objects need to be deleted.
41433
+ * CloudFormation-parity data guard (issue #1344, sibling of #1340): a
41434
+ * non-empty directory bucket is only auto-emptied when the user opted in —
41435
+ * the `aws-cdk:auto-delete-objects` tag on the bucket (settable only via
41436
+ * `--allow-unsupported-properties` today, since `Tags` is not yet a
41437
+ * handled property for this type) or the deploy engine's
41438
+ * `--force-stateful-recreation` consent on a replacement delete
41439
+ * (`DeleteContext.forceDataDelete`). Otherwise the not-empty error
41440
+ * surfaces exactly like CloudFormation's DELETE_FAILED (live-A/B-verified
41441
+ * 2026-08-03: CFn fails a non-empty DirectoryBucket delete with "The
41442
+ * bucket you tried to delete is not empty", 409).
41443
+ *
41444
+ * Directory buckets do not support versioning, so the opted-in auto-empty
41445
+ * only needs to delete current objects.
41391
41446
  */
41392
- async delete(logicalId, physicalId, resourceType, _properties, context) {
41447
+ async delete(logicalId, physicalId, resourceType, properties, context) {
41393
41448
  this.logger.debug(`Deleting S3 Express Directory Bucket ${logicalId}: ${physicalId}`);
41449
+ const allowAutoEmpty = context?.forceDataDelete === true || hasCdkAutoDeleteTag(properties, "aws-cdk:auto-delete-objects");
41394
41450
  try {
41395
- await this.emptyBucket(physicalId);
41451
+ if (allowAutoEmpty) {
41452
+ this.logger.info(`Emptying directory bucket ${physicalId} before deletion (auto-delete opt-in present)`);
41453
+ await this.emptyBucket(physicalId);
41454
+ }
41396
41455
  await this.s3Client.send(new DeleteBucketCommand({ Bucket: physicalId }));
41397
41456
  this.logger.debug(`Successfully deleted S3 Express Directory Bucket ${logicalId}`);
41398
41457
  } catch (error) {
41458
+ const notEmptyMsg = error instanceof Error ? error.message : String(error);
41459
+ if (!allowAutoEmpty && (notEmptyMsg.includes("not empty") || notEmptyMsg.includes("BucketNotEmpty"))) throw new ProvisioningError(`Failed to delete S3 Express Directory Bucket ${logicalId}: bucket ${physicalId} is not empty. Matching CloudFormation, cdkd does not delete a non-empty directory bucket without an explicit opt-in. Delete all objects first (e.g. aws s3 rm s3://${physicalId} --recursive) and destroy again.`, resourceType, logicalId, physicalId, error instanceof Error ? error : void 0);
41399
41460
  if (error instanceof Error && (error.name === "NoSuchBucket" || error.name === "BucketNotFound")) {
41400
41461
  assertRegionMatch(await this.s3Client.config.region(), context?.expectedRegion, resourceType, logicalId, physicalId);
41401
41462
  this.logger.debug(`Bucket ${physicalId} does not exist, skipping deletion`);
@@ -43938,13 +43999,14 @@ async function deployCommand(stacks, options) {
43938
43999
  let deployInterrupted = false;
43939
44000
  const topLevelSigintHandler = () => {
43940
44001
  if (deployInterrupted) {
43941
- 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");
43942
44003
  process.exit(130);
43943
44004
  }
43944
44005
  process.stderr.write("\nInterrupted — waiting for in-progress operations to complete...\n");
43945
44006
  deployInterrupted = true;
43946
44007
  };
43947
44008
  process.on("SIGINT", topLevelSigintHandler);
44009
+ const unforwardSigterm = forwardSigtermToSigint();
43948
44010
  try {
43949
44011
  logger.info(cyan(synthesisStatusMessage(app, "Synthesizing CDK app...")));
43950
44012
  const synthesizer = new Synthesizer();
@@ -44084,6 +44146,7 @@ async function deployCommand(stacks, options) {
44084
44146
  return withSkipPrefix(skipPrefix, () => runStackInner(stackInfo));
44085
44147
  };
44086
44148
  const runStackInner = async (stackInfo) => {
44149
+ if (deployInterrupted) throw new DeployCancelledError(`Deploy interrupted before stack '${stackInfo.stackName}' started — not starting it.`);
44087
44150
  const stackRegion = stackInfo.region || baseRegion;
44088
44151
  logger.info(`\n${cyan("Deploying stack:")} ${bold(cyan(stackInfo.stackName))}${stackRegion !== baseRegion ? gray(` (region: ${stackRegion})`) : ""}`);
44089
44152
  switchRegion(stackRegion);
@@ -44250,6 +44313,7 @@ async function deployCommand(stacks, options) {
44250
44313
  }
44251
44314
  });
44252
44315
  } finally {
44316
+ unforwardSigterm();
44253
44317
  process.removeListener("SIGINT", topLevelSigintHandler);
44254
44318
  awsClients.destroy();
44255
44319
  }
@@ -46894,6 +46958,7 @@ async function destroyCommand(stackArgs, options) {
46894
46958
  ...options.profile && { profile: options.profile }
46895
46959
  });
46896
46960
  setAwsClients(awsClients);
46961
+ const unforwardSigterm = forwardSigtermToSigint();
46897
46962
  try {
46898
46963
  const stateConfig = {
46899
46964
  bucket: stateBucket,
@@ -47103,6 +47168,7 @@ async function destroyCommand(stackArgs, options) {
47103
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.`);
47104
47169
  if (interrupted) throw new PartialFailureError(`Destroy interrupted by Ctrl-C. State preserved — re-run 'cdkd destroy' to finish.`);
47105
47170
  } finally {
47171
+ unforwardSigterm();
47106
47172
  awsClients.destroy();
47107
47173
  }
47108
47174
  }
@@ -50461,6 +50527,7 @@ async function stateDestroyCommand(stackArgs, options) {
50461
50527
  registerAllProviders(providerRegistry);
50462
50528
  providerRegistry.setCustomResourceResponseBucket(setup.bucket);
50463
50529
  if (options.allowUnsupportedTypes?.length) providerRegistry.allowUnsupportedTypes(options.allowUnsupportedTypes);
50530
+ const unforwardSigterm = forwardSigtermToSigint();
50464
50531
  try {
50465
50532
  const stateRefs = await setup.stateBackend.listStacks();
50466
50533
  const knownStackNames = new Set(stateRefs.map((r) => r.stackName));
@@ -50560,6 +50627,7 @@ async function stateDestroyCommand(stackArgs, options) {
50560
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.`);
50561
50628
  if (interrupted) throw new PartialFailureError(`Destroy interrupted by Ctrl-C. State preserved — re-run 'cdkd state destroy' to finish.`);
50562
50629
  } finally {
50630
+ unforwardSigterm();
50563
50631
  setup.dispose();
50564
50632
  }
50565
50633
  }
@@ -51177,6 +51245,7 @@ async function rollbackCommand(stackArg, options) {
51177
51245
  interrupted = true;
51178
51246
  };
51179
51247
  process.on("SIGINT", sigintHandler);
51248
+ const unforwardSigterm = forwardSigtermToSigint();
51180
51249
  try {
51181
51250
  const stateData = await setup.stateBackend.getState(stackName, region);
51182
51251
  const journal = await setup.stateBackend.loadRollbackJournal(stackName, region);
@@ -51316,6 +51385,7 @@ async function rollbackCommand(stackArg, options) {
51316
51385
  if (totalWarnings > 0) throw new PartialFailureError(`Rollback completed with ${totalWarnings} skipped/unrecoverable operation(s) (see warnings above).`);
51317
51386
  logger.info(`\nRollback of '${stackName}' (${region}) complete.`);
51318
51387
  } finally {
51388
+ unforwardSigterm();
51319
51389
  process.removeListener("SIGINT", sigintHandler);
51320
51390
  await setup.lockManager.releaseLock(stackName, region).catch((err) => {
51321
51391
  logger.warn(`Failed to release lock for '${stackName}' (${region}): ${err instanceof Error ? err.message : String(err)}`);
@@ -63554,7 +63624,7 @@ function createMigrateCommand() {
63554
63624
  */
63555
63625
  function buildProgram() {
63556
63626
  const program = new Command();
63557
- program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.275.2");
63627
+ program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.275.4");
63558
63628
  program.hook("preAction", (_thisCommand, actionCommand) => {
63559
63629
  const { profile } = actionCommand.optsWithGlobals();
63560
63630
  if (profile !== void 0) process.env["AWS_PROFILE"] = profile;