@go-to-k/cdkd 0.276.1 → 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.
@@ -12090,7 +12090,7 @@ var CloudControlProvider = class {
12090
12090
  if (context?.finalSnapshotIdentifier !== void 0) throw new ProvisioningError(`${logicalId} (${resourceType}) requires a final snapshot (DeletionPolicy: Snapshot), but the Cloud Control API delete route has no final-snapshot parameter. Re-run with --skip-final-snapshot after snapshotting manually, or retain the resource.`, resourceType, logicalId, physicalId);
12091
12091
  if (context?.removeProtection === true && resourceType === "AWS::AutoScaling::AutoScalingGroup") {
12092
12092
  this.logger.debug(`Delegating protected AutoScalingGroup ${logicalId} delete to the SDK ASGProvider (Cloud Control cannot force-delete a protected ASG)`);
12093
- const { ASGProvider } = await import("./asg-provider-Cfex3rAs.js").then((n) => n.n);
12093
+ const { ASGProvider } = await import("./asg-provider-X-k9FXgs.js").then((n) => n.n);
12094
12094
  await new ASGProvider().delete(logicalId, physicalId, resourceType, _properties, context);
12095
12095
  return;
12096
12096
  }
@@ -17752,24 +17752,73 @@ async function withResourceDeadline(operation, opts) {
17752
17752
 
17753
17753
  //#endregion
17754
17754
  //#region src/deployment/rollback-executor.ts
17755
+ /** The `--skip-final-snapshot` flag name cited by every refusal below. */
17756
+ const SKIP_FINAL_SNAPSHOT_FLAG = "--skip-final-snapshot";
17757
+ /**
17758
+ * Which provisioning layer a delete must be judged against: the CURRENT
17759
+ * state record wins (it is what state says AWS holds right now), with the
17760
+ * journaled op's routing as the legacy-state fallback. Shared by both
17761
+ * Snapshot paths below so the cc-api test cannot drift between them.
17762
+ */
17763
+ function effectiveProvisionedBy(record, fallbackProvisionedBy) {
17764
+ return record?.provisionedBy ?? fallbackProvisionedBy;
17765
+ }
17755
17766
  /**
17756
17767
  * `UpdateReplacePolicy: Snapshot` on a rollback's delete-of-the-NEW-resource
17757
17768
  * (issue #1354): honor it where it costs nothing — an atomic-final-snapshot
17758
17769
  * type on the SDK route gets a generated identifier threaded into the delete
17759
17770
  * context. Every other Snapshot shape (pre-delete types, cc-api routing)
17760
17771
  * keeps the plain delete DELIBERATELY: the rollback executor's delete-new is
17761
- * load-bearing for same-name re-creation (orphaning would break the revert),
17762
- * it has no snapshot-client plumbing by design (registry + region only), and
17763
- * the new resource was created by the deploy being reverted. Recorded as a
17764
- * scope decision on issue #1354.
17772
+ * load-bearing for same-name re-creation (refusing it would strand the
17773
+ * revert half-done), and the new resource was created by the very deploy
17774
+ * being reverted. Recorded as a scope decision on issue #1354.
17775
+ *
17776
+ * NOT the same call as the rolled-back-CREATE path
17777
+ * ({@link prepareCreateRollbackFinalSnapshot}, issue #1358): there the
17778
+ * resource is being deleted under `DeletionPolicy` and a shape cdkd cannot
17779
+ * snapshot is REFUSED rather than plain-deleted, because the user is losing
17780
+ * a resource that existed before this op — nothing downstream depends on
17781
+ * that delete succeeding.
17765
17782
  */
17766
17783
  function rollbackFinalSnapshotId(resourceType, record, fallbackProvisionedBy) {
17767
17784
  if (record.updateReplacePolicy !== "Snapshot") return void 0;
17768
17785
  if (!ATOMIC_FINAL_SNAPSHOT_TYPES.has(resourceType)) return void 0;
17769
- if ((record.provisionedBy ?? fallbackProvisionedBy) === "cc-api") return void 0;
17786
+ if (effectiveProvisionedBy(record, fallbackProvisionedBy) === "cc-api") return void 0;
17770
17787
  return buildFinalSnapshotIdentifier(record.physicalId, resourceType);
17771
17788
  }
17772
17789
  /**
17790
+ * `DeletionPolicy: Snapshot` on a rolled-back CREATE (issue #1358) — the
17791
+ * executor's copy of the deploy engine's `prepareFinalSnapshotForDelete`
17792
+ * mechanism matrix, run BEFORE the delete:
17793
+ *
17794
+ * - atomic type, SDK-routed → returns the generated identifier for the
17795
+ * provider's atomic final-snapshot delete parameter.
17796
+ * - atomic type, cc-api-routed → refuses (Cloud Control's DeleteResource
17797
+ * has no final-snapshot parameter; `CloudControlProvider.delete` also
17798
+ * fail-closes on the context field as defense-in-depth).
17799
+ * - `PRE_DELETE_SNAPSHOT_TYPES` → creates the snapshot and waits for it
17800
+ * here, then returns undefined (the subsequent delete is plain).
17801
+ * - anything else Snapshot-tagged → refuses.
17802
+ *
17803
+ * Refusals are plain throws so `replaySingle`'s per-op catch counts them as
17804
+ * a failure (which blocks the segment pop and keeps the journal for a
17805
+ * re-run) — deliberately NOT a silent fall-back to orphaning, which is the
17806
+ * very leak #1358 fixes.
17807
+ */
17808
+ async function prepareCreateRollbackFinalSnapshot(op, provisionedBy, ctx) {
17809
+ const { logicalId, resourceType } = op;
17810
+ const physicalId = op.physicalId;
17811
+ if (ATOMIC_FINAL_SNAPSHOT_TYPES.has(resourceType)) {
17812
+ if (provisionedBy === "cc-api") throw ccRoutedFinalSnapshotError(logicalId, resourceType, SKIP_FINAL_SNAPSHOT_FLAG);
17813
+ return buildFinalSnapshotIdentifier(physicalId, resourceType);
17814
+ }
17815
+ if (PRE_DELETE_SNAPSHOT_TYPES.has(resourceType)) {
17816
+ await createPreDeleteFinalSnapshot(resourceType, physicalId, logicalId, ctx.finalSnapshotClients ?? getAwsClients(), ctx.logger);
17817
+ return;
17818
+ }
17819
+ throw unsupportedFinalSnapshotError(logicalId, resourceType, SKIP_FINAL_SNAPSHOT_FLAG);
17820
+ }
17821
+ /**
17773
17822
  * Retry schedule for a re-create that must wait out a name-release delay:
17774
17823
  * an async delete's late name release ("already exists") or the SQS 60s
17775
17824
  * same-name cooldown (issue #1206). 2s/4s/8s then capped at 10s over 8
@@ -17822,7 +17871,8 @@ function classifyRollbackOp(op, stateResources, orphanLogicalIds) {
17822
17871
  if (!current) return "skip-already-done";
17823
17872
  if (op.physicalId !== void 0 && current.physicalId !== op.physicalId) return "skip-mismatch";
17824
17873
  const policy = current.deletionPolicy;
17825
- if (policy === "Retain" || policy === "Snapshot") return "orphan-retain";
17874
+ if (policy === "Retain") return "orphan-retain";
17875
+ if (policy === "Snapshot") return "delete-with-final-snapshot";
17826
17876
  return "delete";
17827
17877
  }
17828
17878
  const current = stateResources[op.logicalId];
@@ -17976,7 +18026,7 @@ async function replaySingle(op, stateResources, stackName, ctx, orphanLogicalIds
17976
18026
  return;
17977
18027
  case "orphan-retain":
17978
18028
  delete stateResources[op.logicalId];
17979
- logger.info(` Rollback: Leaving ${op.logicalId} (${op.resourceType}) in AWS (DeletionPolicy: ${stateResourcesPolicyLabel(op, stateResources)}) — removed from state`);
18029
+ logger.info(` Rollback: Leaving ${op.logicalId} (${op.resourceType}) in AWS (DeletionPolicy: Retain) — removed from state`);
17980
18030
  await afterOp?.(op.logicalId);
17981
18031
  ctx.recordEvent?.({
17982
18032
  eventType: "ROLLBACK_RESOURCE_SUCCEEDED",
@@ -17987,18 +18037,27 @@ async function replaySingle(op, stateResources, stackName, ctx, orphanLogicalIds
17987
18037
  ...op.provisionedBy && { provisionedBy: op.provisionedBy }
17988
18038
  });
17989
18039
  return;
17990
- case "delete": {
18040
+ case "delete":
18041
+ case "delete-with-final-snapshot": {
17991
18042
  if (!op.physicalId) {
17992
18043
  logger.warn(` Rollback: Cannot delete ${op.logicalId} — no physical ID recorded`);
17993
18044
  result.warnings++;
17994
18045
  return;
17995
18046
  }
17996
- logger.info(` Rollback: Deleting created resource ${op.logicalId} (${op.resourceType})`);
18047
+ const deleteProvisionedBy = effectiveProvisionedBy(stateResources[op.logicalId], op.provisionedBy);
18048
+ const snapshotPolicy = action === "delete-with-final-snapshot";
18049
+ const takeFinalSnapshot = snapshotPolicy && ctx.skipFinalSnapshot !== true;
18050
+ let finalSnapshotIdentifier;
18051
+ if (takeFinalSnapshot) finalSnapshotIdentifier = await prepareCreateRollbackFinalSnapshot(op, deleteProvisionedBy, ctx);
18052
+ logger.info(` Rollback: Deleting created resource ${op.logicalId} (${op.resourceType})` + (takeFinalSnapshot ? " — DeletionPolicy: Snapshot" : "") + (snapshotPolicy && !takeFinalSnapshot ? " — DeletionPolicy: Snapshot NOT taken (--skip-final-snapshot)" : ""));
17997
18053
  const { provider } = ctx.providerRegistry.getProviderFor({
17998
18054
  resourceType: op.resourceType,
17999
- provisionedBy: op.provisionedBy
18055
+ provisionedBy: deleteProvisionedBy
18056
+ });
18057
+ await provider.delete(op.logicalId, op.physicalId, op.resourceType, op.properties, {
18058
+ expectedRegion: ctx.region,
18059
+ ...finalSnapshotIdentifier !== void 0 && { finalSnapshotIdentifier }
18000
18060
  });
18001
- await provider.delete(op.logicalId, op.physicalId, op.resourceType, op.properties, { expectedRegion: ctx.region });
18002
18061
  delete stateResources[op.logicalId];
18003
18062
  logger.info(` Rollback: ${op.logicalId} deleted successfully`);
18004
18063
  await afterOp?.(op.logicalId);
@@ -18281,9 +18340,6 @@ async function replayFailedOperations(failedOps, stateResources, stackName, ctx,
18281
18340
  result.remainingFailedOps = failedOps.filter((op) => pending.has(op));
18282
18341
  return result;
18283
18342
  }
18284
- function stateResourcesPolicyLabel(op, stateResources) {
18285
- return stateResources[op.logicalId]?.deletionPolicy ?? "Retain";
18286
- }
18287
18343
  /**
18288
18344
  * Sort CREATE rollback operations so that resources depending on others are
18289
18345
  * deleted first (reverse dependency order), using state dependencies. Same
@@ -18373,7 +18429,7 @@ const FLUSH_INTERVAL_MS = 2e3;
18373
18429
  const FLUSH_EVENT_THRESHOLD = 50;
18374
18430
  /** Build-time cdkd version, with a dev fallback for non-built contexts. */
18375
18431
  function getCdkdVersion() {
18376
- return "0.276.1";
18432
+ return "0.276.2";
18377
18433
  }
18378
18434
  /**
18379
18435
  * Generate a time-sortable unique run id, e.g.
@@ -19765,7 +19821,9 @@ var DeployEngine = class {
19765
19821
  providerRegistry: this.providerRegistry,
19766
19822
  region: this.stackRegion,
19767
19823
  logger: this.logger,
19768
- recordEvent: (event) => this.recordEvent(event)
19824
+ recordEvent: (event) => this.recordEvent(event),
19825
+ finalSnapshotClients: this.options.finalSnapshotClients,
19826
+ skipFinalSnapshot: this.options.skipFinalSnapshot
19769
19827
  };
19770
19828
  }
19771
19829
  /**
@@ -20483,4 +20541,4 @@ var DeployEngine = class {
20483
20541
 
20484
20542
  //#endregion
20485
20543
  export { TemplateParser as $, CdkdError as $t, yellow as A, resolveAutoAssetStorage as At, IntrinsicFunctionResolver as B, MIGRATE_TMP_PREFIX as Bt, renderStatefulReason as C, AssetManifestLoader as Ct, gray as D, getDefaultStateBucketName as Dt, cyan as E, synthesisStatusMessage as Et, findActionableSilentDrops as F, resolveUseCdkBootstrapAssets as Ft, resolveExplicitPhysicalId as G, processStackMessages as Gt, refStateLookupFromResource as H, uploadCfnTemplate as Ht, CloudControlProvider as I, stateBucketExistenceConfirmed as It, DiffCalculator as J, AwsClients as Jt, assertRegionMatch as K, clearBucketRegionCache as Kt, slowCcOperationTimeoutMs as L, warnDeprecatedNoPrefixCliFlag as Lt, collectInlinePolicyNamesManagedBySiblings as M, resolveSkipPrefix as Mt, clearOnUpdateRemoval as N, resolveStateBucketWithDefault as Nt, green as O, getLegacyStateBucketName as Ot, ProviderRegistry as P, resolveStateBucketWithDefaultAndSource as Pt, DagBuilder as Q, AssetError as Qt, disableInstanceApiTermination as R, CFN_TEMPLATE_BODY_LIMIT as Rt, isStatefulRecreateTargetSync as S, runDockerStreaming as St, bold as T, Synthesizer as Tt, WAFv2WebACLProvider as U, expectedOwnerParam as Ut, cfnRefValueFromPhysicalId as V, findLargeInlineResources as Vt, normalizeAwsTagsToCfn as W, AssemblyReader as Wt, withRetry as X, resetAwsClients as Xt, describeTypeWithThrottleRetry as Y, getAwsClients as Yt, isRetryableTransientError as Z, setAwsClients as Zt, createPreDeleteFinalSnapshot as _, formatError as _n, validateContainerRepoName as _t, DeploymentEventsStore as a, LocalStartServiceError as an, stringifyValue as at, extractDeploymentEventError as b, withErrorHandling as bn, getDockerCmd as bt, replayFailedOperations as c, NestedStackChildDirectDestroyError as cn, createAssetRedirectResolver as ct, IMPLICIT_DELETE_DEPENDENCIES as d, ResourceTimeoutError as dn, AssetModeResolver as dt, ConfigError as en, LockManager as et, computeImplicitDeleteEdges as f, ResourceUpdateNotSupportedError as fn, BOOTSTRAP_MARKER_PREFIX as ft, ccRoutedFinalSnapshotError as g, SynthesisError as gn, validateAssetBucketName as gt, buildFinalSnapshotIdentifier as h, StateError as hn, parseBootstrapMarker as ht, DeploymentEventsReader as i, LocalMigrateError as in, AssetPublisher as it, IAMRoleProvider as j, resolveCaptureObservedState as jt, red as k, resolveApp as kt, replayRollback as l, PartialFailureError as ln, loadPublishableAssetManifest as lt, PRE_DELETE_SNAPSHOT_TYPES as m, StackTerminationProtectionError as mn, getBootstrapMarkerKey as mt, DEFAULT_RESOURCE_WARN_AFTER_MS as n, DeployCancelledError as nn, rebuildClientForBucketRegion as nt, planFailedOps as o, LockError as on, WorkGraph as ot, ATOMIC_FINAL_SNAPSHOT_TYPES as p, StackHasActiveImportsError as pn, ensureAssetStorage as pt, applyRoleArnIfSet as q, resolveBucketRegion as qt, DeployEngine as r, LocalInvokeBuildError as rn, shouldRetainResource as rt, planRollback as s, MissingCdkCliError as sn, buildAssetRedirectMap as st, DEFAULT_RESOURCE_TIMEOUT_MS as t, DependencyError as tn, S3StateBackend as tt, withResourceDeadline as u, ProvisioningError as un, rewriteTemplateAssetReferences as ut, isFinalSnapshotError as v, isCdkdError as vn, buildDockerImage as vt, formatResourceLine as w, getDockerImageBySourceHash as wt, MULTI_REGION_RECREATE_BLOCKED_TYPES as x, __exportAll as xn, runDockerForeground as xt, unsupportedFinalSnapshotError as y, normalizeAwsError as yn, formatDockerLoginError as yt, isTerminationProtectionPropagationError as z, CFN_TEMPLATE_URL_LIMIT as zt };
20486
- //# sourceMappingURL=deploy-engine-C581XZwt.js.map
20544
+ //# sourceMappingURL=deploy-engine-CwVBPKqE.js.map