@go-to-k/cdkd 0.263.0 → 0.263.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.
@@ -11240,7 +11240,7 @@ var CloudControlProvider = class {
11240
11240
  this.logger.debug(`Deleting resource ${logicalId} (${resourceType}), physical ID: ${physicalId}`);
11241
11241
  if (context?.removeProtection === true && resourceType === "AWS::AutoScaling::AutoScalingGroup") {
11242
11242
  this.logger.debug(`Delegating protected AutoScalingGroup ${logicalId} delete to the SDK ASGProvider (Cloud Control cannot force-delete a protected ASG)`);
11243
- const { ASGProvider } = await import("./asg-provider-DF1bV_pu.js").then((n) => n.n);
11243
+ const { ASGProvider } = await import("./asg-provider-CkNAViXd.js").then((n) => n.n);
11244
11244
  await new ASGProvider().delete(logicalId, physicalId, resourceType, _properties, context);
11245
11245
  return;
11246
11246
  }
@@ -11902,6 +11902,25 @@ var CustomResourceProvider = class CustomResourceProvider {
11902
11902
  responseBucket;
11903
11903
  responsePrefix;
11904
11904
  /**
11905
+ * Memoization for the lazy response-bucket region correction
11906
+ * (`ensureResponseClient`). Mirrors the `clientResolved` /
11907
+ * `resolveInFlight` pattern of the three other state-bucket S3
11908
+ * consumers (S3StateBackend / LockManager / ExportIndexStore), plus a
11909
+ * generation counter: `setResponseBucket` bumps it so a probe that was
11910
+ * still in flight when the bucket was re-set cannot commit its stale
11911
+ * client / resolved flag against the new bucket.
11912
+ */
11913
+ responseClientResolved = false;
11914
+ responseClientResolveInFlight = null;
11915
+ responseClientGeneration = 0;
11916
+ /**
11917
+ * Whether `this.s3Client` is a provider-OWNED client (built from the
11918
+ * `setResponseBucket` region hint or by a region-correction rebuild)
11919
+ * vs the shared `AwsClients.s3` instance from the constructor. Owned
11920
+ * clients are `destroy()`ed when replaced; the shared one never is.
11921
+ */
11922
+ ownsS3Client = false;
11923
+ /**
11905
11924
  * Opt out of the deploy engine's outer transient-error retry loop.
11906
11925
  *
11907
11926
  * The loop re-invokes `provider.create()` from the top on a transient
@@ -11981,7 +12000,67 @@ var CustomResourceProvider = class CustomResourceProvider {
11981
12000
  */
11982
12001
  setResponseBucket(bucket, bucketRegion) {
11983
12002
  this.responseBucket = bucket;
11984
- if (bucketRegion) this.s3Client = new S3Client(bucketRegion ? { region: bucketRegion } : {});
12003
+ if (bucketRegion) this.replaceS3Client(new S3Client({ region: bucketRegion }));
12004
+ this.responseClientGeneration++;
12005
+ this.responseClientResolved = false;
12006
+ this.responseClientResolveInFlight = null;
12007
+ }
12008
+ /**
12009
+ * Swap `this.s3Client`, destroying the previous client when the
12010
+ * provider owned it (never the shared `AwsClients.s3` instance).
12011
+ * The optional call tolerates test doubles without a `destroy`.
12012
+ */
12013
+ replaceS3Client(replacement) {
12014
+ if (this.ownsS3Client) this.s3Client.destroy?.();
12015
+ this.s3Client = replacement;
12016
+ this.ownsS3Client = true;
12017
+ }
12018
+ /**
12019
+ * Resolve the response bucket's actual region and, if it differs from the
12020
+ * current S3 client's configured region, swap in a region-corrected client
12021
+ * before any response-bucket S3 operation (placeholder `PutObject`,
12022
+ * pre-signed `ResponseURL` signing, response polling, cleanup).
12023
+ *
12024
+ * The response bucket is cdkd's state bucket, which can live in a
12025
+ * different region from the deploy region (`cdkd deploy --region` /
12026
+ * `AWS_REGION` against the account-scoped region-free default bucket).
12027
+ * A pre-signed URL's host is region-specific, so signing with the deploy
12028
+ * region against a foreign-region bucket makes S3 return a
12029
+ * 301 PermanentRedirect (issue #1195). Mirrors the lazy
12030
+ * `ensureClientForBucket()` correction the state backend (#60), the
12031
+ * LockManager (#803), and the ExportIndexStore (#819) already do via the
12032
+ * shared `rebuildClientForBucketRegion` helper (#827).
12033
+ *
12034
+ * `tolerateNonStandardClient` keeps test doubles (a bare `{ send }`
12035
+ * object from a mocked `getAwsClients`) on the no-rebuild path, and
12036
+ * `resolveBucketRegion` never throws (probe failures degrade to
12037
+ * "no rebuild"), so this can only improve the client's region.
12038
+ */
12039
+ async ensureResponseClient() {
12040
+ if (this.responseClientResolved || !this.responseBucket) return;
12041
+ if (this.responseClientResolveInFlight) return this.responseClientResolveInFlight;
12042
+ const bucket = this.responseBucket;
12043
+ const generation = this.responseClientGeneration;
12044
+ this.responseClientResolveInFlight = (async () => {
12045
+ try {
12046
+ const replacement = await rebuildClientForBucketRegion(this.s3Client, bucket, {
12047
+ reuseClientCredentials: true,
12048
+ tolerateNonStandardClient: true,
12049
+ onRebuild: ({ bucketRegion, currentRegion }) => {
12050
+ this.logger.debug(`Custom resource response bucket '${bucket}' is in '${bucketRegion}' (client was '${String(currentRegion)}'); building a region-corrected S3 client for response operations.`);
12051
+ }
12052
+ });
12053
+ if (generation !== this.responseClientGeneration) {
12054
+ replacement?.destroy?.();
12055
+ return;
12056
+ }
12057
+ if (replacement) this.replaceS3Client(replacement);
12058
+ this.responseClientResolved = true;
12059
+ } finally {
12060
+ if (generation === this.responseClientGeneration) this.responseClientResolveInFlight = null;
12061
+ }
12062
+ })();
12063
+ return this.responseClientResolveInFlight;
11985
12064
  }
11986
12065
  /**
11987
12066
  * Create a custom resource by invoking its Lambda handler
@@ -12354,6 +12433,7 @@ var CustomResourceProvider = class CustomResourceProvider {
12354
12433
  */
12355
12434
  async generateResponseURL(responseKey) {
12356
12435
  if (!this.responseBucket) return "https://localhost/cfn-response-not-configured";
12436
+ await this.ensureResponseClient();
12357
12437
  await this.s3Client.send(new PutObjectCommand({
12358
12438
  Bucket: this.responseBucket,
12359
12439
  Key: responseKey,
@@ -16559,6 +16639,14 @@ async function replaySingle(op, stateResources, stackName, ctx, orphanLogicalIds
16559
16639
  delete stateResources[op.logicalId];
16560
16640
  logger.info(` Rollback: Orphaning created resource ${op.logicalId} (--orphan)`);
16561
16641
  await afterOp?.(op.logicalId);
16642
+ ctx.recordEvent?.({
16643
+ eventType: "ROLLBACK_RESOURCE_SUCCEEDED",
16644
+ stackName,
16645
+ operation: "CREATE",
16646
+ logicalId: op.logicalId,
16647
+ resourceType: op.resourceType,
16648
+ ...op.provisionedBy && { provisionedBy: op.provisionedBy }
16649
+ });
16562
16650
  } else logger.info(` Rollback: Leaving ${op.logicalId} at its new state (--orphan)`);
16563
16651
  return;
16564
16652
  case "orphan-retain":
@@ -16738,7 +16826,7 @@ const FLUSH_INTERVAL_MS = 2e3;
16738
16826
  const FLUSH_EVENT_THRESHOLD = 50;
16739
16827
  /** Build-time cdkd version, with a dev fallback for non-built contexts. */
16740
16828
  function getCdkdVersion() {
16741
- return "0.263.0";
16829
+ return "0.263.2";
16742
16830
  }
16743
16831
  /**
16744
16832
  * Generate a time-sortable unique run id, e.g.
@@ -18646,4 +18734,4 @@ var DeployEngine = class {
18646
18734
 
18647
18735
  //#endregion
18648
18736
  export { rewriteTemplateAssetReferences as $, StackHasActiveImportsError as $t, disableInstanceApiTermination as A, uploadCfnTemplate as At, DiffCalculator as B, CdkdError as Bt, yellow as C, resolveStateBucketWithDefaultAndSource as Ct, findActionableSilentDrops as D, CFN_TEMPLATE_URL_LIMIT as Dt, ProviderRegistry as E, CFN_TEMPLATE_BODY_LIMIT as Et, WAFv2WebACLProvider as F, AwsClients as Ft, rebuildClientForBucketRegion as G, LocalStartServiceError as Gt, TemplateParser as H, DependencyError as Ht, normalizeAwsTagsToCfn as I, getAwsClients as It, stringifyValue as J, NestedStackChildDirectDestroyError as Jt, shouldRetainResource as K, LockError as Kt, resolveExplicitPhysicalId as L, resetAwsClients as Lt, IntrinsicFunctionResolver as M, AssemblyReader as Mt, cfnRefValueFromPhysicalId as N, clearBucketRegionCache as Nt, CloudControlProvider as O, MIGRATE_TMP_PREFIX as Ot, refStateLookupFromResource as P, resolveBucketRegion as Pt, loadPublishableAssetManifest as Q, ResourceUpdateNotSupportedError as Qt, assertRegionMatch as R, setAwsClients as Rt, red as S, resolveStateBucketWithDefault as St, collectInlinePolicyNamesManagedBySiblings as T, warnDeprecatedNoPrefixCliFlag as Tt, LockManager as U, LocalInvokeBuildError as Ut, DagBuilder as V, ConfigError as Vt, S3StateBackend as W, LocalMigrateError as Wt, buildAssetRedirectMap as X, ProvisioningError as Xt, WorkGraph as Y, PartialFailureError as Yt, createAssetRedirectResolver as Z, ResourceTimeoutError as Zt, formatResourceLine as _, getLegacyStateBucketName as _t, DeploymentEventsStore as a, normalizeAwsError as an, validateAssetBucketName as at, gray as b, resolveCaptureObservedState as bt, withResourceDeadline as c, formatDockerLoginError as ct, IMPLICIT_DELETE_DEPENDENCIES as d, runDockerStreaming as dt, StackTerminationProtectionError as en, AssetModeResolver as et, computeImplicitDeleteEdges as f, AssetManifestLoader as ft, renderStatefulReason as g, getDefaultStateBucketName as gt, isStatefulRecreateTargetSync as h, synthesisStatusMessage as ht, DeploymentEventsReader as i, isCdkdError as in, parseBootstrapMarker as it, isTerminationProtectionPropagationError as j, expectedOwnerParam as jt, slowCcOperationTimeoutMs as k, findLargeInlineResources as kt, withRetry as l, getDockerCmd as lt, MULTI_REGION_RECREATE_BLOCKED_TYPES as m, Synthesizer as mt, DEFAULT_RESOURCE_WARN_AFTER_MS as n, SynthesisError as nn, ensureAssetStorage as nt, planRollback as o, withErrorHandling as on, validateContainerRepoName as ot, extractDeploymentEventError as p, getDockerImageBySourceHash as pt, AssetPublisher as q, MissingCdkCliError as qt, DeployEngine as r, formatError as rn, getBootstrapMarkerKey as rt, replayRollback as s, __exportAll as sn, buildDockerImage as st, DEFAULT_RESOURCE_TIMEOUT_MS as t, StateError as tn, BOOTSTRAP_MARKER_PREFIX as tt, isRetryableTransientError as u, runDockerForeground as ut, bold as v, resolveApp as vt, IAMRoleProvider as w, resolveUseCdkBootstrapAssets as wt, green as x, resolveSkipPrefix as xt, cyan as y, resolveAutoAssetStorage as yt, applyRoleArnIfSet as z, AssetError as zt };
18649
- //# sourceMappingURL=deploy-engine-BbNhlr7X.js.map
18737
+ //# sourceMappingURL=deploy-engine-j-e2Q0XH.js.map