@go-to-k/cdkd 0.111.0 → 0.111.1

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
@@ -8074,9 +8074,7 @@ var DynamoDBGlobalTableProvider = class {
8074
8074
  if (sse["SSEType"]) sseInput.SSEType = sse["SSEType"];
8075
8075
  createParams.SSESpecification = sseInput;
8076
8076
  }
8077
- const dpePerReplica = replicas.find((r) => r["Region"] === currentRegion)?.["DeletionProtectionEnabled"];
8078
- const dpeTopLevel = properties["DeletionProtectionEnabled"];
8079
- const dpeResolved = typeof dpePerReplica === "boolean" ? dpePerReplica : typeof dpeTopLevel === "boolean" ? dpeTopLevel : void 0;
8077
+ const dpeResolved = extractLocalDeletionProtection(properties, currentRegion);
8080
8078
  if (dpeResolved !== void 0) createParams.DeletionProtectionEnabled = dpeResolved;
8081
8079
  if (properties["TableClass"]) createParams.TableClass = properties["TableClass"];
8082
8080
  const wodts = properties["WriteOnDemandThroughputSettings"];
@@ -8202,22 +8200,18 @@ var DynamoDBGlobalTableProvider = class {
8202
8200
  const currentRegion = await this.dynamoDBClient.config.region() ?? "";
8203
8201
  try {
8204
8202
  await this.waitForTableActiveAfterUpdate(physicalId, logicalId);
8205
- const tableArn = (await this.dynamoDBClient.send(new DescribeTableCommand({ TableName: physicalId }))).Table?.TableArn;
8203
+ const describeResp = await this.dynamoDBClient.send(new DescribeTableCommand({ TableName: physicalId }));
8204
+ const tableArn = describeResp.Table?.TableArn;
8206
8205
  const extractLocalTags = (props) => {
8207
8206
  return (props["Replicas"] ?? []).find((r) => r["Region"] === currentRegion)?.["Tags"];
8208
8207
  };
8209
8208
  if (tableArn) await this.applyTagDiff(tableArn, extractLocalTags(previousProperties), extractLocalTags(properties));
8210
- const extractLocalDP = (props) => {
8211
- const perReplica = (props["Replicas"] ?? []).find((r) => r["Region"] === currentRegion)?.["DeletionProtectionEnabled"];
8212
- if (typeof perReplica === "boolean") return perReplica;
8213
- const topLevel = props["DeletionProtectionEnabled"];
8214
- return typeof topLevel === "boolean" ? topLevel : void 0;
8215
- };
8216
- const newDpe = extractLocalDP(properties);
8217
- const oldDpe = extractLocalDP(previousProperties);
8209
+ const newDpe = extractLocalDeletionProtection(properties, currentRegion);
8210
+ const oldDpe = extractLocalDeletionProtection(previousProperties, currentRegion);
8211
+ const awsDpe = describeResp.Table?.DeletionProtectionEnabled;
8218
8212
  const flatUpdate = { TableName: physicalId };
8219
8213
  let flatChanged = false;
8220
- if (newDpe !== oldDpe) {
8214
+ if (newDpe !== oldDpe || newDpe !== void 0 && typeof awsDpe === "boolean" && Boolean(newDpe) !== awsDpe) {
8221
8215
  flatUpdate.DeletionProtectionEnabled = Boolean(newDpe ?? false);
8222
8216
  flatChanged = true;
8223
8217
  }
@@ -8368,8 +8362,17 @@ var DynamoDBGlobalTableProvider = class {
8368
8362
  await this.waitForTableActiveAfterUpdate(physicalId, logicalId);
8369
8363
  }
8370
8364
  if (!deepEqual$1(properties["TimeToLiveSpecification"], previousProperties["TimeToLiveSpecification"])) {
8365
+ const sendTtl = async (cmd) => {
8366
+ try {
8367
+ await this.dynamoDBClient.send(cmd);
8368
+ } catch (ttlErr) {
8369
+ const msg = ttlErr instanceof Error ? ttlErr.message : String(ttlErr);
8370
+ if (msg.includes("Time to live has been modified multiple times")) throw new ProvisioningError(`AWS rejected TimeToLive update on ${physicalId}: ${msg}. AWS enforces a ~4-hour rate limit on TTL changes per table; wait and redeploy, or keep the previous TTL state in this deploy.`, resourceType, logicalId, physicalId, ttlErr instanceof Error ? ttlErr : void 0);
8371
+ throw ttlErr;
8372
+ }
8373
+ };
8371
8374
  const ttl = properties["TimeToLiveSpecification"];
8372
- if (ttl?.["AttributeName"]) await this.dynamoDBClient.send(new UpdateTimeToLiveCommand({
8375
+ if (ttl?.["AttributeName"]) await sendTtl(new UpdateTimeToLiveCommand({
8373
8376
  TableName: physicalId,
8374
8377
  TimeToLiveSpecification: {
8375
8378
  Enabled: ttl["Enabled"] !== void 0 ? Boolean(ttl["Enabled"]) : true,
@@ -8378,7 +8381,7 @@ var DynamoDBGlobalTableProvider = class {
8378
8381
  }));
8379
8382
  else if (previousProperties["TimeToLiveSpecification"]) {
8380
8383
  const prevTtl = previousProperties["TimeToLiveSpecification"];
8381
- if (prevTtl["AttributeName"]) await this.dynamoDBClient.send(new UpdateTimeToLiveCommand({
8384
+ if (prevTtl["AttributeName"]) await sendTtl(new UpdateTimeToLiveCommand({
8382
8385
  TableName: physicalId,
8383
8386
  TimeToLiveSpecification: {
8384
8387
  Enabled: false,
@@ -9098,6 +9101,26 @@ var DynamoDBGlobalTableProvider = class {
9098
9101
  * (per-replica, the deploy region's setting). Same literal-vs-auto-
9099
9102
  * scaling-vs-default-5 precedence.
9100
9103
  */
9104
+ /**
9105
+ * Extract the local replica's `DeletionProtectionEnabled` from a CFn
9106
+ * properties shape. The `AWS::DynamoDB::GlobalTable` CFn schema places
9107
+ * the field inside `Replicas[?Region==<region>].DeletionProtectionEnabled`;
9108
+ * CDK 2.x's `deletionProtection: true` synthesizes there. Falls back
9109
+ * to the top-level `DeletionProtectionEnabled` for legacy or
9110
+ * hand-authored templates (the property doesn't formally exist at
9111
+ * the top level in the CFn schema, but cdkd tolerates it as a
9112
+ * pass-through to avoid breaking older state files).
9113
+ *
9114
+ * Returns `undefined` when neither shape carries a boolean — the
9115
+ * caller treats that as "unset" and does not include the field in
9116
+ * the SDK call.
9117
+ */
9118
+ function extractLocalDeletionProtection(props, region) {
9119
+ const perReplica = (props["Replicas"] ?? []).find((r) => r["Region"] === region)?.["DeletionProtectionEnabled"];
9120
+ if (typeof perReplica === "boolean") return perReplica;
9121
+ const topLevel = props["DeletionProtectionEnabled"];
9122
+ return typeof topLevel === "boolean" ? topLevel : void 0;
9123
+ }
9101
9124
  function derivePerCallProvisionedThroughput(properties, region) {
9102
9125
  const wps = properties["WriteProvisionedThroughputSettings"];
9103
9126
  const writeAutoScaling = wps?.["WriteCapacityAutoScalingSettings"];
@@ -45257,7 +45280,7 @@ function reorderArgs(argv) {
45257
45280
  */
45258
45281
  async function main() {
45259
45282
  const program = new Command();
45260
- program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.111.0");
45283
+ program.name("cdkd").description("CDK Direct - Deploy AWS CDK apps directly via SDK/Cloud Control API").version("0.111.1");
45261
45284
  program.addCommand(createBootstrapCommand());
45262
45285
  program.addCommand(createSynthCommand());
45263
45286
  program.addCommand(createListCommand());