@go-to-k/cdkd 0.284.18 → 0.284.19

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.
@@ -5450,6 +5450,68 @@ function getBootstrapMarkerKey(region) {
5450
5450
  return `${BOOTSTRAP_MARKER_PREFIX}${region}.json`;
5451
5451
  }
5452
5452
  /**
5453
+ * Read a region's bootstrap marker, probing the CANONICAL key first and the
5454
+ * region's RAW spelling second (issues #1836 / #1995 / #2021).
5455
+ *
5456
+ * Why two probes: the READ side folds region case (SDK endpoint resolution is
5457
+ * case-sensitive, and folding also keeps one region from occupying two cache
5458
+ * slots), but the WRITE side does not — `cdkd bootstrap` derives its region as
5459
+ * `options.region || AWS_REGION || 'us-east-1'` verbatim and uses that spelling
5460
+ * for {@link getBootstrapMarkerKey}. Aligning the write side is issue #1820's
5461
+ * lane; until then this read is independent of it.
5462
+ *
5463
+ * HOW REACHABLE the raw key actually is (measured for #2021, because this PR
5464
+ * turns the probe into a SHARED contract for four callers and the earlier
5465
+ * per-caller comments overstated it). A plain `AWS_REGION=US-EAST-1 cdkd
5466
+ * bootstrap` CANNOT write `cdkd-bootstrap/US-EAST-1.json`: the marker is
5467
+ * written LAST, and both resources have to be created first with names derived
5468
+ * from that same raw region — `getCdkdAssetBucketName` yields
5469
+ * `cdkd-assets-<acct>-US-EAST-1`, which S3 rejects as a bucket name, and
5470
+ * `region !== 'us-east-1'` is true for `US-EAST-1` so `CreateBucket` is also
5471
+ * handed `LocationConstraint: 'US-EAST-1'`, an invalid enum value. The
5472
+ * conventional name is never run through `validateAssetBucketName` (that guards
5473
+ * only `--asset-bucket`), so it fails at S3 rather than earlier. The raw key is
5474
+ * therefore reachable only when ALL of these hold:
5475
+ *
5476
+ * 1. both `--asset-bucket` and `--container-repo` are given as valid lowercase
5477
+ * names, so neither conventional name is derived from the raw region; AND
5478
+ * 2. the asset bucket ALREADY EXISTS and is owned by this account, so the
5479
+ * `CreateBucket` carrying the bad `LocationConstraint` is never issued;
5480
+ *
5481
+ * plus, outside that flow, a marker written by hand or by a cdkd predating
5482
+ * those guards. Probe 2 is kept rather than dropped because that state is real
5483
+ * and losing it silently re-points a bootstrapped region at `cdk gc`-collectable
5484
+ * storage — the exact #2021 failure — while the cost is one extra `GetObject`
5485
+ * on a non-canonical region only. It is skipped entirely when the region was
5486
+ * already canonical, so the common path still costs exactly one `GetObject`.
5487
+ * Both conditions are pinned by tests, so this claim cannot rot silently.
5488
+ *
5489
+ * This helper deliberately does NOT catch: each caller keeps its own policy on
5490
+ * top (`cdkd gc` / `cdkd bootstrap --destroy` translate `NoSuchBucket` into a
5491
+ * "never bootstrapped" message and hard-error on anything else;
5492
+ * `loadBootstrapContainerRepo` is best-effort and warns-and-falls-back).
5493
+ */
5494
+ async function readBootstrapMarkerBody(stateBackend, rawRegion, opts = {}) {
5495
+ const canonicalKey = getBootstrapMarkerKey(canonicalizeRegion(rawRegion));
5496
+ const rawKey = getBootstrapMarkerKey(rawRegion);
5497
+ const body = await stateBackend.getRawObject(canonicalKey);
5498
+ if (body !== null || rawKey === canonicalKey) return {
5499
+ body,
5500
+ resolvedKey: canonicalKey
5501
+ };
5502
+ const rawBody = await stateBackend.getRawObject(rawKey);
5503
+ if (rawBody === null) return {
5504
+ body: null,
5505
+ resolvedKey: canonicalKey
5506
+ };
5507
+ const subject = opts.logPrefix ? `${opts.logPrefix}: bootstrap marker` : "Bootstrap marker";
5508
+ getLogger().debug(`${subject} found at the un-folded key '${rawKey}' (none at '${canonicalKey}') — an upper-cased region was used at 'cdkd bootstrap' time.`);
5509
+ return {
5510
+ body: rawBody,
5511
+ resolvedKey: rawKey
5512
+ };
5513
+ }
5514
+ /**
5453
5515
  * Pragmatic S3 bucket-name check for `cdkd bootstrap --asset-bucket`
5454
5516
  * (issue #1011): 3-63 chars, lowercase letters / digits / dots / hyphens,
5455
5517
  * starting and ending with a letter or digit. Rejecting before any AWS call
@@ -5705,6 +5767,15 @@ async function ensureAssetStorage(options) {
5705
5767
  var AssetModeResolver = class {
5706
5768
  logger = getLogger().child("AssetMode");
5707
5769
  cache = /* @__PURE__ */ new Map();
