@go-to-k/cdkd 0.276.0 → 0.276.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 TemplateParser, $t as CdkdError, A as yellow, At as resolveAutoAssetStorage, B as IntrinsicFunctionResolver, Bt as MIGRATE_TMP_PREFIX, C as renderStatefulReason, Ct as AssetManifestLoader, D as gray, Dt as getDefaultStateBucketName, E as cyan, Et as synthesisStatusMessage, F as findActionableSilentDrops, Ft as resolveUseCdkBootstrapAssets, G as resolveExplicitPhysicalId, Gt as processStackMessages, H as refStateLookupFromResource, Ht as uploadCfnTemplate, I as CloudControlProvider, It as stateBucketExistenceConfirmed, J as DiffCalculator, Jt as AwsClients, K as assertRegionMatch, L as slowCcOperationTimeoutMs, Lt as warnDeprecatedNoPrefixCliFlag, M as collectInlinePolicyNamesManagedBySiblings, Mt as resolveSkipPrefix, N as clearOnUpdateRemoval, Nt as resolveStateBucketWithDefault, O as green, Ot as getLegacyStateBucketName, P as ProviderRegistry, Pt as resolveStateBucketWithDefaultAndSource, Q as DagBuilder, R as disableInstanceApiTermination, Rt as CFN_TEMPLATE_BODY_LIMIT, S as isStatefulRecreateTargetSync, St as runDockerStreaming, T as bold, Tt as Synthesizer, U as WAFv2WebACLProvider, Ut as expectedOwnerParam, V as cfnRefValueFromPhysicalId, Vt as findLargeInlineResources, W as normalizeAwsTagsToCfn, Wt as AssemblyReader, X as withRetry, Xt as resetAwsClients, Y as describeTypeWithThrottleRetry, Yt as getAwsClients, Z as isRetryableTransientError, Zt as setAwsClients, _ as createPreDeleteFinalSnapshot, _t as validateContainerRepoName, a as DeploymentEventsStore, an as LocalStartServiceError, at as stringifyValue, b as extractDeploymentEventError, bn as withErrorHandling, bt as getDockerCmd, c as replayFailedOperations, cn as NestedStackChildDirectDestroyError, ct as createAssetRedirectResolver, d as IMPLICIT_DELETE_DEPENDENCIES, dn as ResourceTimeoutError, dt as AssetModeResolver, et as LockManager, f as computeImplicitDeleteEdges, fn as ResourceUpdateNotSupportedError, ft as BOOTSTRAP_MARKER_PREFIX, g as ccRoutedFinalSnapshotError, gt as validateAssetBucketName, h as buildFinalSnapshotIdentifier, ht as parseBootstrapMarker, i as DeploymentEventsReader, in as LocalMigrateError, it as AssetPublisher, j as IAMRoleProvider, jt as resolveCaptureObservedState, k as red, kt as resolveApp, l as replayRollback, ln as PartialFailureError, lt as loadPublishableAssetManifest, m as PRE_DELETE_SNAPSHOT_TYPES, mn as StackTerminationProtectionError, mt as getBootstrapMarkerKey, n as DEFAULT_RESOURCE_WARN_AFTER_MS, nn as DeployCancelledError, nt as rebuildClientForBucketRegion, o as planFailedOps, ot as WorkGraph, p as ATOMIC_FINAL_SNAPSHOT_TYPES, pn as StackHasActiveImportsError, pt as ensureAssetStorage, q as applyRoleArnIfSet, qt as resolveBucketRegion, r as DeployEngine, rn as LocalInvokeBuildError$1, rt as shouldRetainResource, s as planRollback, sn as MissingCdkCliError, st as buildAssetRedirectMap, t as DEFAULT_RESOURCE_TIMEOUT_MS, tt as S3StateBackend, u as withResourceDeadline, un as ProvisioningError, ut as rewriteTemplateAssetReferences, v as isFinalSnapshotError, vt as buildDockerImage, w as formatResourceLine, wt as getDockerImageBySourceHash, x as MULTI_REGION_RECREATE_BLOCKED_TYPES, xt as runDockerForeground, y as unsupportedFinalSnapshotError, yn as normalizeAwsError, yt as formatDockerLoginError, z as isTerminationProtectionPropagationError, zt as CFN_TEMPLATE_URL_LIMIT } from "./deploy-engine-j0TmnJYJ.js";
2
+ import { $ as TemplateParser, $t as CdkdError, A as yellow, At as resolveAutoAssetStorage, B as IntrinsicFunctionResolver, Bt as MIGRATE_TMP_PREFIX, C as renderStatefulReason, Ct as AssetManifestLoader, D as gray, Dt as getDefaultStateBucketName, E as cyan, Et as synthesisStatusMessage, F as findActionableSilentDrops, Ft as resolveUseCdkBootstrapAssets, G as resolveExplicitPhysicalId, Gt as processStackMessages, H as refStateLookupFromResource, Ht as uploadCfnTemplate, I as CloudControlProvider, It as stateBucketExistenceConfirmed, J as DiffCalculator, Jt as AwsClients, K as assertRegionMatch, L as slowCcOperationTimeoutMs, Lt as warnDeprecatedNoPrefixCliFlag, M as collectInlinePolicyNamesManagedBySiblings, Mt as resolveSkipPrefix, N as clearOnUpdateRemoval, Nt as resolveStateBucketWithDefault, O as green, Ot as getLegacyStateBucketName, P as ProviderRegistry, Pt as resolveStateBucketWithDefaultAndSource, Q as DagBuilder, R as disableInstanceApiTermination, Rt as CFN_TEMPLATE_BODY_LIMIT, S as isStatefulRecreateTargetSync, St as runDockerStreaming, T as bold, Tt as Synthesizer, U as WAFv2WebACLProvider, Ut as expectedOwnerParam, V as cfnRefValueFromPhysicalId, Vt as findLargeInlineResources, W as normalizeAwsTagsToCfn, Wt as AssemblyReader, X as withRetry, Xt as resetAwsClients, Y as describeTypeWithThrottleRetry, Yt as getAwsClients, Z as isRetryableTransientError, Zt as setAwsClients, _ as createPreDeleteFinalSnapshot, _t as validateContainerRepoName, a as DeploymentEventsStore, an as LocalStartServiceError, at as stringifyValue, b as extractDeploymentEventError, bn as withErrorHandling, bt as getDockerCmd, c as replayFailedOperations, cn as NestedStackChildDirectDestroyError, ct as createAssetRedirectResolver, d as IMPLICIT_DELETE_DEPENDENCIES, dn as ResourceTimeoutError, dt as AssetModeResolver, et as LockManager, f as computeImplicitDeleteEdges, fn as ResourceUpdateNotSupportedError, ft as BOOTSTRAP_MARKER_PREFIX, g as ccRoutedFinalSnapshotError, gt as validateAssetBucketName, h as buildFinalSnapshotIdentifier, ht as parseBootstrapMarker, i as DeploymentEventsReader, in as LocalMigrateError, it as AssetPublisher, j as IAMRoleProvider, jt as resolveCaptureObservedState, k as red, kt as resolveApp, l as replayRollback, ln as PartialFailureError, lt as loadPublishableAssetManifest, m as PRE_DELETE_SNAPSHOT_TYPES, mn as StackTerminationProtectionError, mt as getBootstrapMarkerKey, n as DEFAULT_RESOURCE_WARN_AFTER_MS, nn as DeployCancelledError, nt as rebuildClientForBucketRegion, o as planFailedOps, ot as WorkGraph, p as ATOMIC_FINAL_SNAPSHOT_TYPES, pn as StackHasActiveImportsError, pt as ensureAssetStorage, q as applyRoleArnIfSet, qt as resolveBucketRegion, r as DeployEngine, rn as LocalInvokeBuildError$1, rt as shouldRetainResource, s as planRollback, sn as MissingCdkCliError, st as buildAssetRedirectMap, t as DEFAULT_RESOURCE_TIMEOUT_MS, tt as S3StateBackend, u as withResourceDeadline, un as ProvisioningError, ut as rewriteTemplateAssetReferences, v as isFinalSnapshotError, vt as buildDockerImage, w as formatResourceLine, wt as getDockerImageBySourceHash, x as MULTI_REGION_RECREATE_BLOCKED_TYPES, xt as runDockerForeground, y as unsupportedFinalSnapshotError, yn as normalizeAwsError, yt as formatDockerLoginError, z as isTerminationProtectionPropagationError, zt as CFN_TEMPLATE_URL_LIMIT } from "./deploy-engine-CwVBPKqE.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-DeLTuWlm.js";
4
+ import { t as ASGProvider } from "./asg-provider-X-k9FXgs.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";
@@ -569,7 +569,7 @@ const recreateViaSdkProviderOption = new Option("--recreate-via-sdk-provider <lo
569
569
  * force would create a false sense of granularity (the user is opting
570
570
  * into a footgun; pretending to scope it per-resource is misleading).
571
571
  */
572
- const forceStatefulRecreationOption = new Option("--force-stateful-recreation", "Bypass the stateful-resource guard for --recreate-via-cc-api targets. Required when ANY named target is a stateful type (RDS / DynamoDB / EFS / S3 with data / Logs with retention / Cognito / Secrets / SSM / Glue / ECR / CloudFront / Kinesis / OpenSearch). Destroy + recreate loses ALL data in the resource — no automatic data migration. Triple-opt-in for CI use: --recreate-via-cc-api <id> --force-stateful-recreation --yes.").default(false);
572
+ const forceStatefulRecreationOption = new Option("--force-stateful-recreation", "Bypass the stateful-resource guard for --recreate-via-cc-api targets. Required when ANY named target is a stateful type (RDS / DynamoDB / EFS / FSx / EBS Volume / S3 with data / Logs with retention / Cognito / Secrets / SSM / Glue / ECR / CloudFront / Kinesis / OpenSearch). Destroy + recreate loses ALL data in the resource — no automatic data migration. Triple-opt-in for CI use: --recreate-via-cc-api <id> --force-stateful-recreation --yes.").default(false);
573
573
  const replaceOption = new Option("--replace", "Replace (DELETE + CREATE) a resource whose in-place update is rejected because an immutable property changed and AWS exposes no update API for it (e.g. Lambda LayerVersion content, EFS AccessPoint, ECS TaskDefinition, ApiGatewayV2 immutable fields). Without this flag such a change fails the deploy. Stateful types (RDS / DynamoDB / EFS / S3 with data / Logs with retention / etc.) ALSO require --force-stateful-recreation since the replacement is a data-losing DELETE + CREATE.").default(false);
574
574
  /**
575
575
  * Issue #1002 PR 2 — per-invocation legacy pin for asset destinations
@@ -718,12 +718,13 @@ const destroyOptions = [
718
718
  * `AWS::ElastiCache::ReplicationGroup`; and a refusal when cdkd cannot
719
719
  * honor the policy (a Cloud-Control-routed atomic type — its delete has no
720
720
  * final-snapshot parameter). Attached to `cdkd deploy` (template-removal +
721
- * replacement deletes), `cdkd destroy`, and `cdkd state destroy` — NOT to
722
- * the shared `destroyOptions` array, which `cdkd orphan` also consumes
723
- * (orphan never deletes AWS resources, so the flag would be inert noise
724
- * there).
721
+ * replacement deletes), `cdkd destroy`, `cdkd state destroy`, and
722
+ * `cdkd rollback` (issue #1358 a rolled-back CREATE under
723
+ * `DeletionPolicy: Snapshot` is snapshotted, then deleted) NOT to the
724
+ * shared `destroyOptions` array, which `cdkd orphan` also consumes (orphan
725
+ * never deletes AWS resources, so the flag would be inert noise there).
725
726
  */
726
- const skipFinalSnapshotOption = new Option("--skip-final-snapshot", "Delete resources whose DeletionPolicy (or, on replacements, UpdateReplacePolicy) is 'Snapshot' WITHOUT creating the final snapshot the policy promises (DATA LOSS — explicit opt-out of CloudFormation parity). By default cdkd creates the final snapshot for every CloudFormation-supported type (RDS DBInstance / DBCluster, Neptune / DocDB clusters, ElastiCache CacheCluster / ReplicationGroup, Redshift Cluster, EC2 Volume) and refuses the delete when it cannot — e.g. a resource managed via the Cloud Control API route, whose delete has no final-snapshot parameter.").default(false);
727
+ const skipFinalSnapshotOption = new Option("--skip-final-snapshot", "Delete resources whose DeletionPolicy (or, on replacements, UpdateReplacePolicy) is 'Snapshot' WITHOUT creating the final snapshot the policy promises (DATA LOSS — explicit opt-out of CloudFormation parity). By default cdkd creates the final snapshot for every CloudFormation-supported type (RDS DBInstance / DBCluster, Neptune / DocDB clusters, ElastiCache CacheCluster / ReplicationGroup, Redshift Cluster, EC2 Volume) and refuses the delete when it cannot — e.g. a resource managed via the Cloud Control API route, whose delete has no final-snapshot parameter. On 'cdkd rollback' the flag governs the rolled-back CREATE's DeletionPolicy; a reverse-replacement delete of the NEW resource keeps its own bounded UpdateReplacePolicy behavior and is unaffected.").default(false);
727
728
 
728
729
  //#endregion
729
730
  //#region src/cli/commands/state-file-keys.ts
@@ -51245,13 +51246,19 @@ async function findJournalCandidates(backend, prefix) {
51245
51246
  }
51246
51247
  return refs;
51247
51248
  }
