@go-to-k/cdkd 0.282.1 → 0.282.2

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 configStringRefusal, $t as MIGRATE_TMP_PREFIX, A as green, At as validateContainerRepoName, B as slowCcOperationTimeoutMs, Bt as getDefaultStateBucketName, C as MULTI_REGION_RECREATE_BLOCKED_TYPES, Cn as NestedStackChildDirectDestroyError, Ct as rewriteTemplateAssetReferences, D as bold, Dn as ResourceUpdateNotSupportedError, Dt as getBootstrapMarkerKey, E as formatResourceLine, En as ResourceTimeoutError, Et as ensureAssetStorage, F as clearOnUpdateRemoval, Fn as withErrorHandling, Ft as runDockerStreaming, G as getAccountInfo, Gt as resolveSkipPrefix, H as isTerminationProtectionPropagationError, Ht as resolveApp, I as ProviderRegistry, It as AssetManifestLoader, J as normalizeAwsTagsToCfn, Jt as resolveUseCdkBootstrapAssets, K as refStateLookupFromResource, Kt as resolveStateBucketWithDefault, L as findActionableSilentDrops, Lt as getDockerImageBySourceHash, M as yellow, Mt as formatDockerLoginError, N as IAMRoleProvider, Nt as getDockerCmd, O as cyan, On as StackHasActiveImportsError, Ot as parseBootstrapMarker, P as collectInlinePolicyNamesManagedBySiblings, Pn as normalizeAwsError, Pt as runDockerForeground, Q as configBooleanRefusal, Qt as CFN_TEMPLATE_URL_LIMIT, R as findSilentDropProperties, Rt as Synthesizer, S as extractDeploymentEventError, Sn as MissingCdkCliError, St as loadPublishableAssetManifest, T as renderStatefulReason, Tn as ProvisioningError, Tt as BOOTSTRAP_MARKER_PREFIX, U as IntrinsicFunctionResolver, Ut as resolveAutoAssetStorage, V as disableInstanceApiTermination, Vt as getLegacyStateBucketName, W as cfnRefValueFromPhysicalId, Wt as resolveCaptureObservedState, X as assertRegionMatch, Xt as warnDeprecatedNoPrefixCliFlag, Y as resolveExplicitPhysicalId, Yt as stateBucketExistenceConfirmed, Z as coerceCfnBoolean, Zt as CFN_TEMPLATE_BODY_LIMIT, _ as createPreDeleteFinalSnapshot, _n as DeployCancelledError, _t as AssetPublisher, a as DeploymentEventsStore, an as AssemblyReader, at as applyRoleArnIfSet, b as unsupportedFinalSnapshotError, bn as LocalStartServiceError, bt as buildAssetRedirectMap, c as replayFailedOperations, cn as resolveBucketRegion, ct as withRetry, d as IMPLICIT_DELETE_DEPENDENCIES, dn as resetAwsClients, dt as DagBuilder, en as findLargeInlineResources, et as readConfigString, f as computeImplicitDeleteEdges, fn as setAwsClients, ft as TemplateParser, g as ccRoutedFinalSnapshotError, gt as shouldRetainResource, h as buildFinalSnapshotIdentifier, ht as rebuildClientForBucketRegion, i as DeploymentEventsReader, in as derivePartitionAndUrlSuffix, it as requireConfigString, j as red, jt as buildDockerImage, k as gray, kn as StackTerminationProtectionError, kt as validateAssetBucketName, l as replayRollback, ln as AwsClients, lt as isRetryableTransientError, m as PRE_DELETE_SNAPSHOT_TYPES, mn as CdkdError, mt as S3StateBackend, n as DEFAULT_RESOURCE_WARN_AFTER_MS, nn as expectedOwnerParam, nt as requireConfigArray, o as planFailedOps, on as processStackMessages, ot as DiffCalculator, p as ATOMIC_FINAL_SNAPSHOT_TYPES, pt as LockManager, q as WAFv2WebACLProvider, qt as resolveStateBucketWithDefaultAndSource, r as DeployEngine, rn as PARTITION_TABLE, rt as requireConfigObject, s as planRollback, st as describeTypeWithThrottleRetry, t as DEFAULT_RESOURCE_TIMEOUT_MS, tn as uploadCfnTemplate, tt as replayWarn, u as withResourceDeadline, un as getAwsClients, ut as isThrottlingError, v as isFinalSnapshotError, vn as LocalInvokeBuildError$1, vt as stringifyValue, w as isStatefulRecreateTargetSync, wn as PartialFailureError, wt as AssetModeResolver, x as makeCanonicalizePropertiesFn, xt as createAssetRedirectResolver, y as refusesFinalSnapshot, yn as LocalMigrateError, yt as WorkGraph, z as CloudControlProvider, zt as synthesisStatusMessage } from "./deploy-engine-DGoHusjU.js";
2
+ import { $ as configStringRefusal, $t as MIGRATE_TMP_PREFIX, A as green, At as validateContainerRepoName, B as slowCcOperationTimeoutMs, Bt as getDefaultStateBucketName, C as MULTI_REGION_RECREATE_BLOCKED_TYPES, Cn as NestedStackChildDirectDestroyError, Ct as rewriteTemplateAssetReferences, D as bold, Dn as ResourceUpdateNotSupportedError, Dt as getBootstrapMarkerKey, E as formatResourceLine, En as ResourceTimeoutError, Et as ensureAssetStorage, F as clearOnUpdateRemoval, Fn as withErrorHandling, Ft as runDockerStreaming, G as getAccountInfo, Gt as resolveSkipPrefix, H as isTerminationProtectionPropagationError, Ht as resolveApp, I as ProviderRegistry, It as AssetManifestLoader, J as normalizeAwsTagsToCfn, Jt as resolveUseCdkBootstrapAssets, K as refStateLookupFromResource, Kt as resolveStateBucketWithDefault, L as findActionableSilentDrops, Lt as getDockerImageBySourceHash, M as yellow, Mt as formatDockerLoginError, N as IAMRoleProvider, Nt as getDockerCmd, O as cyan, On as StackHasActiveImportsError, Ot as parseBootstrapMarker, P as collectInlinePolicyNamesManagedBySiblings, Pn as normalizeAwsError, Pt as runDockerForeground, Q as configBooleanRefusal, Qt as CFN_TEMPLATE_URL_LIMIT, R as findSilentDropProperties, Rt as Synthesizer, S as extractDeploymentEventError, Sn as MissingCdkCliError, St as loadPublishableAssetManifest, T as renderStatefulReason, Tn as ProvisioningError, Tt as BOOTSTRAP_MARKER_PREFIX, U as IntrinsicFunctionResolver, Ut as resolveAutoAssetStorage, V as disableInstanceApiTermination, Vt as getLegacyStateBucketName, W as cfnRefValueFromPhysicalId, Wt as resolveCaptureObservedState, X as assertRegionMatch, Xt as warnDeprecatedNoPrefixCliFlag, Y as resolveExplicitPhysicalId, Yt as stateBucketExistenceConfirmed, Z as coerceCfnBoolean, Zt as CFN_TEMPLATE_BODY_LIMIT, _ as createPreDeleteFinalSnapshot, _n as DeployCancelledError, _t as AssetPublisher, a as DeploymentEventsStore, an as AssemblyReader, at as applyRoleArnIfSet, b as unsupportedFinalSnapshotError, bn as LocalStartServiceError, bt as buildAssetRedirectMap, c as replayFailedOperations, cn as resolveBucketRegion, ct as withRetry, d as IMPLICIT_DELETE_DEPENDENCIES, dn as resetAwsClients, dt as DagBuilder, en as findLargeInlineResources, et as readConfigString, f as computeImplicitDeleteEdges, fn as setAwsClients, ft as TemplateParser, g as ccRoutedFinalSnapshotError, gt as shouldRetainResource, h as buildFinalSnapshotIdentifier, ht as rebuildClientForBucketRegion, i as DeploymentEventsReader, in as derivePartitionAndUrlSuffix, it as requireConfigString, j as red, jt as buildDockerImage, k as gray, kn as StackTerminationProtectionError, kt as validateAssetBucketName, l as replayRollback, ln as AwsClients, lt as isRetryableTransientError, m as PRE_DELETE_SNAPSHOT_TYPES, mn as CdkdError, mt as S3StateBackend, n as DEFAULT_RESOURCE_WARN_AFTER_MS, nn as expectedOwnerParam, nt as requireConfigArray, o as planFailedOps, on as processStackMessages, ot as DiffCalculator, p as ATOMIC_FINAL_SNAPSHOT_TYPES, pt as LockManager, q as WAFv2WebACLProvider, qt as resolveStateBucketWithDefaultAndSource, r as DeployEngine, rn as PARTITION_TABLE, rt as requireConfigObject, s as planRollback, st as describeTypeWithThrottleRetry, t as DEFAULT_RESOURCE_TIMEOUT_MS, tn as uploadCfnTemplate, tt as replayWarn, u as withResourceDeadline, un as getAwsClients, ut as isThrottlingError, v as isFinalSnapshotError, vn as LocalInvokeBuildError$1, vt as stringifyValue, w as isStatefulRecreateTargetSync, wn as PartialFailureError, wt as AssetModeResolver, x as makeCanonicalizePropertiesFn, xt as createAssetRedirectResolver, y as refusesFinalSnapshot, yn as LocalMigrateError, yt as WorkGraph, z as CloudControlProvider, zt as synthesisStatusMessage } from "./deploy-engine-6sSRIhrN.js";
3
3
  import { a as getLiveRenderer, c as PATTERN_B_RESOURCE_TYPES, d as generateResourceNameWithFallback, h as withStackName, i as runStackBuffered, m as withSkipPrefix, n as getLogger, o as PATTERN_B_NAME_OPTIONS, s as PATTERN_B_NAME_PROPERTIES, u as generateResourceName } from "./logger-zRrlbaQt.js";
