@cdkd/cli 0.344.0 → 0.346.0

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.
Files changed (29) hide show
  1. package/dist/{asg-provider-BNaBEVOz.js → asg-provider-Bu7rz365.js} +2 -2
  2. package/dist/{asg-provider-BNaBEVOz.js.map → asg-provider-Bu7rz365.js.map} +1 -1
  3. package/dist/cli.js +2 -2
  4. package/dist/{db-instance-modify-retry-BwAEmSQH.js → db-instance-modify-retry-CY94H9jp.js} +2 -2
  5. package/dist/{db-instance-modify-retry-BwAEmSQH.js.map → db-instance-modify-retry-CY94H9jp.js.map} +1 -1
  6. package/dist/{deploy-engine-BB7LVmAG.js → deploy-engine-BocT17az.js} +175 -26
  7. package/dist/deploy-engine-BocT17az.js.map +1 -0
  8. package/dist/{ecr-uri-CzGt7ztW.js → ecr-uri-Cg53WsUz.js} +2 -2
  9. package/dist/{ecr-uri-CzGt7ztW.js.map → ecr-uri-Cg53WsUz.js.map} +1 -1
  10. package/dist/{iam-role-provider-BlSi1iNz.js → iam-role-provider-_bvctXgr.js} +2 -2
  11. package/dist/{iam-role-provider-BlSi1iNz.js.map → iam-role-provider-_bvctXgr.js.map} +1 -1
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +2 -2
  14. package/dist/{neptune-provider-oRAIG3Kd.js → neptune-provider-CceDOA6q.js} +3 -3
  15. package/dist/{neptune-provider-oRAIG3Kd.js.map → neptune-provider-CceDOA6q.js.map} +1 -1
  16. package/dist/{program-BQH8NPXj.js → program-DM3nrEl9.js} +16 -29
  17. package/dist/program-DM3nrEl9.js.map +1 -0
  18. package/dist/{provider-classes-DmCFkSIr.js → provider-classes-BJRQVOZ0.js} +97 -29
  19. package/dist/{provider-classes-DmCFkSIr.js.map → provider-classes-BJRQVOZ0.js.map} +1 -1
  20. package/dist/{rds-provider-D7y6wD4F.js → rds-provider-B-TkBvu0.js} +482 -48
  21. package/dist/rds-provider-B-TkBvu0.js.map +1 -0
  22. package/dist/{read-replica-c2dYFLKs.js → read-replica-IoZoKlpg.js} +4 -4
  23. package/dist/{read-replica-c2dYFLKs.js.map → read-replica-IoZoKlpg.js.map} +1 -1
  24. package/dist/{version-b-uLTNXf.js → version-BdxBmlDu.js} +2 -2
  25. package/dist/{version-b-uLTNXf.js.map → version-BdxBmlDu.js.map} +1 -1
  26. package/package.json +3 -3
  27. package/dist/deploy-engine-BB7LVmAG.js.map +0 -1
  28. package/dist/program-BQH8NPXj.js.map +0 -1
  29. package/dist/rds-provider-D7y6wD4F.js.map +0 -1