51248
- /** Human label for a planned rollback action (plan preview). */
51249
- function actionLabel(item) {
51249
+ /**
51250
+ * Human label for a planned rollback action (plan preview). `skipFinalSnapshot`
51251
+ * is threaded in because the classifier is pure (it cannot see CLI flags) and
51252
+ * the Snapshot label would otherwise promise a final snapshot the run is about
51253
+ * to skip — a data-loss-relevant lie in the one preview the user reads.
51254
+ */
51255
+ function actionLabel(item, skipFinalSnapshot) {
51250
51256
  const { op, action, replacement } = item;
51251
51257
  const rep = replacement ? " [replacement occurred, best-effort revert]" : "";
51252
51258
  switch (action) {
51253
51259
  case "delete": return ` - delete ${op.logicalId} (${op.resourceType})${rep}`;
51254
- case "orphan-retain": return ` - orphan ${op.logicalId} (${op.resourceType}) [DeletionPolicy Retain/Snapshot — left in AWS]`;
51260
+ case "delete-with-final-snapshot": return skipFinalSnapshot ? ` - delete ${op.logicalId} (${op.resourceType}) [DeletionPolicy Snapshot — NO final snapshot (--skip-final-snapshot)]` : ` - delete ${op.logicalId} (${op.resourceType}) [DeletionPolicy Snapshot — final snapshot, then delete]`;
51261
+ case "orphan-retain": return ` - orphan ${op.logicalId} (${op.resourceType}) [DeletionPolicy Retain — left in AWS]`;
51255
51262
  case "orphan-flag": return ` - orphan ${op.logicalId} (${op.resourceType}) [--orphan]`;
51256
51263
  case "revert": return ` - revert ${op.logicalId} (${op.resourceType})${rep}`;
51257
51264
  case "reverse-replacement": return ` - reverse-replace ${op.logicalId} (${op.resourceType}) [re-create old resource, delete new]`;
@@ -51294,6 +51301,7 @@ async function rollbackCommand(stackArg, options) {
51294
51301
  warnIfDeprecatedRegion(options);
51295
51302
  const setup = await setupStateBackend(options);
51296
51303
  const skipConfirmation = options.force === true || options.yes === true;
51304
+ let stackAwsClients;
51297
51305
  try {
51298
51306
  let ref;
51299
51307
  if (stackArg) ref = resolveSingleRegion(stackArg, await setup.stateBackend.listStacks(), options.stackRegion);
@@ -51312,6 +51320,12 @@ async function rollbackCommand(stackArg, options) {
51312
51320
  }
51313
51321
  const stackName = ref.stackName;
51314
51322
  const region = ref.region ?? setup.region;
51323
+ stackAwsClients = new AwsClients({
51324
+ region,
51325
+ ...options.profile && { profile: options.profile }
51326
+ });
51327
+ setAwsClients(stackAwsClients);
51328
+ const finalSnapshotClients = stackAwsClients;
51315
51329
  const providerRegistry = new ProviderRegistry();
51316
51330
  registerAllProviders(providerRegistry);
51317
51331
  providerRegistry.setCustomResourceResponseBucket(setup.bucket);
@@ -51350,7 +51364,7 @@ async function rollbackCommand(stackArg, options) {
51350
51364
  applyFailedPlanToPreview(failedPlan, planStateView);
51351
51365
  } else for (const fop of segment.failedOperations) logger.info(` - (left as-is) ${fop.logicalId} (${fop.resourceType}) — its ${fop.changeType} FAILED mid-deploy; pass --revert-failed to attempt reverting it`);
51352
51366
  const plan = planRollback(segment.operations, planStateView, orphanLogicalIds);
51353
- for (const item of plan) logger.info(actionLabel(item));
51367
+ for (const item of plan) logger.info(actionLabel(item, options.skipFinalSnapshot === true));
51354
51368
  applyPlanToPreview(plan, planStateView);
51355
51369
  }
51356
51370
  logger.info("");
@@ -51370,7 +51384,9 @@ async function rollbackCommand(stackArg, options) {
51370
51384
  providerRegistry,
51371
51385
  region,
51372
51386
  logger: logger.child("rollback"),
51373
- recordEvent: (e) => eventRecorder.record(e)
51387
+ recordEvent: (e) => eventRecorder.record(e),
51388
+ finalSnapshotClients,
51389
+ skipFinalSnapshot: options.skipFinalSnapshot === true
51374
51390
  };
51375
51391
  let currentEtag = stateData.etag;
51376
51392
  const saveState = async () => {
@@ -51475,6 +51491,10 @@ async function rollbackCommand(stackArg, options) {
51475
51491
  });
51476
51492
  }
51477
51493
  } finally {
51494
+ if (stackAwsClients) {
51495
+ setAwsClients(setup.awsClients);
51496
+ stackAwsClients.destroy();
51497
+ }
51478
51498
  setup.dispose();
51479
51499
  }
51480
51500
  }
@@ -51488,6 +51508,7 @@ function applyPlanToPreview(plan, previewState) {
51488
51508
  const { op, action } = item;
51489
51509
  switch (action) {
51490
51510
  case "delete":
51511
+ case "delete-with-final-snapshot":
51491
51512
  case "orphan-retain":
51492
51513
  case "orphan-flag":
51493
51514
  if (op.changeType === "CREATE") delete previewState[op.logicalId];
@@ -51520,7 +51541,7 @@ function applyFailedPlanToPreview(plan, previewState) {
51520
51541
  }
51521
51542
  }
51522
51543
  function createRollbackCommand() {
51523
- const cmd = new Command("rollback").description("Revert a stack to its pre-deploy state after a failed --no-rollback / interrupted deploy or a partially-failed automatic rollback (state-driven, no synth needed).").argument("[stack]", "Stack name to roll back (defaults to the single journaled stack)").addOption(new Option("--force", "Skip the confirmation prompt").default(false)).addOption(new Option("--orphan <logicalId>", "Skip the given resource during replay (repeatable). Mirrors cdk rollback --orphan.").argParser((value, previous) => [...previous ?? [], value])).addOption(new Option("--revert-failed", "Also attempt to revert the resource whose operation FAILED mid-deploy. Off by default: the remote state of the failed resource is unknown, so force-applying its previous state is opt-in.").default(false)).addOption(stackRegionOption()).addHelpText("after", [
51544
+ const cmd = new Command("rollback").description("Revert a stack to its pre-deploy state after a failed --no-rollback / interrupted deploy or a partially-failed automatic rollback (state-driven, no synth needed).").argument("[stack]", "Stack name to roll back (defaults to the single journaled stack)").addOption(new Option("--force", "Skip the confirmation prompt").default(false)).addOption(new Option("--orphan <logicalId>", "Skip the given resource during replay (repeatable). Mirrors cdk rollback --orphan.").argParser((value, previous) => [...previous ?? [], value])).addOption(new Option("--revert-failed", "Also attempt to revert the resource whose operation FAILED mid-deploy. Off by default: the remote state of the failed resource is unknown, so force-applying its previous state is opt-in.").default(false)).addOption(skipFinalSnapshotOption).addOption(stackRegionOption()).addHelpText("after", [
51524
51545
  "",
51525
51546
  "Examples:",
51526
51547
  " cdkd rollback MyStack",
@@ -51528,6 +51549,7 @@ function createRollbackCommand() {
51528
51549
  " cdkd rollback MyStack --force",
51529
51550
  " cdkd rollback MyStack --orphan MyBucket --orphan MyTable",
51530
51551
  " cdkd rollback MyStack --revert-failed # also revert the failed in-flight resource",
51552
+ " cdkd rollback MyStack --skip-final-snapshot # DeletionPolicy Snapshot → delete without the snapshot",
51531
51553
  " cdkd rollback MyStack --stack-region us-west-2",
51532
51554
  "",
51533
51555
  "Exit codes: 0 = clean, 2 = partial (journal kept for re-run), 1 = hard error."
@@ -63707,7 +63729,7 @@ function createMigrateCommand() {
63707
63729
  */
63708
63730
  function buildProgram() {
63709
63731
  const program = new Command();
63710
- program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.276.0");
63732
+ program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.276.2");
63711
63733
  program.hook("preAction", (_thisCommand, actionCommand) => {
63712
63734
  const { profile } = actionCommand.optsWithGlobals();
63713
63735
  if (profile !== void 0) process.env["AWS_PROFILE"] = profile;