4
- import { t as ASGProvider } from "./asg-provider-s09zJlib.js";
4
+ import { t as ASGProvider } from "./asg-provider-B5EgvcoP.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, DeleteBucketEncryptionCommand, DeleteBucketIntelligentTieringConfigurationCommand, DeleteBucketInventoryConfigurationCommand, DeleteBucketLifecycleCommand, DeleteBucketMetricsConfigurationCommand, DeleteBucketOwnershipControlsCommand, DeleteBucketPolicyCommand, DeleteBucketReplicationCommand, DeleteBucketTaggingCommand, DeleteBucketWebsiteCommand, DeleteObjectsCommand, GetBucketAccelerateConfigurationCommand, GetBucketCorsCommand, GetBucketEncryptionCommand, GetBucketLifecycleConfigurationCommand, GetBucketLocationCommand, GetBucketLoggingCommand, GetBucketNotificationConfigurationCommand, GetBucketOwnershipControlsCommand, 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";
@@ -52866,7 +52866,11 @@ async function runDestroyForStack(stackName, state, ctx) {
52866
52866
  }
52867
52867
  }
52868
52868
  const remainingResources = { ...state.resources };
52869
+ const stateTargetFor = (logicalId, resourceType) => resourceType === NESTED_STACK_TYPE ? `${stackName}~${logicalId}` : stackName;
52869
52870
  const skippedStateTargets = /* @__PURE__ */ new Set();