@@ -2,12 +2,12 @@ import { S as coerceCfnBoolean, b as generatedNameFor, n as describeAwsFailure,
2
2
  import { $ as CdkdError, G as markRedactedCause, K as wrapMaskedAwsError, O as relayedNameCollision, W as markNonRetryable, _ as ResourceUpdateNotSupportedError, it as ProvisioningError, t as ambientClientDefaults } from "./ambient-client-defaults-w6GrD1cQ.js";
3
3
  import { $ as deleteAfterProtectionFlipWithFinalSnapshot, B as resolveExplicitPhysicalId, H as assertRegionMatch, I as normalizeAwsTagsToCfn, It as maskerOrIdentity, J as observeThenDisableProtection, K as deleteWithProtectionCompensation, Kt as markAuxiliaryFailure, Lt as withDerivedNameMasks, Mt as createMaskedLogSinks, Q as PROTECTION_FLIP_RETRY_WAIT_MS, V as RESOURCE_NOT_FOUND, W as markNotGone, Y as rdsFamilyProtectionSite, a as withRemovalDefaults, f as retractCreatedResource, gt as protectedReplacementAdvice, ht as pasteableAwsCommand, it as ProtectionFlipRegistry, j as withoutServerErrorRetries, nt as isTerminalDbWaitStatus, ot as protectionFlipKey, qt as markCreatedBeforeFailure, t as clearOnUpdateRemoval, u as reportCreatedResource } from "./update-removal-BjJh8h9m.js";
4
4
  import { d as ambientRegion } from "./aws-client-defaults-DP5k4Mfi.js";
5
- import { Ac as dbInstanceEngineChangeIsInPlace, ca as tagPlanWarning, ea as definedAttributes, hi as refuseRestoreFromItself, ia as planTagDiff, jt as enclosingDeadlineRemainingMs, ka as slowCcOperationTimeoutMs, oa as refuseMalformedDesiredTags, ql as acceptedCreateOnlyDropsOf, ta as stringifyIfAssigned, ua as markDeleteStarted, xl as dynamicReferenceTokens } from "./deploy-engine-BB7LVmAG.js";
6
- import { a as associatedRoleList, c as canonicalAssociatedRoles, i as associatedRoleKey, l as isRoleCallNotAvailableRefusal, n as modifyDbInstanceWhenAvailable, o as associatedRolesNamed, r as associatedRoleArns, s as associatedRolesReadback, t as isModifyNotAvailableRefusal, u as planAssociatedRoleChanges } from "./db-instance-modify-retry-BwAEmSQH.js";
7
- import { a as refuseMalformedReplicaSource, c as replicaEngine, d as replicaSourceChange, f as replicaSourceOf, l as replicaModifyAfterCreateInput, m as withPreviousReplicaSource, n as isLiveReadReplica, o as refuseUnknownSourceRegion, p as sameReplicaSource, r as ownScopeOf, s as replicaCreateInput, t as describeReplicaSource, u as replicaNeedsModifyAfterCreate } from "./read-replica-c2dYFLKs.js";
5
+ import { Na as slowCcOperationTimeoutMs, Pc as dbInstanceEngineChangeIsInPlace, Xl as acceptedCreateOnlyDropsOf, _i as pointInTimeTemplateRefusal, aa as stringifyIfAssigned, ca as planTagDiff, fa as tagPlanWarning, gi as declaresInstancePointInTime, hi as POINT_IN_TIME_NO_SOURCE_REASON, ia as definedAttributes, jt as enclosingDeadlineRemainingMs, ma as markDeleteStarted, ua as refuseMalformedDesiredTags, vi as refuseRestoreFromItself, wl as dynamicReferenceTokens, yi as parseZonedTimestamp } from "./deploy-engine-BocT17az.js";
6
+ import { a as associatedRoleList, c as canonicalAssociatedRoles, i as associatedRoleKey, l as isRoleCallNotAvailableRefusal, n as modifyDbInstanceWhenAvailable, o as associatedRolesNamed, r as associatedRoleArns, s as associatedRolesReadback, t as isModifyNotAvailableRefusal, u as planAssociatedRoleChanges } from "./db-instance-modify-retry-CY94H9jp.js";
7
+ import { a as positive, c as refuseUnknownSourceRegion, d as replicaModifyAfterCreateInput, f as replicaNeedsModifyAfterCreate, g as withPreviousReplicaSource, h as sameReplicaSource, i as ownScopeOf, l as replicaCreateInput, m as replicaSourceOf, n as describeReplicaSource, p as replicaSourceChange, r as isLiveReadReplica, s as refuseMalformedReplicaSource, t as declared, u as replicaEngine } from "./read-replica-IoZoKlpg.js";
8
8
  import { DescribeSecurityGroupsCommand, EC2Client } from "@aws-sdk/client-ec2";
9
9
  import { isDeepStrictEqual } from "node:util";
10
- import { AddRoleToDBClusterCommand, AddRoleToDBInstanceCommand, AddTagsToResourceCommand, CreateDBClusterCommand, CreateDBInstanceCommand, CreateDBInstanceReadReplicaCommand, CreateDBSubnetGroupCommand, DeleteDBClusterCommand, DeleteDBInstanceCommand, DeleteDBSubnetGroupCommand, DescribeDBClusterAutomatedBackupsCommand, DescribeDBClusterSnapshotsCommand, DescribeDBClustersCommand, DescribeDBInstanceAutomatedBackupsCommand, DescribeDBInstancesCommand, DescribeDBSubnetGroupsCommand, DescribeGlobalClustersCommand, DisableHttpEndpointCommand, EnableHttpEndpointCommand, ListTagsForResourceCommand, ModifyDBClusterCommand, ModifyDBInstanceCommand, ModifyDBSubnetGroupCommand, PromoteReadReplicaCommand, RDSClient, RebootDBInstanceCommand, RemoveFromGlobalClusterCommand, RemoveRoleFromDBClusterCommand, RemoveRoleFromDBInstanceCommand, RemoveTagsFromResourceCommand, RestoreDBClusterFromSnapshotCommand, RestoreDBClusterToPointInTimeCommand, StartDBInstanceAutomatedBackupsReplicationCommand, StopDBInstanceAutomatedBackupsReplicationCommand } from "@aws-sdk/client-rds";
10
+ import { AddRoleToDBClusterCommand, AddRoleToDBInstanceCommand, AddTagsToResourceCommand, CreateDBClusterCommand, CreateDBInstanceCommand, CreateDBInstanceReadReplicaCommand, CreateDBSubnetGroupCommand, DeleteDBClusterCommand, DeleteDBInstanceCommand, DeleteDBSubnetGroupCommand, DescribeDBClusterAutomatedBackupsCommand, DescribeDBClusterSnapshotsCommand, DescribeDBClustersCommand, DescribeDBInstanceAutomatedBackupsCommand, DescribeDBInstancesCommand, DescribeDBSnapshotsCommand, DescribeDBSubnetGroupsCommand, DescribeGlobalClustersCommand, DisableHttpEndpointCommand, EnableHttpEndpointCommand, ListTagsForResourceCommand, ModifyDBClusterCommand, ModifyDBInstanceCommand, ModifyDBSubnetGroupCommand, PromoteReadReplicaCommand, RDSClient, RebootDBInstanceCommand, RemoveFromGlobalClusterCommand, RemoveRoleFromDBClusterCommand, RemoveRoleFromDBInstanceCommand, RemoveTagsFromResourceCommand, RestoreDBClusterFromSnapshotCommand, RestoreDBClusterToPointInTimeCommand, RestoreDBInstanceFromDBSnapshotCommand, RestoreDBInstanceToPointInTimeCommand, StartDBInstanceAutomatedBackupsReplicationCommand, StopDBInstanceAutomatedBackupsReplicationCommand } from "@aws-sdk/client-rds";
11
11
 
12
12
  // src/provisioning/providers/rds/shared.ts
13
13
  const RDS_DELETE_WAIT_MS = Math.max(18e5, slowCcOperationTimeoutMs("AWS::RDS::DBCluster", "DELETE"), slowCcOperationTimeoutMs("AWS::RDS::DBInstance", "DELETE"));
@@ -25,6 +25,10 @@ function readableGlobalClusterId(value) {
25
25
  return value == null || typeof value === "string";
26
26
  }
27
27
  const usableGlobalClusterId = (value) => typeof value === "string";
28
+ function replicationSourceOf(properties) {
29
+ const value = properties?.["ReplicationSourceIdentifier"];
30
+ return typeof value === "string" && value.trim() !== "" ? value : void 0;
31
+ }
28
32
  const GLOBAL_CLUSTER_CHANGE_REFUSED = `GlobalClusterIdentifier cannot be added or changed on an existing DB cluster unless the cluster is already a member of that global cluster (CloudFormation's update handler fails it as "Resource is immutable"). To join a different global cluster, replace the cluster, for example with a new DBClusterIdentifier`;
29
33
  const HTTP_ENDPOINT_BUSY_FAULTS = /* @__PURE__ */ new Set(["InvalidResourceStateFault", "InvalidDBClusterStateFault"]);
30
34
  const TRANSIENT_DETACH_FAULTS = /* @__PURE__ */ new Set([
@@ -650,7 +654,8 @@ function clusterCreateScalarMembers(properties) {
650
654
  ...engineLifecycleSupportOf(properties) !== void 0 && { EngineLifecycleSupport: engineLifecycleSupportOf(properties) },
651
655
  ...properties["MasterUserAuthenticationType"] != null && { MasterUserAuthenticationType: properties["MasterUserAuthenticationType"] },
652
656
  ...typeof backtrackWindowValue(properties["BacktrackWindow"]) === "number" && { BacktrackWindow: backtrackWindowValue(properties["BacktrackWindow"]) },
653
- ...typeof localWriteForwardingFlag(properties["EnableLocalWriteForwarding"]) === "boolean" && { EnableLocalWriteForwarding: localWriteForwardingFlag(properties["EnableLocalWriteForwarding"]) }
657
+ ...typeof localWriteForwardingFlag(properties["EnableLocalWriteForwarding"]) === "boolean" && { EnableLocalWriteForwarding: localWriteForwardingFlag(properties["EnableLocalWriteForwarding"]) },
658
+ ...typeof globalWriteForwardingFlag(properties["EnableGlobalWriteForwarding"]) === "boolean" && { EnableGlobalWriteForwarding: globalWriteForwardingFlag(properties["EnableGlobalWriteForwarding"]) }
654
659
  };
655
660
  }
656
661
  function clusterModifyScalarMembers(properties, previousProperties, context) {
@@ -665,6 +670,8 @@ function clusterModifyScalarMembers(properties, previousProperties, context) {
665
670
  if (typeof backtrackWindow === "number" && changed("BacktrackWindow")) members.BacktrackWindow = backtrackWindow;
666
671
  const localWriteForwarding = localWriteForwardingToSend(properties, previousProperties, context);
667
672
  if (typeof localWriteForwarding === "boolean") members.EnableLocalWriteForwarding = localWriteForwarding;
673
+ const globalWriteForwarding = globalWriteForwardingFlag(properties["EnableGlobalWriteForwarding"]);
674
+ if (typeof globalWriteForwarding === "boolean" && changed("EnableGlobalWriteForwarding")) members.EnableGlobalWriteForwarding = globalWriteForwarding;
668
675
  return members;
669
676
  }
670
677
  function backtrackWindowValue(value) {
@@ -689,6 +696,14 @@ function localWriteForwardingApplied(cluster, enabled) {
689
696
  if (status === "enabling" || status === "disabling") return false;
690
697
  return (status === "requested" || status === "enabled") === enabled;
691
698
  }
699
+ function globalWriteForwardingFlag(value) {
700
+ return httpEndpointFlag(value);
701
+ }
702
+ function globalWriteForwardingApplied(cluster) {
703
+ if (cluster.GlobalWriteForwardingRequested !== true) return true;
704
+ const status = cluster.GlobalWriteForwardingStatus;
705
+ return status !== "enabling" && status !== "disabling";
706
+ }
692
707
  function httpEndpointFlag(value) {
693
708
  if (value == null) return void 0;
694
709
  if (value === true || value === "true") return true;
@@ -733,6 +748,7 @@ const usableHttpEndpoint = (value) => typeof httpEndpointFlag(value) === "boolea
733
748
  const usableRetentionPeriod = (value) => typeof retentionPeriodValue(value) === "number";
734
749
  const usableBacktrackWindow = (value) => typeof backtrackWindowValue(value) === "number";
735
750
  const usableLocalWriteForwarding = (value) => typeof localWriteForwardingFlag(value) === "boolean";
751
+ const usableGlobalWriteForwarding = (value) => typeof globalWriteForwardingFlag(value) === "boolean";
736
752
  const usableAvailabilityZones = (value) => value == null || Array.isArray(value) && value.every((zone) => typeof zone === "string" && zone.trim() !== "");
737
753
  function clusterEngineVersionChanged(properties, previousProperties, context) {
738
754
  if (context?.replayingState === true) return false;
@@ -839,33 +855,6 @@ function restoreCallName(restore) {
839
855
  if (restore === void 0) return "CreateDBCluster";
840
856
  return restore.kind === "snapshot" ? "RestoreDBClusterFromSnapshot" : "RestoreDBClusterToPointInTime";
841
857
  }
842
- const ZONED_DATE_TIME = /^(\d{4})-(\d{2})-(\d{2})[Tt](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,9}))?)?(?:[Zz]|([+-])(\d{2})(?::(\d{2})(?::(\d{2}))?)?)(?:\[[^\]]+\])?$/;
843
- function parseZonedTimestamp(text) {
844
- const match = ZONED_DATE_TIME.exec(text);
845
- if (match === null) return void 0;
846
- const n = (i) => match[i] === void 0 ? 0 : Number(match[i]);
847
- const [year, month, day, hour, minute, second] = [
848
- n(1),
849
- n(2),
850
- n(3),
851
- n(4),
852
- n(5),
853
- n(6)
854
- ];
855
- const [offsetHours, offsetMinutes, offsetSeconds] = [
856
- n(9),
857
- n(10),
858
- n(11)
859
- ];
860
- if (month < 1 || month > 12 || hour > 23 || minute > 59 || second > 59) return void 0;
861
- if (offsetMinutes > 59 || offsetSeconds > 59) return void 0;
862
- if (offsetHours * 3600 + offsetMinutes * 60 + offsetSeconds > 64800) return void 0;
863
- if (day < 1 || new Date(Date.UTC(year, month - 1, day)).getUTCDate() !== day) return void 0;
864
- const millis = Number((match[7] ?? "").padEnd(3, "0").slice(0, 3));
865
- const offsetMs = (match[8] === "-" ? -1 : 1) * (offsetHours * 3600 + offsetMinutes * 60 + offsetSeconds) * 1e3;
866
- const date = new Date(Date.UTC(year, month - 1, day, hour, minute, second, millis) - offsetMs);
867
- return Number.isNaN(date.getTime()) ? void 0 : date;
868
- }
869
858
  function readClusterRestore(properties, resourceType, logicalId) {
870
859
  const refuse = (reason) => {
871
860
  throw markNonRetryable(new ProvisioningError(safeMsg`${resourceType} ${logicalId}: ${reason}, as CloudFormation requires; nothing was changed.`, resourceType, logicalId));
@@ -933,7 +922,8 @@ function unusedRestoreKeys(properties, restore) {
933
922
  "GlobalClusterIdentifier",
934
923
  "WithExpressConfiguration",
935
924
  "ClusterScalabilityType",
936
- "MasterUserAuthenticationType"
925
+ "MasterUserAuthenticationType",
926
+ "ReplicationSourceIdentifier"
937
927
  ];
938
928
  return (restore === void 0 ? pointInTimeKeys : restore.kind === "snapshot" ? [...restoreUnused, ...pointInTimeKeys] : [
939
929
  "AvailabilityZones",
@@ -1097,7 +1087,7 @@ function limitlessRestoreMembers(properties) {
1097
1087
  function definedMembers(members) {
1098
1088
  return Object.fromEntries(Object.entries(members).filter(([, value]) => value !== void 0));
1099
1089
  }
1100
- function pointInTimeRestoreInput(properties, restore, dbClusterIdentifier, tags, logExports, limitless) {
1090
+ function pointInTimeRestoreInput$1(properties, restore, dbClusterIdentifier, tags, logExports, limitless) {
1101
1091
  return definedMembers({
1102
1092
  ...sharedRestoreMembers(properties, tags, logExports),
1103
1093
  DBClusterIdentifier: dbClusterIdentifier,
@@ -1108,7 +1098,7 @@ function pointInTimeRestoreInput(properties, restore, dbClusterIdentifier, tags,
1108
1098
  ...limitless && limitlessRestoreMembers(properties)
1109
1099
  });
1110
1100
  }
1111
- function snapshotRestoreInput(properties, restore, dbClusterIdentifier, tags, logExports, availabilityZones, limitless) {
1101
+ function snapshotRestoreInput$1(properties, restore, dbClusterIdentifier, tags, logExports, availabilityZones, limitless) {
1112
1102
  const string = (key) => properties[key] != null ? properties[key] : void 0;
1113
1103
  const boolean = (key) => properties[key] != null ? properties[key] : void 0;
1114
1104
  return definedMembers({
@@ -1129,7 +1119,7 @@ function snapshotRestoreInput(properties, restore, dbClusterIdentifier, tags, lo
1129
1119
  }
1130
1120
  async function sendClusterRestore(properties, restore, call) {
1131
1121
  const { dbClusterIdentifier, tags, logExports, availabilityZones, limitless } = call;
1132
- return restore.kind === "snapshot" ? this.getCreateClient().send(new RestoreDBClusterFromSnapshotCommand(snapshotRestoreInput(properties, restore, dbClusterIdentifier, tags, logExports, availabilityZones, limitless))) : this.getCreateClient().send(new RestoreDBClusterToPointInTimeCommand(pointInTimeRestoreInput(properties, restore, dbClusterIdentifier, tags, logExports, limitless)));
1122
+ return restore.kind === "snapshot" ? this.getCreateClient().send(new RestoreDBClusterFromSnapshotCommand(snapshotRestoreInput$1(properties, restore, dbClusterIdentifier, tags, logExports, availabilityZones, limitless))) : this.getCreateClient().send(new RestoreDBClusterToPointInTimeCommand(pointInTimeRestoreInput$1(properties, restore, dbClusterIdentifier, tags, logExports, limitless)));
1133
1123
  }
1134
1124
  const DEFAULT_BACKUP_RETENTION_PERIOD = 1;
1135
1125
  function restoreFollowUp(properties, logExports, limitless) {
@@ -1209,15 +1199,19 @@ async function createDBCluster(logicalId, resourceType, properties, mask, replay
1209
1199
  }
1210
1200
  const backtrackSkipped = backtrackWindowValue(properties["BacktrackWindow"]) === "malformed";
1211
1201
  const forwardingSkipped = localWriteForwardingFlag(properties["EnableLocalWriteForwarding"]) === "malformed";
1202
+ const globalForwardingSkipped = globalWriteForwardingFlag(properties["EnableGlobalWriteForwarding"]) === "malformed";
1212
1203
  const rawAvailabilityZones = properties["AvailabilityZones"];
1213
1204
  const availabilityZonesSkipped = !usableAvailabilityZones(rawAvailabilityZones);
1214
1205
  const availabilityZones = rawAvailabilityZones != null && !availabilityZonesSkipped ? rawAvailabilityZones : void 0;
1215
1206
  const globalClusterSkipped = !readableGlobalClusterId(properties["GlobalClusterIdentifier"]);
1216
1207
  const globalClusterId = globalClusterSkipped ? void 0 : recordedGlobalClusterIdentifier(properties);
1208
+ refuseUnknownSourceRegion(properties, resourceType, logicalId, replaying, (message) => this.logger.warn(message));
1217
1209
  const expressFlag = expressConfigurationFlag(properties["WithExpressConfiguration"]);
1218
1210
  const expressSkipped = expressFlag === "malformed";
1219
1211
  const restore = readClusterRestore(properties, resourceType, logicalId);
1220
1212
  const express = expressFlag === true && restore === void 0;
1213
+ const replicationSourceSkipped = restore === void 0 && !readableGlobalClusterId(properties["ReplicationSourceIdentifier"]);
1214
+ const replicationSource = restore === void 0 && !replicationSourceSkipped ? replicationSourceOf(properties) : void 0;
1221
1215
  const unused = unusedRestoreKeys(properties, restore);
1222
1216
  if (unused.length > 0) this.logger.warn(safeMsg`DBCluster ${logicalId}: this ${restore === void 0 ? "create" : `${restore.kind} restore`} does not apply ${unused.join(", ")}, as in CloudFormation.`);
1223
1217
  const classSkipped = malformedInstanceClass(properties["DBClusterInstanceClass"]);
@@ -1237,6 +1231,18 @@ async function createDBCluster(logicalId, resourceType, properties, mask, replay
1237
1231
  "true or false",
1238
1232
  "write forwarding off"
1239
1233
  ],
1234
+ [
1235
+ globalForwardingSkipped,
1236
+ "EnableGlobalWriteForwarding",
1237
+ "true or false",
1238
+ "global write forwarding off"
1239
+ ],
1240
+ [
1241
+ replicationSourceSkipped,
1242
+ "ReplicationSourceIdentifier",
1243
+ "a string",
1244
+ "no replication source (not a read replica)"
1245
+ ],
1240
1246
  [
1241
1247
  globalClusterSkipped,
1242
1248
  "GlobalClusterIdentifier",
@@ -1291,6 +1297,8 @@ async function createDBCluster(logicalId, resourceType, properties, mask, replay
1291
1297
  ...retentionSkipped ? ["PerformanceInsightsRetentionPeriod"] : [],
1292
1298
  ...backtrackSkipped ? ["BacktrackWindow"] : [],
1293
1299
  ...forwardingSkipped ? ["EnableLocalWriteForwarding"] : [],
1300
+ ...globalForwardingSkipped ? ["EnableGlobalWriteForwarding"] : [],
1301
+ ...replicationSourceSkipped ? ["ReplicationSourceIdentifier"] : [],
1294
1302
  ...availabilityZonesSkipped ? ["AvailabilityZones"] : [],
1295
1303
  ...globalClusterSkipped ? ["GlobalClusterIdentifier"] : [],
1296
1304
  ...expressSkipped ? ["WithExpressConfiguration"] : [],
@@ -1360,6 +1368,7 @@ async function createDBCluster(logicalId, resourceType, properties, mask, replay
1360
1368
  ...properties["EngineMode"] != null && { EngineMode: properties["EngineMode"] },
1361
1369
  ...availabilityZones !== void 0 && availabilityZones.length > 0 && { AvailabilityZones: availabilityZones },
1362
1370
  ...globalClusterId !== void 0 && { GlobalClusterIdentifier: globalClusterId },
1371
+ ...replicationSource !== void 0 && { ReplicationSourceIdentifier: replicationSource },
1363
1372
  ...expressFlag !== void 0 && !expressSkipped && { WithExpressConfiguration: express },
1364
1373
  ...tags.length > 0 && { Tags: tags }
1365
1374
  })));
@@ -1386,8 +1395,9 @@ async function createDBCluster(logicalId, resourceType, properties, mask, replay
1386
1395
  }
1387
1396
  }
1388
1397
  if (process.env["CDKD_NO_WAIT"] !== "true") {
1389
- await this.waitForClusterAvailable(logicalId, dbClusterIdentifier, restore === void 0 ? void 0 : restoreWaitMs(), restore === void 0 ? void 0 : "applying the restored cluster settings");
1398
+ await this.waitForClusterAvailable(logicalId, dbClusterIdentifier, restore === void 0 && replicationSource === void 0 ? void 0 : restoreWaitMs(), restore !== void 0 ? "applying the restored cluster settings" : replicationSource !== void 0 ? "replicating from its source" : void 0);
1390
1399
  if (localWriteForwardingFlag(properties["EnableLocalWriteForwarding"]) === true) await this.waitForClusterState(logicalId, dbClusterIdentifier, (cluster) => localWriteForwardingApplied(cluster, true), "local write forwarding setting");
1400
+ if (globalWriteForwardingFlag(properties["EnableGlobalWriteForwarding"]) === true) await this.waitForClusterState(logicalId, dbClusterIdentifier, globalWriteForwardingApplied, "global write forwarding setting");
1391
1401
  if (express) await this.waitForInstanceAvailable(logicalId, expressWriterIdentifier(dbClusterIdentifier));
1392
1402
  }
1393
1403
  if (roles !== "skipped") try {
@@ -1542,6 +1552,12 @@ async function updateDBCluster(logicalId, physicalId, resourceType, properties,
1542
1552
  "true or false",
1543
1553
  usableLocalWriteForwarding
1544
1554
  ],
1555
+ [
1556
+ globalWriteForwardingFlag(properties["EnableGlobalWriteForwarding"]) === "malformed",
1557
+ "EnableGlobalWriteForwarding",
1558
+ "true or false",
1559
+ usableGlobalWriteForwarding
1560
+ ],
1545
1561
  [
1546
1562
  malformedInstanceClass(properties["DBClusterInstanceClass"]),
1547
1563
  "DBClusterInstanceClass",
@@ -1576,6 +1592,7 @@ async function updateDBCluster(logicalId, physicalId, resourceType, properties,
1576
1592
  this.logger.warn(safeMsg`DBCluster ${logicalId}: drift --revert does not turn local write forwarding (EnableLocalWriteForwarding) back on, because the template does not declare EnableLocalWriteForwarding: true; declare it and deploy, or turn it on with aws rds modify-db-cluster --enable-local-write-forwarding`);
1577
1593
  skippedKeys.push(["EnableLocalWriteForwarding", usableLocalWriteForwarding]);
1578
1594
  }
1595
+ if (context?.replayingState !== true && context?.desiredFromAwsReadback !== true && readableGlobalClusterId(properties["ReplicationSourceIdentifier"]) && readableGlobalClusterId(previousProperties["ReplicationSourceIdentifier"]) && replicationSourceOf(properties) !== replicationSourceOf(previousProperties)) this.logger.warn(safeMsg`DBCluster ${logicalId}: an added, changed or removed ReplicationSourceIdentifier is not applied to the existing cluster, as in CloudFormation (ModifyDBCluster has no such member); to stop replicating, promote the cluster with aws rds promote-read-replica-db-cluster`);
1579
1596
  let detachedFrom;
1580
1597
  try {
1581
1598
  const globalClusterPlan = await planGlobalClusterUpdate.call(this, physicalId, properties, previousProperties, resourceType, logicalId, context);
@@ -1656,6 +1673,8 @@ async function updateDBCluster(logicalId, physicalId, resourceType, properties,
1656
1673
  if (!noWait && logExportConfig !== void 0) await this.waitForClusterState(logicalId, physicalId, (cluster) => logExportsApplied(logExportConfig, cluster.EnabledCloudwatchLogsExports, cluster.PendingModifiedValues?.PendingCloudwatchLogsExports), "CloudWatch Logs exports");
1657
1674
  const forwardingSent = scalarMembers.EnableLocalWriteForwarding;
1658
1675
  if (!noWait && forwardingSent !== void 0) await this.waitForClusterState(logicalId, physicalId, (cluster) => localWriteForwardingApplied(cluster, forwardingSent), "local write forwarding setting");
1676
+ const globalForwardingSent = scalarMembers.EnableGlobalWriteForwarding;
1677
+ if (!noWait && globalForwardingSent !== void 0) await this.waitForClusterState(logicalId, physicalId, globalWriteForwardingApplied, "global write forwarding setting");
1659
1678
  const backtrackSent = scalarMembers.BacktrackWindow;
1660
1679
  if (!noWait && backtrackSent !== void 0) await this.waitForClusterState(logicalId, physicalId, (cluster) => cluster.BacktrackWindow === void 0 || cluster.BacktrackWindow === backtrackSent, "backtrack window");
1661
1680
  if (!noWait && Object.keys(multiAzMembers).length > 0) await this.waitForClusterState(logicalId, physicalId, multiAzAppliedProbe(multiAzMembers, process.env["CDKD_FULL_WAIT"] === "true"), "instance class or storage change", slowCcOperationTimeoutMs("AWS::RDS::DBCluster", "UPDATE"));
@@ -2438,6 +2457,348 @@ function withDeclaredVolumeMembers(baseline, aws) {
2438
2457
  } : aws;
2439
2458
  }
2440
2459
 
2460
+ // src/provisioning/providers/rds/instance-restore.ts
2461
+ const SNAPSHOT_RESTORE_KEYS = ["DBSnapshotIdentifier", "DBClusterSnapshotIdentifier"];
2462
+ function readInstanceSnapshotRestore(properties, resourceType, logicalId) {
2463
+ const read = (key) => {
2464
+ const value = properties[key];
2465
+ if (value == null || value === "") return void 0;
2466
+ if (typeof value === "string") return value;
2467
+ throw markNonRetryable(new ProvisioningError(`${resourceType} ${logicalId}: ${key} must be a string (the snapshot's identifier or ARN); nothing was changed.`, resourceType, logicalId));
2468
+ };
2469
+ const dbSnapshotIdentifier = read("DBSnapshotIdentifier");
2470
+ const dbClusterSnapshotIdentifier = read("DBClusterSnapshotIdentifier");
2471
+ if (dbSnapshotIdentifier === void 0 && dbClusterSnapshotIdentifier === void 0) return;
2472
+ return {
2473
+ dbSnapshotIdentifier,
2474
+ dbClusterSnapshotIdentifier
2475
+ };
2476
+ }
2477
+ function declaredSnapshotKeys(properties) {
2478
+ return SNAPSHOT_RESTORE_KEYS.filter((key) => {
2479
+ const value = properties[key];
2480
+ return value != null && value !== "";
2481
+ });
2482
+ }
2483
+ const MIRRORING_SQL_SERVER_ENGINES = /* @__PURE__ */ new Set(["sqlserver-ee", "sqlserver-se"]);
2484
+ async function readSnapshotRestoreSource(properties, restore, resourceType, logicalId, mask) {
2485
+ const declaredEngine = properties["Engine"];
2486
+ let engine = typeof declaredEngine === "string" && declaredEngine !== "" ? declaredEngine : void 0;
2487
+ const declaredMultiAZ = properties["MultiAZ"];
2488
+ let multiAZ = declaredMultiAZ == null ? void 0 : coerceCfnBoolean(declaredMultiAZ);
2489
+ const wrapReadError = (what, error) => this.wrapCaughtError(mask, error, (text) => new ProvisioningError(`Failed to create DBInstance ${logicalId}: reading the ${what} failed, so nothing was changed: ${text}`, resourceType, logicalId, void 0, error instanceof Error ? error : void 0));
2490
+ const refuseNotFound = (key, value, noun) => {
2491
+ throw markNonRetryable(new ProvisioningError((mask ?? ((text) => text))(safeMsg`${resourceType} ${logicalId}: ${key} ${value} does not name a ${noun} this account can read, so there is nothing to restore; nothing was changed.`), resourceType, logicalId));
2492
+ };
2493
+ const snapshot = restore.dbSnapshotIdentifier;
2494
+ if (snapshot !== void 0 && (engine === void 0 || multiAZ !== true)) {
2495
+ let snapshotEngine;
2496
+ let found = false;
2497
+ try {
2498
+ const described = (await this.getClient().send(new DescribeDBSnapshotsCommand({ DBSnapshotIdentifier: snapshot }))).DBSnapshots?.[0];
2499
+ found = described !== void 0;
2500
+ snapshotEngine = described?.Engine;
2501
+ } catch (error) {
2502
+ if (!this.isNotFoundError(error, "DBSnapshotNotFoundFault")) throw wrapReadError("restore snapshot", error);
2503
+ }
2504
+ if (!found) refuseNotFound("DBSnapshotIdentifier", snapshot, "DB snapshot");
2505
+ engine ??= snapshotEngine;
2506
+ if (declaredMultiAZ == null) multiAZ = snapshotEngine !== void 0 && MIRRORING_SQL_SERVER_ENGINES.has(snapshotEngine) ? void 0 : false;
2507
+ } else if (engine === void 0 && snapshot === void 0) {
2508
+ const clusterSnapshot = restore.dbClusterSnapshotIdentifier;
2509
+ let found = false;
2510
+ try {
2511
+ const described = (await this.getClient().send(new DescribeDBClusterSnapshotsCommand({ DBClusterSnapshotIdentifier: clusterSnapshot }))).DBClusterSnapshots?.[0];
2512
+ found = described !== void 0;
2513
+ engine = described?.Engine;
2514
+ } catch (error) {
2515
+ if (!this.isNotFoundError(error, "DBClusterSnapshotNotFoundFault")) throw wrapReadError("restore cluster snapshot", error);
2516
+ }
2517
+ if (!found) refuseNotFound("DBClusterSnapshotIdentifier", clusterSnapshot, "Multi-AZ DB cluster snapshot");
2518
+ }
2519
+ return {
2520
+ engine,
2521
+ multiAZ
2522
+ };
2523
+ }
2524
+ function isSqlServer$1(engine) {
2525
+ return engine === void 0 || engine.includes("sqlserver");
2526
+ }
2527
+ function isOracleCdbEngine$1(engine) {
2528
+ return engine === "oracle-ee-cdb" || engine === "oracle-se2-cdb";
2529
+ }
2530
+ function snapshotRestoreInput(properties, parts) {
2531
+ const p = properties;
2532
+ const engine = parts.source.engine;
2533
+ const vpcSecurityGroups = p["VPCSecurityGroups"];
2534
+ const lifecycle = engineLifecycleSupportOf(p);
2535
+ return {
2536
+ DBInstanceIdentifier: parts.identifier,
2537
+ ...parts.restore.dbSnapshotIdentifier !== void 0 && { DBSnapshotIdentifier: parts.restore.dbSnapshotIdentifier },
2538
+ ...parts.restore.dbClusterSnapshotIdentifier !== void 0 && { DBClusterSnapshotIdentifier: parts.restore.dbClusterSnapshotIdentifier },
2539
+ ...p["AutoMinorVersionUpgrade"] != null && { AutoMinorVersionUpgrade: p["AutoMinorVersionUpgrade"] },
2540
+ ...p["AvailabilityZone"] != null && { AvailabilityZone: p["AvailabilityZone"] },
2541
+ ...p["CopyTagsToSnapshot"] != null && { CopyTagsToSnapshot: p["CopyTagsToSnapshot"] },
2542
+ ...p["DBInstanceClass"] != null && { DBInstanceClass: p["DBInstanceClass"] },
2543
+ ...p["DBName"] != null && { DBName: p["DBName"] },
2544
+ ...p["DBParameterGroupName"] != null && { DBParameterGroupName: p["DBParameterGroupName"] },
2545
+ ...p["DBSubnetGroupName"] != null && { DBSubnetGroupName: p["DBSubnetGroupName"] },
2546
+ ...p["DeletionProtection"] != null && { DeletionProtection: p["DeletionProtection"] },
2547
+ ...p["DedicatedLogVolume"] != null && { DedicatedLogVolume: p["DedicatedLogVolume"] },
2548
+ ...parts.logExports !== void 0 && parts.logExports.length > 0 && { EnableCloudwatchLogsExports: parts.logExports },
2549
+ ...p["EnableIAMDatabaseAuthentication"] != null && { EnableIAMDatabaseAuthentication: p["EnableIAMDatabaseAuthentication"] },
2550
+ ...engine !== void 0 && !isOracleCdbEngine$1(engine) && { Engine: engine },
2551
+ ...p["LicenseModel"] != null && { LicenseModel: p["LicenseModel"] },
2552
+ ...parts.source.multiAZ !== void 0 && { MultiAZ: parts.source.multiAZ },
2553
+ ...p["NetworkType"] != null && { NetworkType: p["NetworkType"] },
2554
+ ...p["OptionGroupName"] != null && { OptionGroupName: p["OptionGroupName"] },
2555
+ ...p["Port"] != null && { Port: Number(p["Port"]) },
2556
+ ...parts.processor.features !== void 0 && { ProcessorFeatures: parts.processor.features },
2557
+ ...parts.processor.useDefault !== void 0 && { UseDefaultProcessorFeatures: parts.processor.useDefault },
2558
+ ...p["PubliclyAccessible"] != null && { PubliclyAccessible: p["PubliclyAccessible"] },
2559
+ ...Array.isArray(vpcSecurityGroups) && vpcSecurityGroups.length > 0 && { VpcSecurityGroupIds: vpcSecurityGroups },
2560
+ ...lifecycle !== void 0 && { EngineLifecycleSupport: lifecycle },
2561
+ ...!isSqlServer$1(engine) && {
2562
+ ...p["AllocatedStorage"] != null && { AllocatedStorage: Number(p["AllocatedStorage"]) },
2563
+ ...p["Iops"] != null && { Iops: Number(p["Iops"]) },
2564
+ ...p["StorageThroughput"] != null && { StorageThroughput: Number(p["StorageThroughput"]) },
2565
+ ...p["StorageType"] != null && { StorageType: p["StorageType"] }
2566
+ },
2567
+ ...parts.tags.length > 0 && { Tags: parts.tags }
2568
+ };
2569
+ }
2570
+ function unusedSnapshotRestoreKeys(properties) {
2571
+ return [
2572
+ "KmsKeyId",
2573
+ "CharacterSetName",
2574
+ "NcharCharacterSetName",
2575
+ "Timezone",
2576
+ "AdditionalStorageVolumes",
2577
+ "DBClusterIdentifier",
2578
+ "PromotionTier",
2579
+ "MasterUserAuthenticationType"
2580
+ ].filter((key) => {
2581
+ const value = properties[key];
2582
+ if (value == null || value === "") return false;
2583
+ return !(Array.isArray(value) && value.length === 0);
2584
+ });
2585
+ }
2586
+ function followUpOnlyKeys(properties, kind) {
2587
+ return [
2588
+ ...kind === "pitr" ? [] : ["MaxAllocatedStorage"],
2589
+ "AllowMajorVersionUpgrade",
2590
+ "MasterUserSecret",
2591
+ ...kind !== "replica" ? [
2592
+ "DatabaseInsightsMode",
2593
+ "PerformanceInsightsRetentionPeriod",
2594
+ "PerformanceInsightsKMSKeyId"
2595
+ ] : []
2596
+ ].filter((key) => {
2597
+ const value = properties[key];
2598
+ if (key === "MaxAllocatedStorage" || key === "PerformanceInsightsRetentionPeriod") return positive(value);
2599
+ if (key === "MasterUserSecret") return declared(value?.KmsKeyId);
2600
+ return declared(value) && value !== false && value !== "false";
2601
+ });
2602
+ }
2603
+ function snapshotRestoredDifferences(properties, instance) {
2604
+ const differences = [];
2605
+ const username = properties["MasterUsername"];
2606
+ if (typeof username === "string" && username !== "" && instance.MasterUsername !== void 0 && username !== instance.MasterUsername) differences.push("MasterUsername");
2607
+ const encrypted = properties["StorageEncrypted"] == null ? void 0 : coerceCfnBoolean(properties["StorageEncrypted"]);
2608
+ if (encrypted !== void 0 && instance.StorageEncrypted !== void 0 && encrypted !== instance.StorageEncrypted) differences.push("StorageEncrypted");
2609
+ return differences;
2610
+ }
2611
+ function createTimeKeySet(key, value) {
2612
+ if (key === "UseLatestRestorableTime") return coerceCfnBoolean(value) === true;
2613
+ return value != null && value !== "";
2614
+ }
2615
+ function sameCreateTimeValue(key, a, b) {
2616
+ if (a === b) return true;
2617
+ return key === "UseLatestRestorableTime" && coerceCfnBoolean(a) === coerceCfnBoolean(b);
2618
+ }
2619
+ function changedCreateTimeKeys(keys, properties, previousProperties, changedProperties, noEchoOnly) {
2620
+ return keys.filter((key) => {
2621
+ const desired = properties[key];
2622
+ if (!createTimeKeySet(key, desired)) return false;
2623
+ if (sameCreateTimeValue(key, desired, previousProperties[key])) return false;
2624
+ if (noEchoOnly?.has(key) === true) return false;
2625
+ if (changedProperties !== void 0) return changedProperties.has(key);
2626
+ return true;
2627
+ });
2628
+ }
2629
+ function unconfirmedCreateTimeKeys(keys, properties, previousProperties, noEchoOnly) {
2630
+ if (noEchoOnly === void 0) return [];
2631
+ return keys.filter((key) => {
2632
+ const desired = properties[key];
2633
+ if (!createTimeKeySet(key, desired)) return false;
2634
+ return !sameCreateTimeValue(key, desired, previousProperties[key]) && noEchoOnly.has(key);
2635
+ });
2636
+ }
2637
+
2638
+ // src/provisioning/providers/rds/instance-pitr.ts
2639
+ const POINT_IN_TIME_KEYS = [
2640
+ "RestoreTime",
2641
+ "UseLatestRestorableTime",
2642
+ "SourceDBInstanceAutomatedBackupsArn",
2643
+ "SourceDbiResourceId"
2644
+ ];
2645
+ function declaresPointInTimeRestore(properties) {
2646
+ return properties !== void 0 && declaresInstancePointInTime(properties);
2647
+ }
2648
+ function readInstancePointInTimeRestore(properties, resourceType, logicalId) {
2649
+ const refuse = (reason) => {
2650
+ throw markNonRetryable(new ProvisioningError(safeMsg`${resourceType} ${logicalId}: ${reason}, as CloudFormation requires; nothing was changed.`, resourceType, logicalId));
2651
+ };
2652
+ const reason = pointInTimeTemplateRefusal(properties);
2653
+ if (reason !== void 0 && reason !== "the template names no source to restore to a point in time from (SourceDBInstanceIdentifier, SourceDbiResourceId or SourceDBInstanceAutomatedBackupsArn), so cdkd cannot read its engine; declare Engine or a source, as CloudFormation requires (\"Cannot fetch the engine\")") return refuse(reason);
2654
+ const declaredTime = properties["RestoreTime"];
2655
+ const restoreTime = typeof declaredTime === "string" && declaredTime.trim() !== "" ? parseZonedTimestamp(declaredTime) : void 0;
2656
+ const useLatestRestorableTime = properties["UseLatestRestorableTime"] == null ? void 0 : coerceCfnBoolean(properties["UseLatestRestorableTime"]);
2657
+ const stringKey = (key) => {
2658
+ const value = properties[key];
2659
+ return typeof value === "string" && value !== "" ? value : void 0;
2660
+ };
2661
+ const sourceDBInstanceAutomatedBackupsArn = stringKey("SourceDBInstanceAutomatedBackupsArn");
2662
+ const sourceDbiResourceId = stringKey("SourceDbiResourceId");
2663
+ if (!declaresInstancePointInTime(properties)) return void 0;
2664
+ const source = properties["SourceDBInstanceIdentifier"];
2665
+ return {
2666
+ restoreTime,
2667
+ useLatestRestorableTime,
2668
+ sourceDBInstanceIdentifier: typeof source === "string" && source !== "" ? source : void 0,
2669
+ sourceDbiResourceId,
2670
+ sourceDBInstanceAutomatedBackupsArn
2671
+ };
2672
+ }
2673
+ async function pointInTimeRestoreEngine(properties, restore, resourceType, logicalId, mask) {
2674
+ const declaredEngine = properties["Engine"];
2675
+ if (typeof declaredEngine === "string" && declaredEngine !== "") return declaredEngine;
2676
+ const masked = mask ?? ((text) => text);
2677
+ const wrapReadError = (what, error) => this.wrapCaughtError(mask, error, (text) => new ProvisioningError(`Failed to create DBInstance ${logicalId}: reading the ${what} failed, so nothing was changed: ${text}`, resourceType, logicalId, void 0, error instanceof Error ? error : void 0));
2678
+ const refuseNotFound = (key, value, noun, why) => {
2679
+ throw markNonRetryable(new ProvisioningError(masked(why === void 0 ? safeMsg`${resourceType} ${logicalId}: ${key} ${value} does not name ${noun} this account can read, so there is nothing to restore; nothing was changed.` : safeMsg`${resourceType} ${logicalId}: ${key} ${value} ${why}; nothing was changed.`), resourceType, logicalId));
2680
+ };
2681
+ const read = async (what, notFoundFault, call) => {
2682
+ try {
2683
+ return await call();
2684
+ } catch (error) {
2685
+ if (this.isNotFoundError(error, notFoundFault)) return void 0;
2686
+ throw wrapReadError(what, error);
2687
+ }
2688
+ };
2689
+ if (restore.sourceDBInstanceIdentifier !== void 0) {
2690
+ const source = restore.sourceDBInstanceIdentifier;
2691
+ const instance = await read("restore source", "DBInstanceNotFoundFault", () => describeReplicaSource.call(this, source));
2692
+ if (instance === void 0) return refuseNotFound("SourceDBInstanceIdentifier", source, "a DB instance");
2693
+ return instance.Engine;
2694
+ }
2695
+ if (restore.sourceDbiResourceId !== void 0) {
2696
+ const resourceId = restore.sourceDbiResourceId;
2697
+ const instance = await read("restore source", "DBInstanceNotFoundFault", async () => {
2698
+ return (await this.getClient().send(new DescribeDBInstancesCommand({ Filters: [{
2699
+ Name: "dbi-resource-id",
2700
+ Values: [resourceId]
2701
+ }] }))).DBInstances?.[0];
2702
+ });
2703
+ if (instance === void 0) return refuseNotFound("SourceDbiResourceId", resourceId, "a DB instance", "names no live DB instance this account can read, so cdkd cannot read the engine to restore; declare Engine (a deleted instance's retained automated backups restore with it declared), as CloudFormation requires");
2704
+ return instance.Engine;
2705
+ }
2706
+ if (restore.sourceDBInstanceAutomatedBackupsArn !== void 0) {
2707
+ const arn = restore.sourceDBInstanceAutomatedBackupsArn;
2708
+ const backup = await read("restore automated backup", "DBInstanceAutomatedBackupNotFoundFault", async () => {
2709
+ return (await this.getClient().send(new DescribeDBInstanceAutomatedBackupsCommand({ DBInstanceAutomatedBackupsArn: arn }))).DBInstanceAutomatedBackups?.[0];
2710
+ });
2711
+ if (backup === void 0) return refuseNotFound("SourceDBInstanceAutomatedBackupsArn", arn, "an automated backup");
2712
+ return backup.Engine;
2713
+ }
2714
+ throw markNonRetryable(new ProvisioningError(safeMsg`${resourceType} ${logicalId}: ${POINT_IN_TIME_NO_SOURCE_REASON}. Nothing was changed.`, resourceType, logicalId));
2715
+ }
2716
+ function isSqlServer(engine) {
2717
+ return engine === void 0 || engine.includes("sqlserver");
2718
+ }
2719
+ function isOracleCdbEngine(engine) {
2720
+ return engine === "oracle-ee-cdb" || engine === "oracle-se2-cdb";
2721
+ }
2722
+ function pointInTimeRestoreInput(properties, parts) {
2723
+ const p = properties;
2724
+ const { restore, engine } = parts;
2725
+ const vpcSecurityGroups = p["VPCSecurityGroups"];
2726
+ const lifecycle = engineLifecycleSupportOf(p);
2727
+ return {
2728
+ TargetDBInstanceIdentifier: parts.identifier,
2729
+ ...restore.sourceDBInstanceIdentifier !== void 0 && { SourceDBInstanceIdentifier: restore.sourceDBInstanceIdentifier },
2730
+ ...restore.sourceDbiResourceId !== void 0 && { SourceDbiResourceId: restore.sourceDbiResourceId },
2731
+ ...restore.sourceDBInstanceAutomatedBackupsArn !== void 0 && { SourceDBInstanceAutomatedBackupsArn: restore.sourceDBInstanceAutomatedBackupsArn },
2732
+ ...restore.restoreTime !== void 0 && { RestoreTime: restore.restoreTime },
2733
+ ...restore.useLatestRestorableTime !== void 0 && { UseLatestRestorableTime: restore.useLatestRestorableTime },
2734
+ ...p["AutoMinorVersionUpgrade"] != null && { AutoMinorVersionUpgrade: p["AutoMinorVersionUpgrade"] },
2735
+ ...p["AvailabilityZone"] != null && { AvailabilityZone: p["AvailabilityZone"] },
2736
+ ...p["CopyTagsToSnapshot"] != null && { CopyTagsToSnapshot: p["CopyTagsToSnapshot"] },
2737
+ ...p["DBInstanceClass"] != null && { DBInstanceClass: p["DBInstanceClass"] },
2738
+ ...p["DBName"] != null && { DBName: p["DBName"] },
2739
+ ...p["DBParameterGroupName"] != null && { DBParameterGroupName: p["DBParameterGroupName"] },
2740
+ ...p["DBSubnetGroupName"] != null && { DBSubnetGroupName: p["DBSubnetGroupName"] },
2741
+ ...p["DedicatedLogVolume"] != null && { DedicatedLogVolume: p["DedicatedLogVolume"] },
2742
+ ...p["DeletionProtection"] != null && { DeletionProtection: p["DeletionProtection"] },
2743
+ ...parts.logExports !== void 0 && parts.logExports.length > 0 && { EnableCloudwatchLogsExports: parts.logExports },
2744
+ ...p["EnableIAMDatabaseAuthentication"] != null && { EnableIAMDatabaseAuthentication: p["EnableIAMDatabaseAuthentication"] },
2745
+ ...engine !== void 0 && !isOracleCdbEngine(engine) && { Engine: engine },
2746
+ ...p["LicenseModel"] != null && { LicenseModel: p["LicenseModel"] },
2747
+ ...p["MaxAllocatedStorage"] != null && { MaxAllocatedStorage: Number(p["MaxAllocatedStorage"]) },
2748
+ ...p["MultiAZ"] != null && { MultiAZ: p["MultiAZ"] },
2749
+ ...p["NetworkType"] != null && { NetworkType: p["NetworkType"] },
2750
+ ...p["OptionGroupName"] != null && { OptionGroupName: p["OptionGroupName"] },
2751
+ ...p["Port"] != null && { Port: Number(p["Port"]) },
2752
+ ...parts.processor.features !== void 0 && { ProcessorFeatures: parts.processor.features },
2753
+ ...parts.processor.useDefault !== void 0 && { UseDefaultProcessorFeatures: parts.processor.useDefault },
2754
+ ...p["PubliclyAccessible"] != null && { PubliclyAccessible: p["PubliclyAccessible"] },
2755
+ ...Array.isArray(vpcSecurityGroups) && vpcSecurityGroups.length > 0 && { VpcSecurityGroupIds: vpcSecurityGroups },
2756
+ ...lifecycle !== void 0 && { EngineLifecycleSupport: lifecycle },
2757
+ ...!isSqlServer(engine) && {
2758
+ ...p["AllocatedStorage"] != null && { AllocatedStorage: Number(p["AllocatedStorage"]) },
2759
+ ...p["Iops"] != null && { Iops: Number(p["Iops"]) },
2760
+ ...p["StorageThroughput"] != null && { StorageThroughput: Number(p["StorageThroughput"]) },
2761
+ ...p["StorageType"] != null && { StorageType: p["StorageType"] }
2762
+ },
2763
+ ...parts.tags.length > 0 && { Tags: parts.tags }
2764
+ };
2765
+ }
2766
+ function unusedPointInTimeRestoreKeys(properties) {
2767
+ return [
2768
+ "KmsKeyId",
2769
+ "CharacterSetName",
2770
+ "NcharCharacterSetName",
2771
+ "Timezone",
2772
+ "AdditionalStorageVolumes",
2773
+ "DBClusterIdentifier",
2774
+ "PromotionTier",
2775
+ "MasterUserAuthenticationType"
2776
+ ].filter((key) => {
2777
+ const value = properties[key];
2778
+ if (value == null || value === "") return false;
2779
+ return !(Array.isArray(value) && value.length === 0);
2780
+ });
2781
+ }
2782
+ async function automatedBackupResourceId(arn, expectedRegion) {
2783
+ if (!isAutomatedBackupsArn(arn)) return void 0;
2784
+ const arnRegion = arn.split(":")[3];
2785
+ if (arnRegion !== "" && arnRegion !== expectedRegion) return void 0;
2786
+ if (await this.getClient().config.region() !== expectedRegion) return void 0;
2787
+ let backups;
2788
+ try {
2789
+ backups = (await this.getClient().send(new DescribeDBInstanceAutomatedBackupsCommand({ DBInstanceAutomatedBackupsArn: arn }))).DBInstanceAutomatedBackups;
2790
+ } catch (error) {
2791
+ if (error?.name === "DBInstanceAutomatedBackupNotFoundFault") return RESOURCE_NOT_FOUND;
2792
+ throw error;
2793
+ }
2794
+ if (backups === void 0 || backups.length === 0) return RESOURCE_NOT_FOUND;
2795
+ const id = backups[0]?.DbiResourceId;
2796
+ return typeof id === "string" && id !== "" ? id : void 0;
2797
+ }
2798
+ function isAutomatedBackupsArn(value) {
2799
+ return /^arn:[^:]+:rds:[^:]*:[^:]*:auto-backup:.+$/.test(value);
2800
+ }
2801
+
2441
2802
  // src/provisioning/providers/rds/instance-create.ts
2442
2803
  async function createDBInstance(logicalId, resourceType, properties, mask, replaying = false) {
2443
2804
  this.logger.debug(`Creating DBInstance ${logicalId}`);
@@ -2449,8 +2810,12 @@ async function createDBInstance(logicalId, resourceType, properties, mask, repla
2449
2810
  const replication = backupReplicationPlan(properties, {}, resourceType, logicalId, void 0, replaying, (message) => this.logger.warn(message));
2450
2811
  refuseMalformedReplicaSource(properties, resourceType, logicalId);
2451
2812
  refuseUnknownSourceRegion(properties, resourceType, logicalId, replaying, (message) => this.logger.warn(message));
2452
- const replicaSource = replicaSourceOf(properties);
2813
+ const pointInTime = readInstancePointInTimeRestore(properties, resourceType, logicalId);
2814
+ const replicaSource = pointInTime === void 0 ? replicaSourceOf(properties) : void 0;
2815
+ const snapshotRestore = pointInTime === void 0 && replicaSource === void 0 ? readInstanceSnapshotRestore(properties, resourceType, logicalId) : void 0;
2816
+ if (snapshotRestore === void 0 && declaredSnapshotKeys(properties).length > 0) this.logger.warn(pointInTime !== void 0 ? safeMsg`DBInstance ${logicalId}: ${declaredSnapshotKeys(properties).join(", ")} not applied: a point-in-time key makes the create a restore to a point in time, which reads no snapshot, as in CloudFormation.` : safeMsg`DBInstance ${logicalId}: ${declaredSnapshotKeys(properties).join(", ")} not applied: SourceDBInstanceIdentifier makes the instance a read replica, which restores no snapshot, as in CloudFormation.`);
2453
2817
  const dbInstanceIdentifier = properties["DBInstanceIdentifier"] || generatedNameFor("AWS::RDS::DBInstance", logicalId);
2818
+ if (snapshotRestore !== void 0 || pointInTime !== void 0) refuseRestoreFromItself(resourceType, properties, dbInstanceIdentifier, logicalId, {});
2454
2819
  let instanceCreated = false;
2455
2820
  let createdResourceId;
2456
2821
  try {
@@ -2512,7 +2877,23 @@ async function createDBInstance(logicalId, resourceType, properties, mask, repla
2512
2877
  ...tags.length > 0 && { Tags: tags }
2513
2878
  });
2514
2879
  const replicaEngineName = replicaSource === void 0 ? void 0 : await replicaEngine.call(this, properties, replicaSource);
2515
- const response = replicaSource === void 0 ? await this.getCreateClient().send(standaloneCreate()) : await createReadReplicaWhenSourceAvailable.call(this, logicalId, replicaSource, new CreateDBInstanceReadReplicaCommand({
2880
+ const restoreSource = snapshotRestore === void 0 ? void 0 : await readSnapshotRestoreSource.call(this, properties, snapshotRestore, resourceType, logicalId, mask);
2881
+ const pointInTimeEngine = pointInTime === void 0 ? void 0 : await pointInTimeRestoreEngine.call(this, properties, pointInTime, resourceType, logicalId, mask);
2882
+ const response = pointInTime !== void 0 ? await this.getCreateClient().send(new RestoreDBInstanceToPointInTimeCommand(pointInTimeRestoreInput(properties, {
2883
+ identifier: dbInstanceIdentifier,
2884
+ restore: pointInTime,
2885
+ engine: pointInTimeEngine,
2886
+ tags,
2887
+ logExports,
2888
+ processor
2889
+ }))) : snapshotRestore !== void 0 && restoreSource !== void 0 ? await this.getCreateClient().send(new RestoreDBInstanceFromDBSnapshotCommand(snapshotRestoreInput(properties, {
2890
+ identifier: dbInstanceIdentifier,
2891
+ restore: snapshotRestore,
2892
+ source: restoreSource,
2893
+ tags,
2894
+ logExports,
2895
+ processor
2896
+ }))) : replicaSource === void 0 ? await this.getCreateClient().send(standaloneCreate()) : await createReadReplicaWhenSourceAvailable.call(this, logicalId, replicaSource, new CreateDBInstanceReadReplicaCommand({
2516
2897
  ...replicaCreateInput(properties, {
2517
2898
  identifier: dbInstanceIdentifier,
2518
2899
  source: replicaSource,
@@ -2529,11 +2910,23 @@ async function createDBInstance(logicalId, resourceType, properties, mask, repla
2529
2910
  createdResourceId = response.DBInstance?.DbiResourceId;
2530
2911
  reportCreatedResource(logicalId, resourceType, dbInstanceIdentifier, createdResourceId);
2531
2912
  const instance = response.DBInstance;
2532
- if (!instance) throw new Error(`${replicaSource === void 0 ? "CreateDBInstance" : "CreateDBInstanceReadReplica"} did not return DBInstance`);
2913
+ if (!instance) throw new Error(`${pointInTime !== void 0 ? "RestoreDBInstanceToPointInTime" : snapshotRestore !== void 0 ? "RestoreDBInstanceFromDBSnapshot" : replicaSource === void 0 ? "CreateDBInstance" : "CreateDBInstanceReadReplica"} did not return DBInstance`);
2914
+ if (snapshotRestore !== void 0) {
2915
+ const unused = [...unusedSnapshotRestoreKeys(properties), ...snapshotRestoredDifferences(properties, instance)];
2916
+ if (unused.length > 0) this.logger.warn(safeMsg`DBInstance ${logicalId}: ${unused.join(", ")} not applied: a restore from a snapshot takes them from the snapshot, as in CloudFormation.`);
2917
+ }
2918
+ if (pointInTime !== void 0) {
2919
+ const unused = [...unusedPointInTimeRestoreKeys(properties), ...snapshotRestoredDifferences(properties, instance)];
2920
+ if (unused.length > 0) this.logger.warn(safeMsg`DBInstance ${logicalId}: ${unused.join(", ")} not applied: a restore to a point in time takes them from its source, as in CloudFormation.`);
2921
+ }
2533
2922
  this.logger.debug(`Successfully created DBInstance ${logicalId}: ${dbInstanceIdentifier}`);
2534
- const modifyAfterCreate = replicaSource !== void 0 && replicaNeedsModifyAfterCreate(properties, replicaEngineName, instance.Engine);
2535
- if (process.env["CDKD_NO_WAIT"] !== "true" || modifyAfterCreate) await this.waitForInstanceAvailable(logicalId, dbInstanceIdentifier);
2536
- if (modifyAfterCreate) await modifyReplicaAfterCreate.call(this, logicalId, dbInstanceIdentifier, properties, replicaEngineName);
2923
+ const followUpEngine = replicaEngineName ?? restoreSource?.engine ?? pointInTimeEngine;
2924
+ const restored = snapshotRestore !== void 0 || pointInTime !== void 0;
2925
+ const modifyAfterCreate = (replicaSource !== void 0 || restored) && replicaNeedsModifyAfterCreate(properties, followUpEngine, instance.Engine);
2926
+ const unappliedFollowUp = modifyAfterCreate || replicaSource === void 0 && !restored ? [] : followUpOnlyKeys(properties, pointInTime !== void 0 ? "pitr" : snapshotRestore !== void 0 ? "restore" : "replica");
2927
+ if (unappliedFollowUp.length > 0) this.logger.warn(safeMsg`DBInstance ${logicalId}: ${unappliedFollowUp.join(", ")} not applied: only CloudFormation's after-create ModifyDBInstance carries them, and nothing else declared calls for it, as in CloudFormation.`);
2928
+ if (process.env["CDKD_NO_WAIT"] !== "true" || modifyAfterCreate || restored) await this.waitForInstanceAvailable(logicalId, dbInstanceIdentifier, restored ? restoreWaitMs() : void 0, restored ? "being restored" : void 0);
2929
+ if (modifyAfterCreate) await modifyReplicaAfterCreate.call(this, logicalId, dbInstanceIdentifier, properties, followUpEngine);
2537
2930
  try {
2538
2931
  if (roles !== "skipped") await this.applyAssociatedRoles("instance", logicalId, dbInstanceIdentifier, roles, [], mask, void 0);
2539
2932
  await applyBackupReplication.call(this, logicalId, dbInstanceIdentifier, replication);
@@ -2609,7 +3002,31 @@ async function updateDBInstance(logicalId, physicalId, resourceType, properties,
2609
3002
  }
2610
3003
  if (passwordCompanion?.kind === "missing") throw markNonRetryable(new ProvisioningError(passwordAuthenticationMissingText(resourceType, logicalId), resourceType, logicalId, physicalId));
2611
3004
  refuseMalformedReplicaSource(properties, resourceType, logicalId, physicalId);
2612
- const sourceChange = replicaSourceChange(properties, previousProperties);
3005
+ const sourceChange = declaresPointInTimeRestore(previousProperties) || declaresPointInTimeRestore(properties) ? "unchanged" : replicaSourceChange(properties, previousProperties);
3006
+ const restoreKeys = [
3007
+ ...SNAPSHOT_RESTORE_KEYS,
3008
+ ...POINT_IN_TIME_KEYS,
3009
+ ...declaresPointInTimeRestore(previousProperties) ? ["SourceDBInstanceIdentifier"] : []
3010
+ ];
3011
+ const changedRestoreKeys = changedCreateTimeKeys(restoreKeys, properties, previousProperties, context?.changedProperties, context?.noEchoOnlyChangedProperties);
3012
+ const unconfirmedRestoreKeys = unconfirmedCreateTimeKeys(restoreKeys, properties, previousProperties, context?.noEchoOnlyChangedProperties);
3013
+ if (unconfirmedRestoreKeys.length > 0) this.logger.warn(safeMsg`DBInstance ${logicalId}: ${unconfirmedRestoreKeys.join(", ")} may have changed (a NoEcho value cdkd cannot compare with its record); not applied: an instance is restored only when it is created.`);
3014
+ if (changedRestoreKeys.length > 0 && context?.replayingState !== true && context?.desiredFromAwsReadback !== true) {
3015
+ const { mask: restoreMask } = withDerivedNameMasks(this.logger, createMaskedLogSinks(this.logger, context?.maskSecrets), [[previousProperties["DBInstanceIdentifier"], physicalId]]);
3016
+ const fromSnapshot = changedRestoreKeys.some((key) => SNAPSHOT_RESTORE_KEYS.includes(key));
3017
+ const toPointInTime = changedRestoreKeys.some((key) => !SNAPSHOT_RESTORE_KEYS.includes(key));
3018
+ const how = fromSnapshot && toPointInTime ? "from a snapshot or to a point in time" : fromSnapshot ? "from a snapshot" : "to a point in time";
3019
+ throw new ResourceUpdateNotSupportedError(resourceType, logicalId, restoreMask(`${changedRestoreKeys.join(" and ")} cannot be added or changed on an existing DB instance — an instance is restored ${how} only when it is created, and CloudFormation refuses the same update ("Resource is immutable"). Removing it changes nothing. Nothing was applied to DB instance ${physicalId}. To keep the instance as it is, ` + (toPointInTime ? `declare the values the previous deploy declared (or none, if it declared none). ` : `declare the snapshot the previous deploy declared (or none, if it declared none). `) + `To replace it with an instance restored ${fromSnapshot && !toPointInTime ? "from the snapshot" : "as declared"}, ` + (String(previousProperties["DeletionProtection"]) === "true" ? protectedReplacementAdvice({
3020
+ evidence: "cdkd's properties for this DB instance carry DeletionProtection: true",
3021
+ replaceFlags: "cdkd deploy --replace --force-stateful-recreation",
3022
+ disable: {
3023
+ before: "aws rds modify-db-instance --db-instance-identifier",
3024
+ identifier: physicalId,
3025
+ after: "--no-deletion-protection --apply-immediately",
3026
+ maskSecrets: restoreMask
3027
+ }
3028
+ }) : "note AWS::RDS::DBInstance is a stateful type: re-run with cdkd deploy --replace --force-stateful-recreation (this deletes the instance and its data). The replace flags apply to the WHOLE deploy, so run them with nothing else pending")));
3029
+ }
2613
3030
  try {
2614
3031
  const volumeChanges = await additionalStorageVolumeChanges(properties, previousProperties, () => this.describeDBInstance(physicalId), {
2615
3032
  rollback: context?.replayingState === true,
@@ -3117,7 +3534,11 @@ function getDriftUnknownPaths(resourceType, properties) {
3117
3534
  "CertificateRotationRestart",
3118
3535
  "SourceRegion",
3119
3536
  "UseDefaultProcessorFeatures",
3120
- "AutomaticBackupReplicationKmsKeyId"
3537
+ "AutomaticBackupReplicationKmsKeyId",
3538
+ "DBSnapshotIdentifier",
3539
+ "DBClusterSnapshotIdentifier",
3540
+ ...POINT_IN_TIME_KEYS,
3541
+ ...declaresPointInTimeRestore(properties) ? ["SourceDBInstanceIdentifier"] : []
3121
3542
  ];
3122
3543
  const retention = properties?.["AutomaticBackupReplicationRetentionPeriod"];
3123
3544
  const declared = properties?.["ProcessorFeatures"];
@@ -3143,7 +3564,10 @@ function getDriftUnknownPaths(resourceType, properties) {
3143
3564
  "SnapshotIdentifier",
3144
3565
  "RestoreToTime",
3145
3566
  "RestoreType",
3146
- "UseLatestRestorableTime"
3567
+ "UseLatestRestorableTime",
3568
+ "EnableGlobalWriteForwarding",
3569
+ "ReplicationSourceIdentifier",
3570
+ "SourceRegion"
3147
3571
  ];
3148
3572
  if (properties === void 0 || Object.keys(properties).length === 0) return neverRead;
3149
3573
  return (properties?.["ServerlessV2ScalingConfiguration"])?.SecondsUntilAutoPause === void 0 ? [...neverRead, "ServerlessV2ScalingConfiguration.SecondsUntilAutoPause"] : neverRead;
@@ -3545,7 +3969,10 @@ var RDSProvider = class {
3545
3969
  "SnapshotIdentifier",
3546
3970
  "RestoreToTime",
3547
3971
  "RestoreType",
3548
- "UseLatestRestorableTime"
3972
+ "UseLatestRestorableTime",
3973
+ "EnableGlobalWriteForwarding",
3974
+ "ReplicationSourceIdentifier",
3975
+ "SourceRegion"
3549
3976
  ])],
3550
3977
  ["AWS::RDS::DBInstance", /* @__PURE__ */ new Set([
3551
3978
  "DBInstanceIdentifier",
@@ -3600,6 +4027,12 @@ var RDSProvider = class {
3600
4027
  "AssociatedRoles",
3601
4028
  "SourceDBInstanceIdentifier",
3602
4029
  "SourceRegion",
4030
+ "DBSnapshotIdentifier",
4031
+ "DBClusterSnapshotIdentifier",
4032
+ "RestoreTime",
4033
+ "UseLatestRestorableTime",
4034
+ "SourceDBInstanceAutomatedBackupsArn",
4035
+ "SourceDbiResourceId",
3603
4036
  "ProcessorFeatures",
3604
4037
  "AdditionalStorageVolumes",
3605
4038
  "UseDefaultProcessorFeatures",
@@ -3801,6 +4234,7 @@ var RDSProvider = class {
3801
4234
  return isSameResource.call(this, journaledPhysicalId, record, resourceType, context);
3802
4235
  }
3803
4236
  resourceIdentity(physicalId, resourceType, context) {
4237
+ if (typeof physicalId === "string" && isAutomatedBackupsArn(physicalId)) return automatedBackupResourceId.call(this, physicalId, context.expectedRegion);
3804
4238
  return resourceIdentity.call(this, physicalId, resourceType, context);
3805
4239
  }
3806
4240
  readDbResourceIdIfExists(resourceType, identifier) {
@@ -3830,4 +4264,4 @@ var RDSProvider = class {
3830
4264
  };
3831
4265
 
3832
4266
  export { RDSProvider };
3833
- //# sourceMappingURL=rds-provider-D7y6wD4F.js.map
4267
+ //# sourceMappingURL=rds-provider-B-TkBvu0.js.map