5770
+ /**
5771
+ * NOT load-bearing today — defense-in-depth only. `resolve` sets `cache`
5772
+ * synchronously before the first await, so `doResolve` runs at most once per
5773
+ * canonical region, and the notice arm always returns successfully so the
5774
+ * failure-eviction path cannot re-enter it. This Set was already ineffective
5775
+ * BEFORE the issue #2021 fold (two spellings simply made two entries), so it
5776
+ * is not a regression that fold introduced. Kept so removing or bypassing the
5777
+ * cache cannot silently turn the notice into one line per resolve.
5778
+ */
5708
5779
  legacyNoticeShownRegions = /* @__PURE__ */ new Set();
5709
5780
  stateBackend;
5710
5781
  accountId;
@@ -5723,24 +5794,37 @@ var AssetModeResolver = class {
5723
5794
  /**
5724
5795
  * Resolve the asset mode for a deploy region. Concurrent callers for the
5725
5796
  * same region share one in-flight resolution.
5797
+ *
5798
+ * The region arrives UNFOLDED (issue #2021): both deploy-time callers derive
5799
+ * it as `options.region || AWS_REGION || 'us-east-1'` and then
5800
+ * `stack.region || baseRegion`, so an env-agnostic stack under
5801
+ * `--region US-EAST-1` (or `AWS_REGION=US-EAST-1`) hands an upper-cased
5802
+ * spelling straight through. A stack whose `env.region` is pinned in CDK is
5803
+ * unaffected — `stack.region` comes from the Cloud Assembly and is canonical.
5804
+ *
5805
+ * Folding at THIS boundary rather than at each caller fixes two things at
5806
+ * once: the marker read below (which used to miss `cdkd-bootstrap/
5807
+ * us-east-1.json` and silently downgrade the whole region to LEGACY —
5808
+ * `cdk gc`-collectable — storage), and the CACHE, where `us-east-1` and
5809
+ * `US-EAST-1` occupied two slots and each re-probed S3.
5726
5810
  */
5727
- resolve(region) {
5811
+ resolve(rawRegion) {
5728
5812
  if (this.useCdkBootstrapAssets) return Promise.resolve({ mode: "legacy" });
5813
+ const region = canonicalizeRegion(rawRegion);
5729
5814
  const cached = this.cache.get(region);
5730
5815
  if (cached) return cached;
5731
- const inFlight = this.doResolve(region).catch((error) => {
5816
+ const inFlight = this.doResolve(region, rawRegion).catch((error) => {
5732
5817
  this.cache.delete(region);
5733
5818
  throw error;
5734
5819
  });
5735
5820
  this.cache.set(region, inFlight);
5736
5821
  return inFlight;
5737
5822
  }
5738
- async doResolve(region) {
5739
- const markerKey = getBootstrapMarkerKey(region);
5740
- const body = await this.stateBackend.getRawObject(markerKey);
5823
+ async doResolve(region, rawRegion) {
5824
+ const { body, resolvedKey } = await readBootstrapMarkerBody(this.stateBackend, rawRegion);
5741
5825
  if (body === null) {
5742
5826
  if (this.autoCreate) {
5743
- const created = await this.tryAutoCreate(region, markerKey);
5827
+ const created = await this.tryAutoCreate(region, getBootstrapMarkerKey(region));
5744
5828
  if (created) return created;
5745
5829
  }
5746
5830
  if (!this.legacyNoticeShownRegions.has(region) && !this.suppressLegacyNotice) {
@@ -5749,7 +5833,7 @@ var AssetModeResolver = class {
5749
5833
  }
5750
5834
  return { mode: "legacy" };
5751
5835
  }
5752
- const marker = parseBootstrapMarker(body, markerKey);
5836
+ const marker = parseBootstrapMarker(body, resolvedKey);
5753
5837
  await verifyAssetStorageExists(marker, this.accountId, region, { ...this.profile && { profile: this.profile } });
5754
5838
  this.logger.debug(`cdkd asset storage active for region '${region}': ${marker.assetBucket} / ${marker.containerRepo}`);
5755
5839
  return {
@@ -16514,7 +16598,7 @@ var CloudControlProvider = class {
16514
16598
  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);
16515
16599
  if (context?.removeProtection === true && resourceType === "AWS::AutoScaling::AutoScalingGroup") {
16516
16600
  this.logger.debug(`Delegating protected AutoScalingGroup ${logicalId} delete to the SDK ASGProvider (Cloud Control cannot force-delete a protected ASG)`);
16517
- const { ASGProvider } = await import("./asg-provider-IPF2MfAC.js").then((n) => n.n);
16601
+ const { ASGProvider } = await import("./asg-provider-CuSoYdf6.js").then((n) => n.n);
16518
16602
  return await new ASGProvider().delete(logicalId, physicalId, resourceType, _properties, context);
16519
16603
  }
16520
16604
  const isProtectedEc2Instance = context?.removeProtection === true && resourceType === "AWS::EC2::Instance";
@@ -24687,7 +24771,7 @@ const FLUSH_INTERVAL_MS = 2e3;
24687
24771
  const FLUSH_EVENT_THRESHOLD = 50;
24688
24772
  /** Build-time cdkd version, with a dev fallback for non-built contexts. */
24689
24773
  function getCdkdVersion() {
24690
- return "0.284.18";
24774
+ return "0.284.19";
24691
24775
  }
24692
24776
  /**
24693
24777
  * Generate a time-sortable unique run id, e.g.
@@ -27226,5 +27310,5 @@ var DeployEngine = class {
27226
27310
  };
27227
27311
 
27228
27312
  //#endregion
27229
- export { isTerminationProtectionPropagationError as $, ResourceUpdateNotSupportedError as $n, validateAssetBucketName as $t, renderStatefulReason as A, derivePartitionAndUrlSuffix as An, INTRINSIC_KEYS as At, exportAliasCollisionScrubWarning as B, CdkdError as Bn, stringifyValue as Bt, isFinalSnapshotError as C, CFN_TEMPLATE_URL_LIMIT as Cn, s3BucketArn as Ct, extractDeploymentEventError as D, expectedOwnerParam as Dn, s3BucketWebsiteUrl as Dt, makeCanonicalizePropertiesFn as E, uploadCfnTemplate as En, s3BucketRegionalDomainName as Et, green as F, AwsClients as Fn, LockManager as Ft, collectInlinePolicyNamesManagedBySiblings as G, LocalMigrateError as Gn, rewriteTemplateAssetReferences as Gt, secretBearingStateKeyWarning as H, DependencyError as Hn, buildAssetRedirectMap as Ht, red as I, getAwsClients as In, S3StateBackend as It, findActionableSilentDrops as J, MissingCdkCliError as Jn, AssetModeResolver as Jt, clearOnUpdateRemoval as K, LocalStartServiceError as Kn, escapeRegExp$1 as Kt, yellow as L, resetAwsClients as Ln, rebuildClientForBucketRegion as Lt, bold as M, processStackMessages as Mn, withRetry as Mt, cyan as N, clearBucketRegionCache as Nn, DagBuilder as Nt, MULTI_REGION_RECREATE_BLOCKED_TYPES as O, PARTITION_TABLE as On, applyRoleArnIfSet as Ot, gray as P, resolveBucketRegion as Pn, TemplateParser as Pt, disableInstanceApiTermination as Q, ResourceTimeoutError as Qn, parseBootstrapMarker as Qt, collectDeclaredOutputNames as R, setAwsClients as Rn, shouldRetainResource as Rt, createPreDeleteFinalSnapshot as S, CFN_TEMPLATE_BODY_LIMIT as Sn, scrubResourceRecord as St, unsupportedFinalSnapshotError as T, findLargeInlineResources as Tn, s3BucketDualStackDomainName as Tt, stateKeySecretExposure as U, DeployCancelledError as Un, createAssetRedirectResolver as Ut, isExportAliasCollision as V, ConfigError as Vn, WorkGraph as Vt, IAMRoleProvider as W, LocalInvokeBuildError as Wn, loadPublishableAssetManifest as Wt, CloudControlProvider as X, PartialFailureError as Xn, ensureAssetStorage as Xt, findSilentDropProperties as Y, NestedStackChildDirectDestroyError as Yn, BOOTSTRAP_MARKER_PREFIX as Yt, slowCcOperationTimeoutMs as Z, ProvisioningError as Zn, getBootstrapMarkerKey as Zt, computeImplicitDeleteEdges as _, resolveStateBucketWithDefault as _n, STATE_SOURCED_READBACK_RULES as _t, DeploymentEventsStore as a, runDockerForeground as an, isCdkdError as ar, normalizeAwsTagsToCfn as at, buildFinalSnapshotIdentifier as b, stateBucketExistenceConfirmed as bn, maskSecretsInText as bt, replayFailedOperations as c, getDockerImageBySourceHash as cn, isMarkedNonRetryable as cr, coerceCfnBoolean as ct, updatePartialReason as d, getDefaultStateBucketName as dn, markNonRetryable as dr, readConfigString as dt, validateContainerRepoName as en, StackHasActiveImportsError as er, IntrinsicFunctionResolver as et, UNSPECIFIED_SKIP_REASON as f, getLegacyStateBucketName as fn, __exportAll as fr, replayWarn as ft, IMPLICIT_DELETE_DEPENDENCIES as g, resolveSkipPrefix as gn, STATE_SOURCED_CROSS_GENERATION_RULES as gt, maskingRetryLogger as h, resolveCaptureObservedState as hn, requireConfigString as ht, DeploymentEventsReader as i, getDockerCmd as in, formatError as ir, WAFv2WebACLProvider as it, formatResourceLine as j, AssemblyReader as jn, describeTypeWithThrottleRetry as jt, isStatefulRecreateTargetSync as k, canonicalizeRegion as kn, DiffCalculator as kt, replayRollback as l, Synthesizer as ln, isRetryableTransientError as lr, configBooleanRefusal as lt, withResourceDeadline as m, resolveAutoAssetStorage as mn, requireConfigObject as mt, DEFAULT_RESOURCE_WARN_AFTER_MS as n, buildDockerImage as nn, StateError as nr, getAccountInfo as nt, planFailedOps as o, runDockerStreaming as on, normalizeAwsError as or, resolveExplicitPhysicalId as ot, deleteSkipReason as p, resolveApp as pn, requireConfigArray as pt, ProviderRegistry as q, LockError as qn, stripControlChars as qt, DeployEngine as r, formatDockerLoginError as rn, SynthesisError as rr, refStateLookupFromResource as rt, planRollback as s, AssetManifestLoader as sn, withErrorHandling as sr, assertRegionMatch as st, DEFAULT_RESOURCE_TIMEOUT_MS as t, buildDenyExternalAccessPolicy as tn, StackTerminationProtectionError as tr, cfnRefValueFromPhysicalId as tt, updatePartialMessage as u, synthesisStatusMessage as un, isThrottlingError as ur, configStringRefusal as ut, ATOMIC_FINAL_SNAPSHOT_TYPES as v, resolveStateBucketWithDefaultAndSource as vn, TEMPLATE_SOURCED_RULES as vt, refusesFinalSnapshot as w, MIGRATE_TMP_PREFIX as wn, s3BucketDomainName as wt, ccRoutedFinalSnapshotError as x, warnDeprecatedNoPrefixCliFlag as xn, redactSecretsForState as xt, PRE_DELETE_SNAPSHOT_TYPES as y, resolveUseCdkBootstrapAssets as yn, createSecretMasker as yt, collectPublishedOutputNames as z, AssetError as zn, AssetPublisher as zt };
27230
- //# sourceMappingURL=deploy-engine-HK-oROJf.js.map
27313
+ export { isTerminationProtectionPropagationError as $, ResourceTimeoutError as $n, readBootstrapMarkerBody as $t, renderStatefulReason as A, canonicalizeRegion as An, INTRINSIC_KEYS as At, exportAliasCollisionScrubWarning as B, AssetError as Bn, stringifyValue as Bt, isFinalSnapshotError as C, CFN_TEMPLATE_BODY_LIMIT as Cn, s3BucketArn as Ct, extractDeploymentEventError as D, uploadCfnTemplate as Dn, s3BucketWebsiteUrl as Dt, makeCanonicalizePropertiesFn as E, findLargeInlineResources as En, s3BucketRegionalDomainName as Et, green as F, resolveBucketRegion as Fn, LockManager as Ft, collectInlinePolicyNamesManagedBySiblings as G, LocalInvokeBuildError as Gn, rewriteTemplateAssetReferences as Gt, secretBearingStateKeyWarning as H, ConfigError as Hn, buildAssetRedirectMap as Ht, red as I, AwsClients as In, S3StateBackend as It, findActionableSilentDrops as J, LockError as Jn, AssetModeResolver as Jt, clearOnUpdateRemoval as K, LocalMigrateError as Kn, escapeRegExp$1 as Kt, yellow as L, getAwsClients as Ln, rebuildClientForBucketRegion as Lt, bold as M, AssemblyReader as Mn, withRetry as Mt, cyan as N, processStackMessages as Nn, DagBuilder as Nt, MULTI_REGION_RECREATE_BLOCKED_TYPES as O, expectedOwnerParam as On, applyRoleArnIfSet as Ot, gray as P, clearBucketRegionCache as Pn, TemplateParser as Pt, disableInstanceApiTermination as Q, ProvisioningError as Qn, parseBootstrapMarker as Qt, collectDeclaredOutputNames as R, resetAwsClients as Rn, shouldRetainResource as Rt, createPreDeleteFinalSnapshot as S, warnDeprecatedNoPrefixCliFlag as Sn, scrubResourceRecord as St, unsupportedFinalSnapshotError as T, MIGRATE_TMP_PREFIX as Tn, s3BucketDualStackDomainName as Tt, stateKeySecretExposure as U, DependencyError as Un, createAssetRedirectResolver as Ut, isExportAliasCollision as V, CdkdError as Vn, WorkGraph as Vt, IAMRoleProvider as W, DeployCancelledError as Wn, loadPublishableAssetManifest as Wt, CloudControlProvider as X, NestedStackChildDirectDestroyError as Xn, ensureAssetStorage as Xt, findSilentDropProperties as Y, MissingCdkCliError as Yn, BOOTSTRAP_MARKER_PREFIX as Yt, slowCcOperationTimeoutMs as Z, PartialFailureError as Zn, getBootstrapMarkerKey as Zt, computeImplicitDeleteEdges as _, resolveSkipPrefix as _n, STATE_SOURCED_READBACK_RULES as _t, DeploymentEventsStore as a, getDockerCmd as an, formatError as ar, normalizeAwsTagsToCfn as at, buildFinalSnapshotIdentifier as b, resolveUseCdkBootstrapAssets as bn, maskSecretsInText as bt, replayFailedOperations as c, AssetManifestLoader as cn, withErrorHandling as cr, coerceCfnBoolean as ct, updatePartialReason as d, synthesisStatusMessage as dn, isThrottlingError as dr, readConfigString as dt, validateAssetBucketName as en, ResourceUpdateNotSupportedError as er, IntrinsicFunctionResolver as et, UNSPECIFIED_SKIP_REASON as f, getDefaultStateBucketName as fn, markNonRetryable as fr, replayWarn as ft, IMPLICIT_DELETE_DEPENDENCIES as g, resolveCaptureObservedState as gn, STATE_SOURCED_CROSS_GENERATION_RULES as gt, maskingRetryLogger as h, resolveAutoAssetStorage as hn, requireConfigString as ht, DeploymentEventsReader as i, formatDockerLoginError as in, SynthesisError as ir, WAFv2WebACLProvider as it, formatResourceLine as j, derivePartitionAndUrlSuffix as jn, describeTypeWithThrottleRetry as jt, isStatefulRecreateTargetSync as k, PARTITION_TABLE as kn, DiffCalculator as kt, replayRollback as l, getDockerImageBySourceHash as ln, isMarkedNonRetryable as lr, configBooleanRefusal as lt, withResourceDeadline as m, resolveApp as mn, requireConfigObject as mt, DEFAULT_RESOURCE_WARN_AFTER_MS as n, buildDenyExternalAccessPolicy as nn, StackTerminationProtectionError as nr, getAccountInfo as nt, planFailedOps as o, runDockerForeground as on, isCdkdError as or, resolveExplicitPhysicalId as ot, deleteSkipReason as p, getLegacyStateBucketName as pn, __exportAll as pr, requireConfigArray as pt, ProviderRegistry as q, LocalStartServiceError as qn, stripControlChars as qt, DeployEngine as r, buildDockerImage as rn, StateError as rr, refStateLookupFromResource as rt, planRollback as s, runDockerStreaming as sn, normalizeAwsError as sr, assertRegionMatch as st, DEFAULT_RESOURCE_TIMEOUT_MS as t, validateContainerRepoName as tn, StackHasActiveImportsError as tr, cfnRefValueFromPhysicalId as tt, updatePartialMessage as u, Synthesizer as un, isRetryableTransientError as ur, configStringRefusal as ut, ATOMIC_FINAL_SNAPSHOT_TYPES as v, resolveStateBucketWithDefault as vn, TEMPLATE_SOURCED_RULES as vt, refusesFinalSnapshot as w, CFN_TEMPLATE_URL_LIMIT as wn, s3BucketDomainName as wt, ccRoutedFinalSnapshotError as x, stateBucketExistenceConfirmed as xn, redactSecretsForState as xt, PRE_DELETE_SNAPSHOT_TYPES as y, resolveStateBucketWithDefaultAndSource as yn, createSecretMasker as yt, collectPublishedOutputNames as z, setAwsClients as zn, AssetPublisher as zt };
27314
+ //# sourceMappingURL=deploy-engine-Bh_LPdju.js.map