52871
+ const failedStateTargets = /* @__PURE__ */ new Set();
52872
+ /** `'cmd A' / 'cmd B'` — the quoted, slash-joined hint both summary arms print. */
52873
+ const hintFor = (command, targets) => targets.map((t) => `'${command} ${t}'`).join(" / ");
52870
52874
  const buildDestroySnapshot = () => {
52871
52875
  const { imports: _imports, outputReads: _outputReads, ...rest } = state;
52872
52876
  return {
@@ -53031,7 +53035,7 @@ async function runDestroyForStack(stackName, state, ctx) {
53031
53035
  if (deleteResult?.outcome === "skipped") {
53032
53036
  logger.info(` ${formatResourceLine("skipped", logicalId, resource.resourceType, `skipped (${deleteResult.reason})`)}`);
53033
53037
  result.skippedCount++;
53034
- skippedStateTargets.add(resource.resourceType === NESTED_STACK_TYPE ? `${stackName}~${logicalId}` : stackName);
53038
+ skippedStateTargets.add(stateTargetFor(logicalId, resource.resourceType));
53035
53039
  ctx.eventRecorder?.record({
53036
53040
  eventType: "RESOURCE_SKIPPED",
53037
53041
  stackName,
@@ -53081,6 +53085,7 @@ async function runDestroyForStack(stackName, state, ctx) {
53081
53085
  const wrapped = new ProvisioningError(error.message, resource.resourceType, logicalId, resource.physicalId, error);
53082
53086
  logger.error(` ✗ Failed to delete ${logicalId}:`, wrapped.message);
53083
53087
  result.errorCount++;
53088
+ failedStateTargets.add(stateTargetFor(logicalId, resource.resourceType));
53084
53089
  ctx.eventRecorder?.record({
53085
53090
  eventType: "RESOURCE_FAILED",
53086
53091
  stackName,
@@ -53094,6 +53099,7 @@ async function runDestroyForStack(stackName, state, ctx) {
53094
53099
  } else {
53095
53100
  logger.error(` ✗ Failed to delete ${logicalId}:`, String(error));
53096
53101
  result.errorCount++;
53102
+ failedStateTargets.add(stateTargetFor(logicalId, resource.resourceType));
53097
53103
  ctx.eventRecorder?.record({
53098
53104
  eventType: "RESOURCE_FAILED",
53099
53105
  stackName,
@@ -53134,10 +53140,15 @@ async function runDestroyForStack(stackName, state, ctx) {
53134
53140
  else if (result.interrupted && result.errorCount === 0) logger.warn(`\n${yellow("⚠")} ${bold(`Stack ${stackName} destroy interrupted`)} (${green(result.deletedCount)} deleted${retainedSuffix}${skippedSuffix}, ${result.errorCount} errors). State preserved — re-run 'cdkd destroy' / 'cdkd state destroy' to finish.`);
53135
53141
  else if (result.errorCount === 0) {
53136
53142
  const targets = [...skippedStateTargets];
53137
- const showHint = targets.map((t) => `'cdkd state show ${t}'`).join(" / ");
53138
- const orphanHint = targets.map((t) => `'cdkd state orphan ${t}'`).join(" / ");
53143
+ const showHint = hintFor("cdkd state show", targets);
53144
+ const orphanHint = hintFor("cdkd state orphan", targets);
53139
53145
  logger.warn(`\n${yellow("⚠")} ${bold(`Stack ${stackName} partially destroyed`)} (${green(result.deletedCount)} deleted${retainedSuffix}${skippedSuffix}, ${result.errorCount} errors). cdkd could not address the skipped resource(s), so they may still exist in AWS. Fix the physicalId in state.json (${showHint}) and re-run, or delete them by hand and drop the records with ${orphanHint}.`);
53140
- } else logger.warn(`\n${yellow("⚠")} ${bold(`Stack ${stackName} partially destroyed`)} (${green(result.deletedCount)} deleted${retainedSuffix}${skippedSuffix}, ${red(result.errorCount)} errors). State preserved — re-run 'cdkd destroy' / 'cdkd state destroy' to clean up. If the same resource keeps failing, 'cdkd state orphan ${stackName}' is the last resort: it removes the state record without deleting AWS resources.`);
53146
+ } else {
53147
+ const orphanHint = hintFor("cdkd state orphan", failedStateTargets.size > 0 ? [...failedStateTargets] : [stackName]);
53148
+ const skippedTargets = [...skippedStateTargets];
53149
+ const skippedClause = skippedTargets.length > 0 ? ` Separately, ${result.skippedCount} resource(s) were SKIPPED — cdkd could not address them, so no delete was issued and they may still exist in AWS. Fix the physicalId in state.json (${hintFor("cdkd state show", skippedTargets)}) and re-run, or delete them by hand and drop the records with ${hintFor("cdkd state orphan", skippedTargets)}.` : "";
53150
+ logger.warn(`\n${yellow("⚠")} ${bold(`Stack ${stackName} partially destroyed`)} (${green(result.deletedCount)} deleted${retainedSuffix}${skippedSuffix}, ${red(result.errorCount)} errors). State preserved — re-run 'cdkd destroy' / 'cdkd state destroy' to clean up. If the same resource keeps failing, ${orphanHint} is the last resort: it removes the state record without deleting AWS resources.` + skippedClause);
53151
+ }
53141
53152
  } finally {
53142
53153
  process.removeListener("SIGINT", sigintHandler);
53143
53154
  renderer.stop();
@@ -53212,6 +53223,50 @@ function getCurrentNestedStackContext() {
53212
53223
  return storage.getStore();
53213
53224
  }
53214
53225
 
53226
+ //#endregion
53227
+ //#region src/provisioning/nested-stack-messages.ts
53228
+ /**
53229
+ * User-facing message builders for the nested-stack (`AWS::CloudFormation::Stack`)
53230
+ * delete path.
53231
+ *
53232
+ * **This module must stay a LEAF** — no imports, ever. It exists precisely so
53233
+ * the strings can be shared without dragging a module graph along: the obvious
53234
+ * home, `providers/nested-stack-provider.ts`, imports `destroy-runner.ts`
53235
+ * (it recurses into a child destroy), which imports `register-providers.ts`,
53236
+ * which imports every provider in the tree — including `nested-stack-provider`
53237
+ * itself. Importing the builder from there therefore pulled the whole provider
53238
+ * registry into two unrelated unit tests and closed that cycle. It is harmless
53239
+ * only for as long as nothing on the ring does module-scope work, which is not
53240
+ * a property any of those files promises. Adding an import here would silently
53241
+ * re-create the problem, so keep this file dependency-free.
53242
+ */
53243
+ /**
53244
+ * The message `NestedStackProvider.delete` throws when the child stack's own
53245
+ * destroy reported `errorCount > 0` (issue
53246
+ * [#1777](https://github.com/go-to-k/cdkd/issues/1777)).
53247
+ *
53248
+ * A builder rather than an inline template literal so tests that need the exact
53249
+ * string cannot drift onto a stale hand-written copy. That matters more than
53250
+ * usual here, because both callers of `delete()` classify a delete failure by
53251
+ * MESSAGE: an already-deleted-shaped phrase (`not found` / `does not exist` /
53252
+ * `No policy found` / `NoSuchEntity` / `NotFoundException`, plus the deploy
53253
+ * engine's `was not found` / `ResourceNotFoundException`) is read as idempotent
53254
+ * success and DROPS the state row — the exact outcome this throw exists to
53255
+ * prevent. `tests/unit/provisioning/nested-stack-provider.test.ts` pins that
53256
+ * property against the union of both phrase sets.
53257
+ *
53258
+ * @param childStackName the child's `<parent>~<childLogicalId>` state key
53259
+ * @param errorCount resources in the child that failed to delete
53260
+ * @param alsoSkippedCount resources the child SKIPPED (no AWS call issued)
53261
+ * @param alsoInterrupted whether the child's destroy was also interrupted
53262
+ */
53263
+ function nestedStackChildFailureMessage(childStackName, errorCount, alsoSkippedCount, alsoInterrupted) {
53264
+ const extra = [];
53265
+ if (alsoSkippedCount > 0) extra.push(`${alsoSkippedCount} resource(s) were also skipped`);
53266
+ if (alsoInterrupted) extra.push("the child destroy was also interrupted");
53267
+ return `Nested stack ${childStackName} failed to destroy: ${errorCount} resource(s) failed to delete` + (extra.length > 0 ? ` (${extra.join("; ")})` : "") + `. The child's state is PRESERVED and still lists them — inspect it with 'cdkd state show ${childStackName}', resolve the failure, and re-run the destroy. The parent's record of this nested stack is kept so the child stays reachable.`;
53268
+ }
53269
+
53215
53270
  //#endregion
53216
53271
  //#region src/provisioning/providers/nested-stack-provider.ts
53217
53272
  /**
@@ -53378,6 +53433,7 @@ var NestedStackProvider = class {
53378
53433
  ...ctx.destroyOptions?.resourceWarnAfterByType && { resourceWarnAfterByType: ctx.destroyOptions.resourceWarnAfterByType },
53379
53434
  ...ctx.destroyOptions?.resourceTimeoutByType && { resourceTimeoutByType: ctx.destroyOptions.resourceTimeoutByType }
53380
53435
  }));
53436
+ if (childResult.errorCount > 0) throw new Error(nestedStackChildFailureMessage(childStackName, childResult.errorCount, childResult.skippedCount, childResult.interrupted));
53381
53437
  if (childResult.skippedCount > 0 || childResult.interrupted) {
53382
53438
  const causes = [];
53383
53439
  if (childResult.skippedCount > 0) causes.push(`skipped ${childResult.skippedCount} resource(s)`);
@@ -75494,7 +75550,7 @@ function createMigrateCommand() {
75494
75550
  */
75495
75551
  function buildProgram() {
75496
75552
  const program = new Command();
75497
- program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.282.1");
75553
+ program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.282.2");
75498
75554
  program.hook("preAction", (_thisCommand, actionCommand) => {
75499
75555
  const { profile } = actionCommand.optsWithGlobals();
75500
75556
  if (profile !== void 0) process.env["AWS_PROFILE"] = profile;