@go-to-k/cdkd 0.278.53 → 0.278.55

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 DiffCalculator, $t as resolveBucketRegion, A as red, At as getDockerImageBySourceHash, B as isTerminationProtectionPropagationError, Bt as resolveStateBucketWithDefaultAndSource, C as isStatefulRecreateTargetSync, Ct as validateContainerRepoName, D as cyan, Dt as runDockerForeground, E as bold, En as withErrorHandling, Et as getDockerCmd, F as ProviderRegistry, Ft as resolveApp, G as normalizeAwsTagsToCfn, Gt as CFN_TEMPLATE_URL_LIMIT, H as cfnRefValueFromPhysicalId, Ht as stateBucketExistenceConfirmed, I as findActionableSilentDrops, It as resolveAutoAssetStorage, J as readConfigString, Jt as uploadCfnTemplate, K as resolveExplicitPhysicalId, Kt as MIGRATE_TMP_PREFIX, L as CloudControlProvider, Lt as resolveCaptureObservedState, M as IAMRoleProvider, Mt as synthesisStatusMessage, N as collectInlinePolicyNamesManagedBySiblings, Nt as getDefaultStateBucketName, O as gray, Ot as runDockerStreaming, P as clearOnUpdateRemoval, Pt as getLegacyStateBucketName, Q as applyRoleArnIfSet, R as slowCcOperationTimeoutMs, Rt as resolveSkipPrefix, S as MULTI_REGION_RECREATE_BLOCKED_TYPES, St as validateAssetBucketName, T as formatResourceLine, Tn as normalizeAwsError, Tt as formatDockerLoginError, U as refStateLookupFromResource, Ut as warnDeprecatedNoPrefixCliFlag, V as IntrinsicFunctionResolver, Vt as resolveUseCdkBootstrapAssets, W as WAFv2WebACLProvider, Wt as CFN_TEMPLATE_BODY_LIMIT, X as requireConfigArray, Xt as AssemblyReader, Y as replayWarn, Yt as expectedOwnerParam, Z as requireConfigString, Zt as processStackMessages, _ as createPreDeleteFinalSnapshot, _n as ResourceTimeoutError, _t as AssetModeResolver, a as DeploymentEventsStore, an as CdkdError, at as TemplateParser, b as unsupportedFinalSnapshotError, bn as StackTerminationProtectionError, bt as getBootstrapMarkerKey, c as replayFailedOperations, cn as DeployCancelledError, ct as rebuildClientForBucketRegion, d as IMPLICIT_DELETE_DEPENDENCIES, dn as LocalStartServiceError, dt as stringifyValue, en as AwsClients, et as describeTypeWithThrottleRetry, f as computeImplicitDeleteEdges, ft as WorkGraph, g as ccRoutedFinalSnapshotError, gn as ProvisioningError, gt as rewriteTemplateAssetReferences, h as buildFinalSnapshotIdentifier, hn as PartialFailureError, ht as loadPublishableAssetManifest, i as DeploymentEventsReader, it as DagBuilder, j as yellow, jt as Synthesizer, k as green, kt as AssetManifestLoader, l as replayRollback, ln as LocalInvokeBuildError$1, lt as shouldRetainResource, m as PRE_DELETE_SNAPSHOT_TYPES, mn as NestedStackChildDirectDestroyError, mt as createAssetRedirectResolver, n as DEFAULT_RESOURCE_WARN_AFTER_MS, nn as resetAwsClients, nt as isRetryableTransientError, o as planFailedOps, ot as LockManager, p as ATOMIC_FINAL_SNAPSHOT_TYPES, pn as MissingCdkCliError, pt as buildAssetRedirectMap, q as assertRegionMatch, qt as findLargeInlineResources, r as DeployEngine, rn as setAwsClients, rt as isThrottlingError, s as planRollback, st as S3StateBackend, t as DEFAULT_RESOURCE_TIMEOUT_MS, tn as getAwsClients, tt as withRetry, u as withResourceDeadline, un as LocalMigrateError, ut as AssetPublisher, v as isFinalSnapshotError, vn as ResourceUpdateNotSupportedError, vt as BOOTSTRAP_MARKER_PREFIX, w as renderStatefulReason, wt as buildDockerImage, x as extractDeploymentEventError, xt as parseBootstrapMarker, y as refusesFinalSnapshot, yn as StackHasActiveImportsError, yt as ensureAssetStorage, z as disableInstanceApiTermination, zt as resolveStateBucketWithDefault } from "./deploy-engine-CeEJqaaT.js";
2
+ import { $ as DiffCalculator, $t as resolveBucketRegion, A as red, At as getDockerImageBySourceHash, B as isTerminationProtectionPropagationError, Bt as resolveStateBucketWithDefaultAndSource, C as isStatefulRecreateTargetSync, Ct as validateContainerRepoName, D as cyan, Dt as runDockerForeground, E as bold, En as withErrorHandling, Et as getDockerCmd, F as ProviderRegistry, Ft as resolveApp, G as normalizeAwsTagsToCfn, Gt as CFN_TEMPLATE_URL_LIMIT, H as cfnRefValueFromPhysicalId, Ht as stateBucketExistenceConfirmed, I as findActionableSilentDrops, It as resolveAutoAssetStorage, J as readConfigString, Jt as uploadCfnTemplate, K as resolveExplicitPhysicalId, Kt as MIGRATE_TMP_PREFIX, L as CloudControlProvider, Lt as resolveCaptureObservedState, M as IAMRoleProvider, Mt as synthesisStatusMessage, N as collectInlinePolicyNamesManagedBySiblings, Nt as getDefaultStateBucketName, O as gray, Ot as runDockerStreaming, P as clearOnUpdateRemoval, Pt as getLegacyStateBucketName, Q as applyRoleArnIfSet, R as slowCcOperationTimeoutMs, Rt as resolveSkipPrefix, S as MULTI_REGION_RECREATE_BLOCKED_TYPES, St as validateAssetBucketName, T as formatResourceLine, Tn as normalizeAwsError, Tt as formatDockerLoginError, U as refStateLookupFromResource, Ut as warnDeprecatedNoPrefixCliFlag, V as IntrinsicFunctionResolver, Vt as resolveUseCdkBootstrapAssets, W as WAFv2WebACLProvider, Wt as CFN_TEMPLATE_BODY_LIMIT, X as requireConfigArray, Xt as AssemblyReader, Y as replayWarn, Yt as expectedOwnerParam, Z as requireConfigString, Zt as processStackMessages, _ as createPreDeleteFinalSnapshot, _n as ResourceTimeoutError, _t as AssetModeResolver, a as DeploymentEventsStore, an as CdkdError, at as TemplateParser, b as unsupportedFinalSnapshotError, bn as StackTerminationProtectionError, bt as getBootstrapMarkerKey, c as replayFailedOperations, cn as DeployCancelledError, ct as rebuildClientForBucketRegion, d as IMPLICIT_DELETE_DEPENDENCIES, dn as LocalStartServiceError, dt as stringifyValue, en as AwsClients, et as describeTypeWithThrottleRetry, f as computeImplicitDeleteEdges, ft as WorkGraph, g as ccRoutedFinalSnapshotError, gn as ProvisioningError, gt as rewriteTemplateAssetReferences, h as buildFinalSnapshotIdentifier, hn as PartialFailureError, ht as loadPublishableAssetManifest, i as DeploymentEventsReader, it as DagBuilder, j as yellow, jt as Synthesizer, k as green, kt as AssetManifestLoader, l as replayRollback, ln as LocalInvokeBuildError$1, lt as shouldRetainResource, m as PRE_DELETE_SNAPSHOT_TYPES, mn as NestedStackChildDirectDestroyError, mt as createAssetRedirectResolver, n as DEFAULT_RESOURCE_WARN_AFTER_MS, nn as resetAwsClients, nt as isRetryableTransientError, o as planFailedOps, ot as LockManager, p as ATOMIC_FINAL_SNAPSHOT_TYPES, pn as MissingCdkCliError, pt as buildAssetRedirectMap, q as assertRegionMatch, qt as findLargeInlineResources, r as DeployEngine, rn as setAwsClients, rt as isThrottlingError, s as planRollback, st as S3StateBackend, t as DEFAULT_RESOURCE_TIMEOUT_MS, tn as getAwsClients, tt as withRetry, u as withResourceDeadline, un as LocalMigrateError, ut as AssetPublisher, v as isFinalSnapshotError, vn as ResourceUpdateNotSupportedError, vt as BOOTSTRAP_MARKER_PREFIX, w as renderStatefulReason, wt as buildDockerImage, x as extractDeploymentEventError, xt as parseBootstrapMarker, y as refusesFinalSnapshot, yn as StackHasActiveImportsError, yt as ensureAssetStorage, z as disableInstanceApiTermination, zt as resolveStateBucketWithDefault } from "./deploy-engine-CJkdO-cZ.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-Camwh-s6.js";
4
+ import { t as ASGProvider } from "./asg-provider-BSJ8OWXR.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";
@@ -5370,19 +5370,19 @@ var S3BucketProvider = class S3BucketProvider {
5370
5370
  async applyMetricsConfigurations(bucketName, configs) {
5371
5371
  for (const config of configs) {
5372
5372
  const id = config["Id"];
5373
- const filter = config["TagFilters"] || config["Prefix"] || config["AccessPointArn"];
5374
5373
  const metricsConfig = { Id: id };
5375
- if (config["Prefix"]) metricsConfig.Filter = { Prefix: config["Prefix"] };
5376
- else if (config["TagFilters"]) {
5377
- const tagFilters = config["TagFilters"];
5378
- if (tagFilters.length === 1 && !config["Prefix"] && !config["AccessPointArn"]) metricsConfig.Filter = { Tag: tagFilters[0] };
5379
- else metricsConfig.Filter = { And: {
5380
- Prefix: config["Prefix"],
5381
- Tags: tagFilters,
5382
- AccessPointArn: config["AccessPointArn"]
5383
- } };
5384
- } else if (config["AccessPointArn"]) metricsConfig.Filter = { AccessPointArn: config["AccessPointArn"] };
5385
- else if (filter === void 0) {}
5374
+ const prefix = config["Prefix"];
5375
+ const accessPointArn = config["AccessPointArn"];
5376
+ const tagFilters = config["TagFilters"];
5377
+ const tagCount = tagFilters?.length ?? 0;
5378
+ if ((prefix ? 1 : 0) + tagCount + (accessPointArn ? 1 : 0) > 1) metricsConfig.Filter = { And: {
5379
+ Prefix: prefix,
5380
+ Tags: tagCount > 0 ? tagFilters : void 0,
5381
+ AccessPointArn: accessPointArn
5382
+ } };
5383
+ else if (prefix) metricsConfig.Filter = { Prefix: prefix };
5384
+ else if (tagFilters && tagFilters.length === 1) metricsConfig.Filter = { Tag: tagFilters[0] };
5385
+ else if (accessPointArn) metricsConfig.Filter = { AccessPointArn: accessPointArn };
5386
5386
  await this.s3Client.send(new PutBucketMetricsConfigurationCommand({
5387
5387
  Bucket: bucketName,
5388
5388
  Id: id,
@@ -5456,14 +5456,13 @@ var S3BucketProvider = class S3BucketProvider {
5456
5456
  };
5457
5457
  const prefix = config["Prefix"];
5458
5458
  const tagFilters = config["TagFilters"];
5459
- if (prefix || tagFilters && tagFilters.length > 0) {
5460
- if ((prefix ? 1 : 0) + (tagFilters && tagFilters.length > 0 ? 1 : 0) > 1) analyticsConfig.Filter = { And: {
5461
- Prefix: prefix,
5462
- Tags: tagFilters
5463
- } };
5464
- else if (prefix) analyticsConfig.Filter = { Prefix: prefix };
5465
- else if (tagFilters && tagFilters.length > 0) analyticsConfig.Filter = { Tag: tagFilters[0] };
5466
- }
5459
+ const tagCount = tagFilters?.length ?? 0;
5460
+ if ((prefix ? 1 : 0) + tagCount > 1) analyticsConfig.Filter = { And: {
5461
+ Prefix: prefix,
5462
+ Tags: tagFilters
5463
+ } };
5464
+ else if (prefix) analyticsConfig.Filter = { Prefix: prefix };
5465
+ else if (tagFilters && tagFilters.length === 1) analyticsConfig.Filter = { Tag: tagFilters[0] };
5467
5466
  if (storageClassAnalysis?.["DataExport"] != null) {
5468
5467
  const dataExport = storageClassAnalysis["DataExport"];
5469
5468
  const analyticsDestPath = "AWS::S3::Bucket AnalyticsConfigurations[].StorageClassAnalysis.DataExport.Destination";
@@ -5509,14 +5508,13 @@ var S3BucketProvider = class S3BucketProvider {
5509
5508
  };
5510
5509
  const prefix = config["Prefix"];
5511
5510
  const tagFilters = config["TagFilters"];
5512
- if (prefix || tagFilters && tagFilters.length > 0) {
5513
- if ((prefix ? 1 : 0) + (tagFilters && tagFilters.length > 0 ? 1 : 0) > 1) itConfig.Filter = { And: {
5514
- Prefix: prefix,
5515
- Tags: tagFilters
5516
- } };
5517
- else if (prefix) itConfig.Filter = { Prefix: prefix };
5518
- else if (tagFilters && tagFilters.length > 0) itConfig.Filter = { Tag: tagFilters[0] };
5519
- }
5511
+ const tagCount = tagFilters?.length ?? 0;
5512
+ if ((prefix ? 1 : 0) + tagCount > 1) itConfig.Filter = { And: {
5513
+ Prefix: prefix,
5514
+ Tags: tagFilters
5515
+ } };
5516
+ else if (prefix) itConfig.Filter = { Prefix: prefix };
5517
+ else if (tagFilters && tagFilters.length === 1) itConfig.Filter = { Tag: tagFilters[0] };
5520
5518
  await this.s3Client.send(new PutBucketIntelligentTieringConfigurationCommand({
5521
5519
  Bucket: bucketName,
5522
5520
  Id: id,
@@ -7775,8 +7773,20 @@ var SNSTopicProvider = class {
7775
7773
  }
7776
7774
  /**
7777
7775
  * Create an SNS topic
7776
+ *
7777
+ * `context.replayingState` (issue #1551) downgrades this method's one
7778
+ * template-shape refusal — `buildDeliveryStatusAttributeMap`'s `'throw'`
7779
+ * mode — to a warning. The rollback executor's
7780
+ * reverse-replacement arm revives the OLD topic with
7781
+ * `create(..., previousState.properties, REPLAYING_STATE_CREATE_CONTEXT)`,
7782
+ * so the properties bag can be a historical cdkd STATE record carrying a
7783
+ * shape this provider now refuses — and the user has no template-side
7784
+ * remedy for a state record. The parameter was previously absent, so that
7785
+ * 4th argument was silently ignored and `buildDeliveryStatusAttributeMap`'s
7786
+ * `'throw'` mode stranded the replay; issue #1538 fixed the update side
7787
+ * only.
7778
7788
  */
7779
- async create(logicalId, resourceType, properties) {
7789
+ async create(logicalId, resourceType, properties, context) {
7780
7790
  this.logger.debug(`Creating SNS topic ${logicalId}`);
7781
7791
  const topicName = properties["TopicName"] || generateResourceName(logicalId, { maxLength: 256 });
7782
7792
  try {
@@ -7814,7 +7824,7 @@ var SNSTopicProvider = class {
7814
7824
  AttributeValue: dataProtectionPolicy
7815
7825
  }));
7816
7826
  }
7817
- const deliveryStatusAttributes = buildDeliveryStatusAttributeMap(properties["DeliveryStatusLogging"], logicalId, "throw");
7827
+ const deliveryStatusAttributes = buildDeliveryStatusAttributeMap(properties["DeliveryStatusLogging"], logicalId, context?.replayingState === true ? "warn" : "throw");
7818
7828
  for (const [attributeName, attributeValue] of deliveryStatusAttributes) await this.snsClient.send(new SetTopicAttributesCommand({
7819
7829
  TopicArn: topicArn,
7820
7830
  AttributeName: attributeName,
@@ -8311,9 +8321,15 @@ const SNS_DELIVERY_STATUS_ATTRIBUTE_SUFFIXES = [
8311
8321
  * / unknown protocol, and encodes the create-vs-update distinction
8312
8322
  * (issue #1538):
8313
8323
  *
8314
- * - `'throw'` — the CREATE desired side, which is always template-borne:
8315
- * a template error must fail fast, naming the offending value.
8316
- * - `'warn'` — the UPDATE desired side, which is NOT always template-borne:
8324
+ * - `'throw'` — a TEMPLATE-borne desired side: an ordinary `create()`, where a
8325
+ * template error must fail fast, naming the offending value.
8326
+ * - `'warn'` — a desired side that is NOT template-borne. That is every
8327
+ * `update()`, and — since issue #1551 — a `create()` whose
8328
+ * `CreateContext.replayingState` is set (the rollback executor's
8329
+ * reverse-replacement arm, which revives the old topic from a state record).
8330
+ * The wording below is therefore operation-neutral: on a create there is no
8331
+ * previously-set attribute to reset, only one that is never applied. Same
8332
+ * reason as before:
8317
8333
  * the rollback executor's revert arm and `cdkd drift --revert` both call
8318
8334
  * `update()` with a state-derived bag as the DESIRED properties, so a
8319
8335
  * state record carrying an unsupported protocol / malformed shape (a
@@ -8346,8 +8362,9 @@ const SNS_DELIVERY_STATUS_ATTRIBUTE_SUFFIXES = [
8346
8362
  * protocol, non-array container, non-object entry) used to throw on that
8347
8363
  * side too, which made such a state record permanently unreplayable —
8348
8364
  * fixed by issue #1538, which moved `update()`'s desired side to `'warn'`
8349
- * while `create()` keeps `'throw'` (a template create must still fail
8350
- * fast; #1529 / #1536 deliberately left that contract unchanged).
8365
+ * while `create()` kept `'throw'`; issue #1551 then extended the downgrade to
8366
+ * a create that DECLARES a state replay, leaving the template-path create
8367
+ * strict (#1529 / #1536 deliberately left that contract unchanged).
8351
8368
  */
8352
8369
  function buildDeliveryStatusAttributeMap(logging, logicalId, onMalformed) {
8353
8370
  const map = /* @__PURE__ */ new Map();
@@ -8358,7 +8375,7 @@ function buildDeliveryStatusAttributeMap(logging, logicalId, onMalformed) {
8358
8375
  const seenProtocols = /* @__PURE__ */ new Set();
8359
8376
  if (!Array.isArray(logging)) {
8360
8377
  if (onMalformed === "throw") throw new Error(`SNS topic ${logicalId}: DeliveryStatusLogging must be an array of {Protocol, ...} objects, got ${JSON.stringify(logging)}`);
8361
- if (onMalformed === "warn") warn(`SNS topic ${logicalId}: DeliveryStatusLogging must be an array of {Protocol, ...} objects, got ${JSON.stringify(logging)} — treating it as empty for this update, so previously set delivery-status attributes are reset. The desired properties can come from a cdkd state record (rollback replay / drift --revert), so this does not fail the update; fix the template (or the state record on a replay) to clear this warning.`);
8378
+ if (onMalformed === "warn") warn(`SNS topic ${logicalId}: DeliveryStatusLogging must be an array of {Protocol, ...} objects, got ${JSON.stringify(logging)} — treating it as empty, so no delivery-status attribute is applied (on an update, any previously set one is reset). The desired properties can come from a cdkd state record (rollback replay / drift --revert), so this does not fail the operation; fix the template (or the state record on a replay) to clear this warning.`);
8362
8379
  return map;
8363
8380
  }
8364
8381
  for (const entry of logging) {
@@ -10083,9 +10100,16 @@ var LambdaUrlProvider = class {
10083
10100
  wasReplaced: false,
10084
10101
  attributes: {}
10085
10102
  };
10103
+ let authTypeUnusable = false;
10104
+ const requestedAuthType = requireConfigString(properties["AuthType"], "NONE", "AWS::Lambda::Url AuthType", { onUnusable: (message) => {
10105
+ authTypeUnusable = true;
10106
+ this.logger.warn(`${message} The function URL's existing auth type is kept for this update rather than reset to the default (NONE), which would make the URL public.`);
10107
+ } });
10108
+ const previousAuthType = previousProperties["AuthType"];
10109
+ const authType = authTypeUnusable ? typeof previousAuthType === "string" && previousAuthType.trim() !== "" ? previousAuthType : void 0 : requestedAuthType;
10086
10110
  const updateParams = {
10087
10111
  FunctionName: physicalId,
10088
- AuthType: requireConfigString(properties["AuthType"], "NONE", "AWS::Lambda::Url AuthType")
10112
+ ...authType !== void 0 && { AuthType: authType }
10089
10113
  };
10090
10114
  const invokeMode = clearOnUpdateRemoval(properties["InvokeMode"], previousProperties["InvokeMode"], "BUFFERED");
10091
10115
  if (invokeMode !== void 0) updateParams.InvokeMode = invokeMode;
@@ -11729,7 +11753,10 @@ var DynamoDBTableProvider = class {
11729
11753
  if (table?.TableArn) await this.applyTagDiff(table.TableArn, previousProperties["Tags"], properties["Tags"]);
11730
11754
  const normalizeTableClass = (v) => typeof v === "string" && v.length > 0 ? v : "STANDARD";
11731
11755
  const tableClassChanged = normalizeTableClass(properties["TableClass"]) !== normalizeTableClass(previousProperties["TableClass"]);
11732
- const prevBillingMode = previousProperties["BillingMode"];
11756
+ const recordedPrevBillingMode = previousProperties["BillingMode"];
11757
+ const recordedPrevBillingModeUsable = recordedPrevBillingMode === void 0 || typeof recordedPrevBillingMode === "string" && recordedPrevBillingMode.trim() !== "";
11758
+ const prevBillingMode = recordedPrevBillingModeUsable ? recordedPrevBillingMode : table?.BillingModeSummary?.BillingMode ?? "PROVISIONED";
11759
+ if (!recordedPrevBillingModeUsable) this.logger.warn(`AWS::DynamoDB::Table ${logicalId}: the recorded previous BillingMode is unusable (${JSON.stringify(recordedPrevBillingMode)}) — using the table's actual billing mode (${prevBillingMode}) as the comparison baseline for this update so a corrected template does not issue a same-mode UpdateTable.`);
11733
11760
  let billingModeUnusable = false;
11734
11761
  const requestedBillingMode = properties["BillingMode"] === void 0 ? void 0 : requireConfigString(properties["BillingMode"], "PROVISIONED", "AWS::DynamoDB::Table BillingMode", { onUnusable: (message) => {
11735
11762
  billingModeUnusable = true;
@@ -12707,7 +12734,8 @@ var DynamoDBGlobalTableProvider = class {
12707
12734
  }
12708
12735
  let sdkIndexes;
12709
12736
  try {
12710
- sdkIndexes = toSdkGlobalSecondaryIndexes(properties, currentRegion, billingMode, "min", diagnostics, replayWarn(this.logger, context).onUnusable);
12737
+ const onUnusableCreateIndexes = replayWarn(this.logger, context).onUnusable;
12738
+ sdkIndexes = toSdkGlobalSecondaryIndexes(properties, currentRegion, billingMode, "min", diagnostics, onUnusableCreateIndexes && ((message) => onUnusableCreateIndexes(`${message} Omitting the malformed block, so this create carries NO indexes; the same value is REFUSED on a template-path create`)));
12711
12739
  } catch (error) {
12712
12740
  throw new ProvisioningError(error instanceof Error ? error.message : String(error), resourceType, logicalId, void 0, error instanceof Error ? error : void 0);
12713
12741
  }
@@ -12915,7 +12943,10 @@ var DynamoDBGlobalTableProvider = class {
12915
12943
  return (props["Replicas"] ?? []).find((r) => r["Region"] === currentRegion)?.["Tags"];
12916
12944
  };
12917
12945
  if (tableArn) await this.applyTagDiff(tableArn, extractLocalTags(previousProperties), extractLocalTags(properties));
12918
- const oldBilling = previousProperties["BillingMode"] ?? "PAY_PER_REQUEST";
12946
+ const recordedOldBilling = previousProperties["BillingMode"];
12947
+ const recordedOldBillingUsable = recordedOldBilling === void 0 || typeof recordedOldBilling === "string" && recordedOldBilling.trim() !== "";
12948
+ const oldBilling = recordedOldBillingUsable ? recordedOldBilling ?? "PAY_PER_REQUEST" : describeResp.Table?.BillingModeSummary?.BillingMode ?? "PROVISIONED";
12949
+ if (!recordedOldBillingUsable) this.logger.warn(`AWS::DynamoDB::GlobalTable ${logicalId}: the recorded previous BillingMode is unusable (${JSON.stringify(recordedOldBilling)}) — using the table's actual billing mode (${oldBilling}) as the comparison baseline for this update so a corrected template does not issue a same-mode UpdateTable.`);
12919
12950
  let billingUnusable = false;
12920
12951
  const requestedBilling = requireConfigString(properties["BillingMode"], "PAY_PER_REQUEST", "AWS::DynamoDB::GlobalTable BillingMode", { onUnusable: (message) => {
12921
12952
  billingUnusable = true;
@@ -12927,8 +12958,19 @@ var DynamoDBGlobalTableProvider = class {
12927
12958
  const desiredCeilings = collectTableOnDemandCeilings(properties, currentRegion, diagnostics);
12928
12959
  const flippingToProvisioned = oldBilling !== newBilling && newBilling === "PROVISIONED";
12929
12960
  if (flippingToProvisioned) derivePerCallProvisionedThroughput(properties, currentRegion, "seed", diagnostics);
12930
- const desiredSdkIndexes = toSdkGlobalSecondaryIndexes(properties, currentRegion, newBilling, "min", flippingToProvisioned ? void 0 : diagnostics);
12931
- if (flippingToProvisioned) toSdkGlobalSecondaryIndexes(properties, currentRegion, newBilling, "seed", diagnostics);
12961
+ let desiredGsiUnusable = false;
12962
+ const onUnusableGsiBlock = (message) => {
12963
+ desiredGsiUnusable = true;
12964
+ this.logger.warn(`${message} No GlobalSecondaryIndexes change is applied by this update; the table's existing indexes are left untouched.`);
12965
+ };
12966
+ let previousGsiUnusable = false;
12967
+ const onUnusablePreviousGsiBlock = (message) => {
12968
+ previousGsiUnusable = true;
12969
+ this.logger.warn(`${message} (recorded in cdkd state, not in the template) — using the table's LIVE indexes as the comparison baseline for this update, so a corrected template still applies.`);
12970
+ };
12971
+ const liveIndexNames = new Set((describeResp.Table?.GlobalSecondaryIndexes ?? []).map((live) => live.IndexName).filter((name) => typeof name === "string"));
12972
+ const desiredSdkIndexes = toSdkGlobalSecondaryIndexes(properties, currentRegion, newBilling, "min", flippingToProvisioned ? void 0 : diagnostics, onUnusableGsiBlock);
12973
+ if (flippingToProvisioned) toSdkGlobalSecondaryIndexes(properties, currentRegion, newBilling, "seed", diagnostics, onUnusableGsiBlock);
12932
12974
  for (const replica of properties["Replicas"] ?? []) {
12933
12975
  const replicaRegion = asRecord$1(replica)?.["Region"];
12934
12976
  if (typeof replicaRegion !== "string" || replicaRegion === currentRegion) continue;
@@ -12959,11 +13001,18 @@ var DynamoDBGlobalTableProvider = class {
12959
13001
  flatChanged = true;
12960
13002
  }
12961
13003
  if (properties["StreamSpecification"] !== void 0 && !deepEqual$1(properties["StreamSpecification"], previousProperties["StreamSpecification"])) {
12962
- flatUpdate.StreamSpecification = {
12963
- StreamEnabled: true,
12964
- StreamViewType: readConfigString(properties["StreamSpecification"], "StreamViewType", "NEW_AND_OLD_IMAGES", "AWS::DynamoDB::GlobalTable StreamSpecification")
12965
- };
12966
- flatChanged = true;
13004
+ let streamSpecUnusable = false;
13005
+ const streamViewType = readConfigString(properties["StreamSpecification"], "StreamViewType", "NEW_AND_OLD_IMAGES", "AWS::DynamoDB::GlobalTable StreamSpecification", { onUnusable: (message) => {
13006
+ streamSpecUnusable = true;
13007
+ this.logger.warn(`${message} The table's existing stream configuration is left untouched for this update rather than re-pointed at the default.`);
13008
+ } });
13009
+ if (!streamSpecUnusable) {
13010
+ flatUpdate.StreamSpecification = {
13011
+ StreamEnabled: true,
13012
+ StreamViewType: streamViewType
13013
+ };
13014
+ flatChanged = true;
13015
+ }
12967
13016
  }
12968
13017
  const awsOnDemand = describeResp.Table?.OnDemandThroughput;
12969
13018
  const onDemandPayload = {};
@@ -12995,11 +13044,13 @@ var DynamoDBGlobalTableProvider = class {
12995
13044
  };
12996
13045
  if (newBilling === "PROVISIONED") {
12997
13046
  billingUpdate.ProvisionedThroughput = derivePerCallProvisionedThroughput(properties, currentRegion, "seed");
12998
- const provisionedIndexes = toSdkGlobalSecondaryIndexes(properties, currentRegion, newBilling, "seed");
13047
+ const provisionedIndexes = toSdkGlobalSecondaryIndexes(properties, currentRegion, newBilling, "seed", void 0, onUnusableGsiBlock);
13048
+ const previousFlipIndexes = toSdkGlobalSecondaryIndexes(previousProperties, currentRegion, newBilling, "seed", void 0, onUnusablePreviousGsiBlock);
13049
+ if (desiredGsiUnusable || previousGsiUnusable) throw new ProvisioningError(`Cannot flip AWS::DynamoDB::GlobalTable ${logicalId} to PROVISIONED while its GlobalSecondaryIndexes block is unusable: AWS requires per-index provisioned capacity in the same UpdateTable, and it cannot be derived from a malformed block (nor read from a table that is still on-demand). Fix the GlobalSecondaryIndexes value — in the template, or in the cdkd state record on a rollback / drift --revert replay — and re-deploy. The table is unchanged.`, resourceType, logicalId, physicalId);
13050
+ const previousByIndexName = /* @__PURE__ */ new Map();
13051
+ for (const gsi of previousFlipIndexes) if (gsi.IndexName) previousByIndexName.set(gsi.IndexName, gsi);
12999
13052
  const previousCfnIndexes = previousProperties["GlobalSecondaryIndexes"];
13000
13053
  const existingIndexNames = new Set((Array.isArray(previousCfnIndexes) ? previousCfnIndexes : []).map((entry) => entry?.["IndexName"]).filter((name) => typeof name === "string"));
13001
- const previousByIndexName = /* @__PURE__ */ new Map();
13002
- for (const gsi of toSdkGlobalSecondaryIndexes(previousProperties, currentRegion, newBilling, "seed")) if (gsi.IndexName) previousByIndexName.set(gsi.IndexName, gsi);
13003
13054
  const byIndexName = new Map(previousByIndexName);
13004
13055
  const survivingIndexNames = /* @__PURE__ */ new Set();
13005
13056
  for (const gsi of provisionedIndexes) {
@@ -13121,8 +13172,18 @@ var DynamoDBGlobalTableProvider = class {
13121
13172
  }));
13122
13173
  await this.waitForReplicaActive(physicalId, region, logicalId);
13123
13174
  }
13124
- const previousSdkIndexes = toSdkGlobalSecondaryIndexes(previousProperties, currentRegion, oldBilling);
13125
- const gsiDiff = diffGlobalSecondaryIndexes(previousSdkIndexes, desiredSdkIndexes);
13175
+ const previousTranslatedIndexes = toSdkGlobalSecondaryIndexes(previousProperties, currentRegion, oldBilling, "min", void 0, onUnusablePreviousGsiBlock);
13176
+ const previousSdkIndexes = previousGsiUnusable ? desiredSdkIndexes.filter((gsi) => typeof gsi.IndexName === "string" && liveIndexNames.has(gsi.IndexName)) : previousTranslatedIndexes;
13177
+ if (previousGsiUnusable) {
13178
+ const desiredNames = new Set(desiredSdkIndexes.map((gsi) => gsi.IndexName).filter((name) => typeof name === "string"));
13179
+ const liveOnly = [...liveIndexNames].filter((name) => !desiredNames.has(name));
13180
+ if (liveOnly.length > 0) this.logger.warn(`AWS::DynamoDB::GlobalTable ${logicalId}: ${liveOnly.join(", ")} exist(s) on the table but not in the template. No Delete is issued while the recorded GlobalSecondaryIndexes are unusable — a junk state record cannot prove cdkd created them. Re-deploy once state carries a valid block to remove them.`);
13181
+ }
13182
+ const gsiDiff = desiredGsiUnusable ? {
13183
+ added: [],
13184
+ removed: [],
13185
+ modified: []
13186
+ } : diffGlobalSecondaryIndexes(previousSdkIndexes, desiredSdkIndexes);
13126
13187
  const rawOnDemandDeclarations = collectRawOnDemandDeclarations(properties, currentRegion);
13127
13188
  const previousSdkByName = /* @__PURE__ */ new Map();
13128
13189
  for (const prev of previousSdkIndexes) if (prev.IndexName) previousSdkByName.set(prev.IndexName, prev);
@@ -13182,7 +13243,10 @@ var DynamoDBGlobalTableProvider = class {
13182
13243
  }));
13183
13244
  await this.waitForTableActiveAfterUpdate(physicalId, logicalId);
13184
13245
  }
13185
- if (newBilling === "PROVISIONED" || oldBilling === "PROVISIONED") {
13246
+ const skipAutoScalingForUnusableGsi = desiredGsiUnusable && newBilling !== "PAY_PER_REQUEST";
13247
+ const autoScalingMeaningfulForIndexes = (newBilling === "PROVISIONED" || oldBilling === "PROVISIONED") && !skipAutoScalingForUnusableGsi;
13248
+ if (skipAutoScalingForUnusableGsi && oldBilling === "PROVISIONED") this.logger.warn(`AWS::DynamoDB::GlobalTable ${logicalId}: skipping the auto-scaling target reconcile because the GlobalSecondaryIndexes block is unusable — the per-index targets are derived from it, so reconciling would deregister the live indexes' scalable targets. Existing targets are left untouched.`);
13249
+ if (autoScalingMeaningfulForIndexes) {
13186
13250
  if (gsiDiff.added.length > 0) await this.waitForIndexesActive(physicalId, logicalId);
13187
13251
  await this.reconcileAutoScalingTargets(physicalId, collectAutoScalingTargets(previousProperties, currentRegion), newBilling === "PAY_PER_REQUEST" ? [] : collectAutoScalingTargets(properties, currentRegion), currentRegion, autoScalingApplied);
13188
13252
  }
@@ -14692,7 +14756,7 @@ function toSdkGlobalSecondaryIndexes(properties, region, billingMode, source = "
14692
14756
  if (rawIndexes !== void 0 && !Array.isArray(rawIndexes)) {
14693
14757
  const shapeDetail = `AWS::DynamoDB::GlobalTable GlobalSecondaryIndexes must be an array, got ${typeof rawIndexes} (${JSON.stringify(rawIndexes)?.slice(0, 200)}).`;
14694
14758
  if (onUnusableIndexes) {
14695
- onUnusableIndexes(`${shapeDetail} Omitting the malformed block, so this create carries NO indexes; the same value is REFUSED on a template-path create`);
14759
+ onUnusableIndexes(shapeDetail);
14696
14760
  return [];
14697
14761
  }
14698
14762
  throw new Error(`${shapeDetail} An unresolved intrinsic here would otherwise deploy a table with no indexes.`);
@@ -68036,7 +68100,7 @@ function createMigrateCommand() {
68036
68100
  */
68037
68101
  function buildProgram() {
68038
68102
  const program = new Command();
68039
- program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.278.53");
68103
+ program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.278.55");
68040
68104
  program.hook("preAction", (_thisCommand, actionCommand) => {
68041
68105
  const { profile } = actionCommand.optsWithGlobals();
68042
68106
  if (profile !== void 0) process.env["AWS_PROFILE"] = profile;