@cdkd/cli 0.330.1 → 0.332.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.
- package/dist/{asg-provider-BjxeIEiY.js → asg-provider-CwwgTp0h.js} +2 -2
- package/dist/{asg-provider-BjxeIEiY.js.map → asg-provider-CwwgTp0h.js.map} +1 -1
- package/dist/cli.js +2 -2
- package/dist/{db-associated-roles-BJYhpVIw.js → db-instance-modify-retry-B1PdmL5X.js} +42 -42
- package/dist/db-instance-modify-retry-B1PdmL5X.js.map +1 -0
- package/dist/{deploy-engine-CwSyFyiD.js → deploy-engine-5GASWIYI.js} +6669 -5931
- package/dist/deploy-engine-5GASWIYI.js.map +1 -0
- package/dist/{iam-role-provider-Z5NfXkLq.js → iam-role-provider-Cp9ASoIg.js} +2 -2
- package/dist/{iam-role-provider-Z5NfXkLq.js.map → iam-role-provider-Cp9ASoIg.js.map} +1 -1
- package/dist/index.js +2 -2
- package/dist/{neptune-provider-yH2aypYz.js → neptune-provider-C9IhSshh.js} +3 -3
- package/dist/{neptune-provider-yH2aypYz.js.map → neptune-provider-C9IhSshh.js.map} +1 -1
- package/dist/{program-B8hhHT8d.js → program-CaHG8EBB.js} +22020 -21474
- package/dist/program-CaHG8EBB.js.map +1 -0
- package/dist/{provider-classes-BMp1wV6q.js → provider-classes-DdGvWb5T.js} +9711 -8017
- package/dist/provider-classes-DdGvWb5T.js.map +1 -0
- package/dist/rds-provider-BI5PcgWT.js +2439 -0
- package/dist/rds-provider-BI5PcgWT.js.map +1 -0
- package/dist/{version-CRa3wJWQ.js → version-DXx2w7jk.js} +2 -2
- package/dist/{version-CRa3wJWQ.js.map → version-DXx2w7jk.js.map} +1 -1
- package/package.json +2 -2
- package/dist/db-associated-roles-BJYhpVIw.js.map +0 -1
- package/dist/deploy-engine-CwSyFyiD.js.map +0 -1
- package/dist/program-B8hhHT8d.js.map +0 -1
- package/dist/provider-classes-BMp1wV6q.js.map +0 -1
- package/dist/rds-provider-CKkb8Tk3.js +0 -2088
- package/dist/rds-provider-CKkb8Tk3.js.map +0 -1
|
@@ -0,0 +1,2439 @@
|
|
|
1
|
+
import { $ as safeMsg, E as generatedNameFor, n as describeAwsFailure, s as getLogger } from "./aws-failure-text-DiHodi76.js";
|
|
2
|
+
import { B as normalizeAwsTagsToCfn, F as assertRegionMatch, Fn as ResourceUpdateNotSupportedError, Ft as maskerOrIdentity, Gt as markAuxiliaryFailure, It as withDerivedNameMasks, J as deleteAfterProtectionFlipWithFinalSnapshot, K as ProtectionFlipRegistry, Kt as markCreatedBeforeFailure, M as RESOURCE_NOT_FOUND, Mr as markRedactedCause, Nn as ProvisioningError, Nr as wrapMaskedAwsError, P as markNotGone, Q as isTerminalDbWaitStatus, W as resolveExplicitPhysicalId, Y as deleteWithProtectionCompensation, b as withRemovalDefaults, dt as pasteableAwsCommand, fn as ambientClientDefaults, ft as protectedReplacementAdvice, g as clearOnUpdateRemoval, hr as relayedNameCollision, i as reportCreatedResource, j as withoutServerErrorRetries, jr as markNonRetryable, jt as createMaskedLogSinks, nt as protectionFlipKey, o as retractCreatedResource, rt as rdsFamilyProtectionSite, tt as observeThenDisableProtection, vn as CdkdError } from "./created-resource-sink-DBYrPwKg.js";
|
|
3
|
+
import { c as ambientRegion } from "./aws-client-defaults-BLXFsfMa.js";
|
|
4
|
+
import { $i as refuseMalformedDesiredTags, Dt as enclosingDeadlineRemainingMs, Ji as markDeleteStarted, Zi as planTagDiff, bl as dynamicReferenceTokens, kc as dbInstanceEngineChangeIsInPlace, na as definedAttributes, ra as stringifyIfAssigned, ta as tagPlanWarning, ya as slowCcOperationTimeoutMs } from "./deploy-engine-5GASWIYI.js";
|
|
5
|
+
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-B1PdmL5X.js";
|
|
6
|
+
import { DescribeSecurityGroupsCommand, EC2Client } from "@aws-sdk/client-ec2";
|
|
7
|
+
import { isDeepStrictEqual } from "node:util";
|
|
8
|
+
import { AddRoleToDBClusterCommand, AddRoleToDBInstanceCommand, AddTagsToResourceCommand, CreateDBClusterCommand, CreateDBInstanceCommand, CreateDBSubnetGroupCommand, DeleteDBClusterCommand, DeleteDBInstanceCommand, DeleteDBSubnetGroupCommand, DescribeDBClustersCommand, DescribeDBInstancesCommand, DescribeDBSubnetGroupsCommand, DescribeGlobalClustersCommand, DisableHttpEndpointCommand, EnableHttpEndpointCommand, ListTagsForResourceCommand, ModifyDBClusterCommand, ModifyDBInstanceCommand, ModifyDBSubnetGroupCommand, RDSClient, RebootDBInstanceCommand, RemoveFromGlobalClusterCommand, RemoveRoleFromDBClusterCommand, RemoveRoleFromDBInstanceCommand, RemoveTagsFromResourceCommand } from "@aws-sdk/client-rds";
|
|
9
|
+
|
|
10
|
+
// src/provisioning/providers/rds/shared.ts
|
|
11
|
+
const PROTECTION_FLIP_RETRY_WAIT_MS = 6e5;
|
|
12
|
+
const RDS_DELETE_WAIT_MS = Math.max(18e5, slowCcOperationTimeoutMs("AWS::RDS::DBCluster", "DELETE"), slowCcOperationTimeoutMs("AWS::RDS::DBInstance", "DELETE"));
|
|
13
|
+
function deleteAutomatedBackupsInput(properties) {
|
|
14
|
+
const value = properties?.["DeleteAutomatedBackups"];
|
|
15
|
+
if (value === true || value === "true") return { DeleteAutomatedBackups: true };
|
|
16
|
+
if (value === false || value === "false") return { DeleteAutomatedBackups: false };
|
|
17
|
+
return {};
|
|
18
|
+
}
|
|
19
|
+
function recordedGlobalClusterIdentifier(properties) {
|
|
20
|
+
const value = properties?.["GlobalClusterIdentifier"];
|
|
21
|
+
return typeof value === "string" && value.trim() !== "" ? value : void 0;
|
|
22
|
+
}
|
|
23
|
+
function readableGlobalClusterId(value) {
|
|
24
|
+
return value == null || typeof value === "string";
|
|
25
|
+
}
|
|
26
|
+
const usableGlobalClusterId = (value) => typeof value === "string";
|
|
27
|
+
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`;
|
|
28
|
+
const HTTP_ENDPOINT_BUSY_FAULTS = /* @__PURE__ */ new Set(["InvalidResourceStateFault", "InvalidDBClusterStateFault"]);
|
|
29
|
+
const TRANSIENT_DETACH_FAULTS = /* @__PURE__ */ new Set([
|
|
30
|
+
"InvalidDBClusterStateFault",
|
|
31
|
+
"InvalidGlobalClusterStateFault",
|
|
32
|
+
"ThrottlingException",
|
|
33
|
+
"Throttling",
|
|
34
|
+
"RequestLimitExceeded"
|
|
35
|
+
]);
|
|
36
|
+
function isDbIdentifier(id) {
|
|
37
|
+
return id.length <= 63 && /^[A-Za-z](?:-?[A-Za-z0-9])*$/.test(id);
|
|
38
|
+
}
|
|
39
|
+
function awsErrorName(error) {
|
|
40
|
+
return error?.name ?? "";
|
|
41
|
+
}
|
|
42
|
+
var GlobalClusterDetachError = class extends Error {
|
|
43
|
+
constructor(message) {
|
|
44
|
+
super(message);
|
|
45
|
+
this.name = "GlobalClusterDetachError";
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
function securityGroupListChanged(sent, previous) {
|
|
49
|
+
if (sent === void 0) return false;
|
|
50
|
+
const before = Array.isArray(previous) ? previous.filter((id) => typeof id === "string") : [];
|
|
51
|
+
return [...sent].sort().join(" ") !== [...before].sort().join(" ");
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// src/provisioning/providers/rds/dispatch.ts
|
|
55
|
+
async function create(logicalId, resourceType, properties, context) {
|
|
56
|
+
const mask = context?.maskSecrets;
|
|
57
|
+
switch (resourceType) {
|
|
58
|
+
case "AWS::RDS::DBSubnetGroup": return this.createDBSubnetGroup(logicalId, resourceType, properties, mask);
|
|
59
|
+
case "AWS::RDS::DBCluster": return this.createDBCluster(logicalId, resourceType, properties, mask, context?.replayingState === true);
|
|
60
|
+
case "AWS::RDS::DBInstance": return this.createDBInstance(logicalId, resourceType, properties, mask, context?.replayingState === true);
|
|
61
|
+
default: throw new ProvisioningError(`Unsupported resource type: ${resourceType}`, resourceType, logicalId);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
async function update(logicalId, physicalId, resourceType, properties, previousProperties, context) {
|
|
65
|
+
properties = withRemovalDefaults(this.removalDefaults, resourceType, properties, previousProperties, context);
|
|
66
|
+
switch (resourceType) {
|
|
67
|
+
case "AWS::RDS::DBSubnetGroup": return this.updateDBSubnetGroup(logicalId, physicalId, resourceType, properties, previousProperties, context?.maskSecrets);
|
|
68
|
+
case "AWS::RDS::DBCluster": return this.updateDBCluster(logicalId, physicalId, resourceType, properties, previousProperties, context);
|
|
69
|
+
case "AWS::RDS::DBInstance": return this.updateDBInstance(logicalId, physicalId, resourceType, properties, previousProperties, context);
|
|
70
|
+
default: throw new ProvisioningError(`Unsupported resource type: ${resourceType}`, resourceType, logicalId, physicalId);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
async function deleteImpl(logicalId, physicalId, resourceType, properties, context) {
|
|
74
|
+
switch (resourceType) {
|
|
75
|
+
case "AWS::RDS::DBSubnetGroup": return this.deleteDBSubnetGroup(logicalId, physicalId, resourceType, context);
|
|
76
|
+
case "AWS::RDS::DBCluster": return this.deleteDBCluster(logicalId, physicalId, resourceType, properties, context);
|
|
77
|
+
case "AWS::RDS::DBInstance": return this.deleteDBInstance(logicalId, physicalId, resourceType, properties, context);
|
|
78
|
+
default: throw new ProvisioningError(`Unsupported resource type: ${resourceType}`, resourceType, logicalId, physicalId);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
async function importImpl(input) {
|
|
82
|
+
switch (input.resourceType) {
|
|
83
|
+
case "AWS::RDS::DBInstance": return this.importDBInstance(input);
|
|
84
|
+
case "AWS::RDS::DBCluster": return this.importDBCluster(input);
|
|
85
|
+
case "AWS::RDS::DBSubnetGroup": return this.importDBSubnetGroup(input);
|
|
86
|
+
default: return null;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// src/provisioning/providers/rds/subnet-group.ts
|
|
91
|
+
async function createDBSubnetGroup(logicalId, resourceType, properties, mask) {
|
|
92
|
+
this.logger.debug(`Creating DBSubnetGroup ${logicalId}`);
|
|
93
|
+
const tags = refuseMalformedDesiredTags(properties["Tags"], resourceType, logicalId);
|
|
94
|
+
const dbSubnetGroupName = properties["DBSubnetGroupName"] || generatedNameFor("AWS::RDS::DBSubnetGroup", logicalId);
|
|
95
|
+
try {
|
|
96
|
+
const created = await this.getCreateClient().send(new CreateDBSubnetGroupCommand({
|
|
97
|
+
DBSubnetGroupName: dbSubnetGroupName,
|
|
98
|
+
DBSubnetGroupDescription: properties["DBSubnetGroupDescription"] || `Subnet group for ${logicalId}`,
|
|
99
|
+
SubnetIds: properties["SubnetIds"],
|
|
100
|
+
...tags.length > 0 && { Tags: tags }
|
|
101
|
+
}));
|
|
102
|
+
this.logger.debug(`Successfully created DBSubnetGroup ${logicalId}: ${dbSubnetGroupName}`);
|
|
103
|
+
const dbSubnetGroupArn = created.DBSubnetGroup?.DBSubnetGroupArn;
|
|
104
|
+
return {
|
|
105
|
+
physicalId: dbSubnetGroupName,
|
|
106
|
+
attributes: {
|
|
107
|
+
DBSubnetGroupName: dbSubnetGroupName,
|
|
108
|
+
...dbSubnetGroupArn !== void 0 && { DBSubnetGroupArn: dbSubnetGroupArn }
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
} catch (error) {
|
|
112
|
+
const cause = error instanceof Error ? error : void 0;
|
|
113
|
+
throw this.wrapCaughtError(mask, error, (text) => new ProvisioningError(`Failed to create DBSubnetGroup ${logicalId}: ${text}`, resourceType, logicalId, dbSubnetGroupName, cause));
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
async function updateDBSubnetGroup(logicalId, physicalId, resourceType, properties, previousProperties, mask) {
|
|
117
|
+
this.logger.debug(`Updating DBSubnetGroup ${logicalId}: ${physicalId}`);
|
|
118
|
+
refuseMalformedDesiredTags(properties["Tags"], resourceType, logicalId, physicalId);
|
|
119
|
+
try {
|
|
120
|
+
const subnetIds = properties["SubnetIds"];
|
|
121
|
+
const sendSubnetIds = subnetIds !== void 0 && subnetIds.length > 0;
|
|
122
|
+
const modifyInput = {
|
|
123
|
+
DBSubnetGroupName: physicalId,
|
|
124
|
+
DBSubnetGroupDescription: properties["DBSubnetGroupDescription"],
|
|
125
|
+
...sendSubnetIds && { SubnetIds: subnetIds }
|
|
126
|
+
};
|
|
127
|
+
await this.getClient().send(new ModifyDBSubnetGroupCommand(modifyInput));
|
|
128
|
+
const arn = (await this.getClient().send(new DescribeDBSubnetGroupsCommand({ DBSubnetGroupName: physicalId }))).DBSubnetGroups?.[0]?.DBSubnetGroupArn;
|
|
129
|
+
if (arn) await this.applyTagDiff(arn, resourceType, logicalId, previousProperties["Tags"], properties["Tags"]);
|
|
130
|
+
this.logger.debug(`Successfully updated DBSubnetGroup ${logicalId}`);
|
|
131
|
+
return {
|
|
132
|
+
physicalId,
|
|
133
|
+
wasReplaced: false,
|
|
134
|
+
attributes: {
|
|
135
|
+
DBSubnetGroupName: physicalId,
|
|
136
|
+
...arn !== void 0 && { DBSubnetGroupArn: arn }
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
} catch (error) {
|
|
140
|
+
const cause = error instanceof Error ? error : void 0;
|
|
141
|
+
throw this.wrapCaughtError(mask, error, (text) => new ProvisioningError(`Failed to update DBSubnetGroup ${logicalId}: ${text}`, resourceType, logicalId, physicalId, cause));
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
async function deleteDBSubnetGroup(logicalId, physicalId, resourceType, context) {
|
|
145
|
+
this.logger.debug(`Deleting DBSubnetGroup ${logicalId}: ${physicalId}`);
|
|
146
|
+
try {
|
|
147
|
+
await this.getClient().send(new DeleteDBSubnetGroupCommand({ DBSubnetGroupName: physicalId }));
|
|
148
|
+
this.logger.debug(`Successfully deleted DBSubnetGroup ${logicalId}`);
|
|
149
|
+
} catch (error) {
|
|
150
|
+
if (this.isNotFoundError(error, "DBSubnetGroupNotFoundFault")) {
|
|
151
|
+
const clientRegion = await this.getClient().config.region();
|
|
152
|
+
assertRegionMatch(clientRegion, context?.expectedRegion, resourceType, logicalId, physicalId);
|
|
153
|
+
this.logger.debug(`DBSubnetGroup ${physicalId} does not exist, skipping deletion`);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
const cause = error instanceof Error ? error : void 0;
|
|
157
|
+
throw this.wrapDeleteError(context?.maskSecrets, error, (text) => new ProvisioningError(`Failed to delete DBSubnetGroup ${logicalId}: ${text}`, resourceType, logicalId, physicalId, cause));
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
async function readCurrentStateDBSubnetGroup(physicalId) {
|
|
161
|
+
let resp;
|
|
162
|
+
try {
|
|
163
|
+
resp = await this.getClient().send(new DescribeDBSubnetGroupsCommand({ DBSubnetGroupName: physicalId }));
|
|
164
|
+
} catch (err) {
|
|
165
|
+
if (err?.name === "DBSubnetGroupNotFoundFault") return RESOURCE_NOT_FOUND;
|
|
166
|
+
if (this.isNotFoundError(err, "DBSubnetGroupNotFoundFault")) return void 0;
|
|
167
|
+
throw err;
|
|
168
|
+
}
|
|
169
|
+
const sg = resp.DBSubnetGroups?.[0];
|
|
170
|
+
if (!sg) return RESOURCE_NOT_FOUND;
|
|
171
|
+
const result = {};
|
|
172
|
+
if (sg.DBSubnetGroupName !== void 0) result["DBSubnetGroupName"] = sg.DBSubnetGroupName;
|
|
173
|
+
if (sg.DBSubnetGroupDescription !== void 0) result["DBSubnetGroupDescription"] = sg.DBSubnetGroupDescription;
|
|
174
|
+
result["SubnetIds"] = (sg.Subnets ?? []).map((s) => s.SubnetIdentifier).filter((id) => !!id);
|
|
175
|
+
if (sg.DBSubnetGroupArn) await this.attachTags(result, sg.DBSubnetGroupArn);
|
|
176
|
+
return result;
|
|
177
|
+
}
|
|
178
|
+
async function importDBSubnetGroup(input) {
|
|
179
|
+
const explicit = resolveExplicitPhysicalId(input, "DBSubnetGroupName");
|
|
180
|
+
if (explicit) try {
|
|
181
|
+
const arn = (await this.getClient().send(new DescribeDBSubnetGroupsCommand({ DBSubnetGroupName: explicit }))).DBSubnetGroups?.[0]?.DBSubnetGroupArn;
|
|
182
|
+
return {
|
|
183
|
+
physicalId: explicit,
|
|
184
|
+
attributes: { ...arn !== void 0 && { DBSubnetGroupArn: arn } }
|
|
185
|
+
};
|
|
186
|
+
} catch (err) {
|
|
187
|
+
if (err.name === "DBSubnetGroupNotFoundFault") return null;
|
|
188
|
+
throw err;
|
|
189
|
+
}
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// src/provisioning/providers/rds/instance-members.ts
|
|
194
|
+
function numberOrUndefined(value) {
|
|
195
|
+
return value == null ? void 0 : Number(value);
|
|
196
|
+
}
|
|
197
|
+
const STORAGE_MEMBERS = /* @__PURE__ */ new Set([
|
|
198
|
+
"AllocatedStorage",
|
|
199
|
+
"Iops",
|
|
200
|
+
"StorageType",
|
|
201
|
+
"StorageThroughput"
|
|
202
|
+
]);
|
|
203
|
+
function instanceValueChanged(properties, previousProperties, key, context) {
|
|
204
|
+
const desired = properties[key];
|
|
205
|
+
if (desired == null) return false;
|
|
206
|
+
const previous = previousProperties[key];
|
|
207
|
+
if (previous == null) return true;
|
|
208
|
+
const differs = typeof desired === "object" || typeof previous === "object" ? !isDeepStrictEqual(desired, previous) : String(desired) !== String(previous);
|
|
209
|
+
if (STORAGE_MEMBERS.has(key) && !differs) return false;
|
|
210
|
+
if (context?.changedProperties !== void 0) return context.changedProperties.has(key);
|
|
211
|
+
return differs;
|
|
212
|
+
}
|
|
213
|
+
function sizeOrZero(value) {
|
|
214
|
+
const size = Number(value);
|
|
215
|
+
return value != null && Number.isFinite(size) ? size : 0;
|
|
216
|
+
}
|
|
217
|
+
function isProvisionedIoStorage(properties) {
|
|
218
|
+
const storageType = properties["StorageType"];
|
|
219
|
+
if (typeof storageType === "string" && storageType !== "") return [
|
|
220
|
+
"io1",
|
|
221
|
+
"io2",
|
|
222
|
+
"gp3"
|
|
223
|
+
].includes(storageType.toLowerCase());
|
|
224
|
+
return properties["Iops"] != null;
|
|
225
|
+
}
|
|
226
|
+
async function instanceModifyBackfillMembers(properties, previousProperties, liveAllocatedStorage, logicalId, context) {
|
|
227
|
+
const changed = (key) => instanceValueChanged(properties, previousProperties, key, context);
|
|
228
|
+
const desiredAllocated = numberOrUndefined(properties["AllocatedStorage"]);
|
|
229
|
+
const members = {};
|
|
230
|
+
if (changed("BackupRetentionPeriod")) members.BackupRetentionPeriod = Number(properties["BackupRetentionPeriod"]);
|
|
231
|
+
for (const key of [
|
|
232
|
+
"PreferredBackupWindow",
|
|
233
|
+
"PreferredMaintenanceWindow",
|
|
234
|
+
"StorageType",
|
|
235
|
+
"OptionGroupName",
|
|
236
|
+
"CACertificateIdentifier"
|
|
237
|
+
]) if (changed(key)) members[key] = properties[key];
|
|
238
|
+
for (const key of ["NetworkType", "LicenseModel"]) if (changed(key)) members[key] = properties[key];
|
|
239
|
+
if (changed("DatabaseInsightsMode")) members.DatabaseInsightsMode = properties["DatabaseInsightsMode"];
|
|
240
|
+
for (const key of [
|
|
241
|
+
"MultiAZ",
|
|
242
|
+
"AutoMinorVersionUpgrade",
|
|
243
|
+
"CopyTagsToSnapshot",
|
|
244
|
+
"DedicatedLogVolume"
|
|
245
|
+
]) if (changed(key)) members[key] = properties[key];
|
|
246
|
+
if (changed("StorageThroughput")) members.StorageThroughput = Number(properties["StorageThroughput"]);
|
|
247
|
+
if (changed("PromotionTier")) members.PromotionTier = Number(properties["PromotionTier"]);
|
|
248
|
+
if (changed("CACertificateIdentifier") && properties["CertificateRotationRestart"] != null) members.CertificateRotationRestart = properties["CertificateRotationRestart"];
|
|
249
|
+
if (changed("MaxAllocatedStorage")) members.MaxAllocatedStorage = Number(properties["MaxAllocatedStorage"]);
|
|
250
|
+
else if (properties["MaxAllocatedStorage"] == null && previousProperties["MaxAllocatedStorage"] != null) {
|
|
251
|
+
const live = await liveAllocatedStorage();
|
|
252
|
+
if (live === void 0) throw new Error(safeMsg`DBInstance ${logicalId}: MaxAllocatedStorage was removed from the template, which turns storage autoscaling off by setting it to the allocated storage, but DescribeDBInstances did not report the allocated storage`);
|
|
253
|
+
members.MaxAllocatedStorage = Math.max(live, sizeOrZero(desiredAllocated));
|
|
254
|
+
}
|
|
255
|
+
const rollback = context?.replayingState === true;
|
|
256
|
+
if (changed("EngineVersion") && !rollback) members.EngineVersion = String(properties["EngineVersion"]);
|
|
257
|
+
if (changed("DBParameterGroupName") && !(rollback && changed("EngineVersion"))) members.DBParameterGroupName = properties["DBParameterGroupName"];
|
|
258
|
+
if (changed("AllowMajorVersionUpgrade") || members.EngineVersion !== void 0 && properties["AllowMajorVersionUpgrade"] != null) members.AllowMajorVersionUpgrade = properties["AllowMajorVersionUpgrade"];
|
|
259
|
+
if (changed("AllocatedStorage") && !rollback) members.AllocatedStorage = desiredAllocated;
|
|
260
|
+
if (isProvisionedIoStorage(properties)) {
|
|
261
|
+
if (changed("AllocatedStorage") || changed("Iops") || changed("StorageThroughput") || changed("StorageType")) {
|
|
262
|
+
if (members.AllocatedStorage === void 0) {
|
|
263
|
+
const live = await liveAllocatedStorage();
|
|
264
|
+
const larger = Math.max(sizeOrZero(live), sizeOrZero(desiredAllocated), rollback ? sizeOrZero(previousProperties["AllocatedStorage"]) : 0);
|
|
265
|
+
if (larger > 0) members.AllocatedStorage = larger;
|
|
266
|
+
}
|
|
267
|
+
if (properties["Iops"] != null) members.Iops = Number(properties["Iops"]);
|
|
268
|
+
}
|
|
269
|
+
} else if (changed("Iops") && !rollback) members.Iops = Number(properties["Iops"]);
|
|
270
|
+
const enableChanged = changed("EnablePerformanceInsights");
|
|
271
|
+
const keyChanged = changed("PerformanceInsightsKMSKeyId");
|
|
272
|
+
const enableDesired = properties["EnablePerformanceInsights"];
|
|
273
|
+
const keyDesired = properties["PerformanceInsightsKMSKeyId"];
|
|
274
|
+
if (enableChanged || keyChanged) {
|
|
275
|
+
members.EnablePerformanceInsights = enableDesired;
|
|
276
|
+
if (keyChanged || String(enableDesired) === "true") members.PerformanceInsightsKMSKeyId = keyDesired;
|
|
277
|
+
}
|
|
278
|
+
if (changed("PerformanceInsightsRetentionPeriod")) {
|
|
279
|
+
members.PerformanceInsightsRetentionPeriod = Number(properties["PerformanceInsightsRetentionPeriod"]);
|
|
280
|
+
members.EnablePerformanceInsights = enableDesired;
|
|
281
|
+
members.PerformanceInsightsKMSKeyId = keyDesired;
|
|
282
|
+
}
|
|
283
|
+
return Object.fromEntries(Object.entries(members).filter(([, value]) => value !== void 0));
|
|
284
|
+
}
|
|
285
|
+
function instanceParameterGroupPendingReboot(instance) {
|
|
286
|
+
return (instance?.DBParameterGroups ?? []).some((group) => group.ParameterApplyStatus === "pending-reboot");
|
|
287
|
+
}
|
|
288
|
+
function instanceParameterGroupApplying(instance) {
|
|
289
|
+
return (instance?.DBParameterGroups ?? []).some((group) => group.ParameterApplyStatus === "applying");
|
|
290
|
+
}
|
|
291
|
+
function instanceHasPendingChanges(instance, caRotationRestarts) {
|
|
292
|
+
const pending = instance.PendingModifiedValues;
|
|
293
|
+
if (pending === void 0) return false;
|
|
294
|
+
return pending.DBInstanceClass !== void 0 || pending.AllocatedStorage !== void 0 || pending.AutomationMode !== void 0 || pending.BackupRetentionPeriod !== void 0 || pending.DBInstanceIdentifier !== void 0 || pending.DBSubnetGroupName !== void 0 || pending.Engine !== void 0 || pending.EngineVersion !== void 0 || pending.IAMDatabaseAuthenticationEnabled !== void 0 || pending.Iops !== void 0 || pending.LicenseModel !== void 0 || pending.MasterUserPassword !== void 0 || pending.MultiAZ !== void 0 || pending.PendingCloudwatchLogsExports !== void 0 || pending.Port !== void 0 || (pending.ProcessorFeatures ?? []).length > 0 || pending.ResumeFullAutomationModeTime !== void 0 || pending.StorageThroughput !== void 0 || pending.StorageType !== void 0 || caRotationRestarts && pending.CACertificateIdentifier !== void 0;
|
|
295
|
+
}
|
|
296
|
+
function instanceParameterGroupSettled(instance, sentGroup, caRotationRestarts) {
|
|
297
|
+
if (instance.DBInstanceStatus !== "available") return false;
|
|
298
|
+
if (instanceHasPendingChanges(instance, caRotationRestarts)) return false;
|
|
299
|
+
const groups = instance.DBParameterGroups ?? [];
|
|
300
|
+
if (groups.some((group) => group.ParameterApplyStatus === "applying")) return false;
|
|
301
|
+
if (sentGroup === void 0 || groups.length === 0) return true;
|
|
302
|
+
return groups.some((group) => group.DBParameterGroupName?.toLowerCase() === sentGroup.toLowerCase());
|
|
303
|
+
}
|
|
304
|
+
function instanceRebootApplied(instance) {
|
|
305
|
+
return instance.DBInstanceStatus === "available" && (instance.DBParameterGroups ?? []).every((group) => group.ParameterApplyStatus === "in-sync") && (instance.OptionGroupMemberships ?? []).every((group) => group.Status === "in-sync");
|
|
306
|
+
}
|
|
307
|
+
function logExportsList(value) {
|
|
308
|
+
if (value == null) return void 0;
|
|
309
|
+
if (!Array.isArray(value) || !value.every((type) => typeof type === "string")) return "malformed";
|
|
310
|
+
return [...new Set(value)];
|
|
311
|
+
}
|
|
312
|
+
function desiredLogExports(properties, resourceType, logicalId, physicalId) {
|
|
313
|
+
const desired = logExportsList(properties["EnableCloudwatchLogsExports"]);
|
|
314
|
+
if (desired !== "malformed") return desired;
|
|
315
|
+
throw markNonRetryable(new ProvisioningError(`${resourceType} ${logicalId}: EnableCloudwatchLogsExports must be a list of log type names`, resourceType, logicalId, physicalId));
|
|
316
|
+
}
|
|
317
|
+
function logExportsDelta(desired, previousValue) {
|
|
318
|
+
const previous = logExportsList(previousValue);
|
|
319
|
+
const had = previous === void 0 || previous === "malformed" ? [] : previous;
|
|
320
|
+
const want = desired ?? [];
|
|
321
|
+
const enable = want.filter((type) => !had.includes(type));
|
|
322
|
+
const disable = had.filter((type) => !want.includes(type));
|
|
323
|
+
if (enable.length === 0 && disable.length === 0) return void 0;
|
|
324
|
+
return {
|
|
325
|
+
...enable.length > 0 && { EnableLogTypes: enable },
|
|
326
|
+
...disable.length > 0 && { DisableLogTypes: disable }
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
function liveLogExports(enabled, pending) {
|
|
330
|
+
const disabled = pending?.LogTypesToDisable ?? [];
|
|
331
|
+
const out = (enabled ?? []).filter((type) => !disabled.includes(type));
|
|
332
|
+
for (const type of pending?.LogTypesToEnable ?? []) if (!out.includes(type)) out.push(type);
|
|
333
|
+
return out;
|
|
334
|
+
}
|
|
335
|
+
function logExportsApplied(config, enabled, pending) {
|
|
336
|
+
if ((pending?.LogTypesToEnable?.length ?? 0) > 0) return false;
|
|
337
|
+
if ((pending?.LogTypesToDisable?.length ?? 0) > 0) return false;
|
|
338
|
+
const live = enabled ?? [];
|
|
339
|
+
return (config.EnableLogTypes ?? []).every((type) => live.includes(type)) && !(config.DisableLogTypes ?? []).some((type) => live.includes(type));
|
|
340
|
+
}
|
|
341
|
+
function instanceAvailabilityZoneKept(properties, previousProperties) {
|
|
342
|
+
const desired = properties["AvailabilityZone"];
|
|
343
|
+
if (desired === previousProperties["AvailabilityZone"]) return true;
|
|
344
|
+
return (desired == null || desired === "") && String(properties["MultiAZ"]) === "true";
|
|
345
|
+
}
|
|
346
|
+
function withPreviousAvailabilityZone(properties, previousProperties) {
|
|
347
|
+
const { AvailabilityZone: _desired, ...rest } = properties;
|
|
348
|
+
const previous = previousProperties["AvailabilityZone"];
|
|
349
|
+
return previous === void 0 ? rest : {
|
|
350
|
+
...rest,
|
|
351
|
+
AvailabilityZone: previous
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
function engineLifecycleSupportOf(bag) {
|
|
355
|
+
const value = bag["EngineLifecycleSupport"];
|
|
356
|
+
return value == null || value === "" ? void 0 : String(value);
|
|
357
|
+
}
|
|
358
|
+
function engineLifecycleSupportAction(properties, previousProperties, context) {
|
|
359
|
+
const desired = engineLifecycleSupportOf(properties);
|
|
360
|
+
if (desired === engineLifecycleSupportOf(previousProperties)) return "unchanged";
|
|
361
|
+
if (context?.replayingState === true) return "unchanged";
|
|
362
|
+
if (context?.desiredFromAwsReadback === true) return desired === void 0 ? "unchanged" : "send";
|
|
363
|
+
return desired === void 0 ? "refuse" : "check-live";
|
|
364
|
+
}
|
|
365
|
+
function engineLifecycleSupportRefusalText(resourceType, logicalId, physicalId, kind, liveRead) {
|
|
366
|
+
const cli = kind === "DB cluster" ? "aws rds modify-db-cluster" : "aws rds modify-db-instance";
|
|
367
|
+
return `${resourceType} ${logicalId}: EngineLifecycleSupport cannot change on an existing ${kind}. CloudFormation refuses the same update ("EngineLifecycleSupport cannot be modified."), whether the value changes, is added or is removed. Nothing was applied to ${kind} ${physicalId}. ` + (liveRead === "unreadable" ? `cdkd could not read the live setting (an AWS read failed), so it could not tell whether the ${kind} already holds the declared value; a re-run may succeed. ` : liveRead === "not-found" ? `RDS reports no such ${kind}: it was deleted outside cdkd, so the state record no longer matches AWS. ` : "") + `Declare the value the previous deploy declared (or none, if it declared none). To change the live setting, run ${cli} with --engine-lifecycle-support and --apply-immediately, then declare that value: a declared value the ${kind} already holds is no change.`;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
// src/provisioning/providers/rds/cluster-members.ts
|
|
371
|
+
const CLUSTER_REMOVED_PORT = /* @__PURE__ */ new Map([
|
|
372
|
+
["aurora-postgresql", 5432],
|
|
373
|
+
["aurora-mysql", 3306],
|
|
374
|
+
["mysql", 3306],
|
|
375
|
+
["postgres", 3306]
|
|
376
|
+
]);
|
|
377
|
+
function isClusterBusyRefusal(error) {
|
|
378
|
+
if (isModifyNotAvailableRefusal(error)) return true;
|
|
379
|
+
return error instanceof Error && error.name === "InvalidDBClusterStateFault" && /could not be modified\. Please try again/i.test(error.message);
|
|
380
|
+
}
|
|
381
|
+
function serverlessV2ScalingToSend(config) {
|
|
382
|
+
const seconds = numberOrUndefined(config.SecondsUntilAutoPause);
|
|
383
|
+
return {
|
|
384
|
+
MinCapacity: config.MinCapacity,
|
|
385
|
+
MaxCapacity: config.MaxCapacity,
|
|
386
|
+
...seconds !== void 0 && { SecondsUntilAutoPause: seconds }
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
const CLUSTER_BACKFILL_STRING_MEMBERS = [
|
|
390
|
+
"DBClusterParameterGroupName",
|
|
391
|
+
"PreferredBackupWindow",
|
|
392
|
+
"PreferredMaintenanceWindow",
|
|
393
|
+
"StorageType"
|
|
394
|
+
];
|
|
395
|
+
function clusterCreateBackfillMembers(properties) {
|
|
396
|
+
const members = {};
|
|
397
|
+
for (const key of CLUSTER_BACKFILL_STRING_MEMBERS) if (properties[key] != null) members[key] = properties[key];
|
|
398
|
+
if (properties["CopyTagsToSnapshot"] != null) members.CopyTagsToSnapshot = properties["CopyTagsToSnapshot"];
|
|
399
|
+
return members;
|
|
400
|
+
}
|
|
401
|
+
function clusterModifyBackfillMembers(properties, previousProperties, context) {
|
|
402
|
+
const changed = (key) => instanceValueChanged(properties, previousProperties, key, context);
|
|
403
|
+
const members = {};
|
|
404
|
+
for (const key of CLUSTER_BACKFILL_STRING_MEMBERS) if (changed(key)) members[key] = properties[key];
|
|
405
|
+
if (changed("CopyTagsToSnapshot")) members.CopyTagsToSnapshot = properties["CopyTagsToSnapshot"];
|
|
406
|
+
return members;
|
|
407
|
+
}
|
|
408
|
+
const CLUSTER_PERFORMANCE_INSIGHTS_MEMBERS = [
|
|
409
|
+
["PerformanceInsightsEnabled", "EnablePerformanceInsights"],
|
|
410
|
+
["PerformanceInsightsKmsKeyId", "PerformanceInsightsKMSKeyId"],
|
|
411
|
+
["PerformanceInsightsRetentionPeriod", "PerformanceInsightsRetentionPeriod"]
|
|
412
|
+
];
|
|
413
|
+
function clusterPerformanceInsightsMembers(properties) {
|
|
414
|
+
const members = {};
|
|
415
|
+
if (properties["PerformanceInsightsEnabled"] != null) members.EnablePerformanceInsights = properties["PerformanceInsightsEnabled"];
|
|
416
|
+
if (properties["PerformanceInsightsKmsKeyId"] != null) members.PerformanceInsightsKMSKeyId = properties["PerformanceInsightsKmsKeyId"];
|
|
417
|
+
const retention = retentionPeriodValue(properties["PerformanceInsightsRetentionPeriod"]);
|
|
418
|
+
if (typeof retention === "number") members.PerformanceInsightsRetentionPeriod = retention;
|
|
419
|
+
return members;
|
|
420
|
+
}
|
|
421
|
+
function clusterCreateScalarMembers(properties) {
|
|
422
|
+
return {
|
|
423
|
+
...properties["AutoMinorVersionUpgrade"] != null && { AutoMinorVersionUpgrade: properties["AutoMinorVersionUpgrade"] },
|
|
424
|
+
...properties["NetworkType"] != null && { NetworkType: properties["NetworkType"] },
|
|
425
|
+
...clusterPerformanceInsightsMembers(properties),
|
|
426
|
+
...properties["DatabaseInsightsMode"] != null && { DatabaseInsightsMode: properties["DatabaseInsightsMode"] },
|
|
427
|
+
...engineLifecycleSupportOf(properties) !== void 0 && { EngineLifecycleSupport: engineLifecycleSupportOf(properties) },
|
|
428
|
+
...properties["MasterUserAuthenticationType"] != null && { MasterUserAuthenticationType: properties["MasterUserAuthenticationType"] },
|
|
429
|
+
...typeof backtrackWindowValue(properties["BacktrackWindow"]) === "number" && { BacktrackWindow: backtrackWindowValue(properties["BacktrackWindow"]) },
|
|
430
|
+
...typeof localWriteForwardingFlag(properties["EnableLocalWriteForwarding"]) === "boolean" && { EnableLocalWriteForwarding: localWriteForwardingFlag(properties["EnableLocalWriteForwarding"]) }
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
function clusterModifyScalarMembers(properties, previousProperties, context) {
|
|
434
|
+
const changed = (key) => instanceValueChanged(properties, previousProperties, key, context);
|
|
435
|
+
const members = {};
|
|
436
|
+
if (changed("AutoMinorVersionUpgrade")) members.AutoMinorVersionUpgrade = properties["AutoMinorVersionUpgrade"];
|
|
437
|
+
if (changed("NetworkType")) members.NetworkType = properties["NetworkType"];
|
|
438
|
+
const insightsModeChanged = changed("DatabaseInsightsMode");
|
|
439
|
+
if (insightsModeChanged || CLUSTER_PERFORMANCE_INSIGHTS_MEMBERS.some(([key]) => changed(key))) Object.assign(members, clusterPerformanceInsightsMembers(properties));
|
|
440
|
+
if (insightsModeChanged) members.DatabaseInsightsMode = properties["DatabaseInsightsMode"];
|
|
441
|
+
const backtrackWindow = backtrackWindowValue(properties["BacktrackWindow"]);
|
|
442
|
+
if (typeof backtrackWindow === "number" && changed("BacktrackWindow")) members.BacktrackWindow = backtrackWindow;
|
|
443
|
+
const localWriteForwarding = localWriteForwardingToSend(properties, previousProperties, context);
|
|
444
|
+
if (typeof localWriteForwarding === "boolean") members.EnableLocalWriteForwarding = localWriteForwarding;
|
|
445
|
+
return members;
|
|
446
|
+
}
|
|
447
|
+
function backtrackWindowValue(value) {
|
|
448
|
+
return retentionPeriodValue(value);
|
|
449
|
+
}
|
|
450
|
+
function localWriteForwardingFlag(value) {
|
|
451
|
+
return httpEndpointFlag(value);
|
|
452
|
+
}
|
|
453
|
+
function localWriteForwardingToSend(properties, previousProperties, context) {
|
|
454
|
+
const desired = localWriteForwardingFlag(properties["EnableLocalWriteForwarding"]);
|
|
455
|
+
const previousFlag = localWriteForwardingFlag(previousProperties["EnableLocalWriteForwarding"]);
|
|
456
|
+
const previous = typeof previousFlag === "boolean" ? previousFlag : void 0;
|
|
457
|
+
if (desired === void 0) return previous === true ? false : void 0;
|
|
458
|
+
if (desired === "malformed") return void 0;
|
|
459
|
+
if (previous === void 0 && desired === false) return void 0;
|
|
460
|
+
if (!instanceValueChanged(properties, previousProperties, "EnableLocalWriteForwarding", context)) return;
|
|
461
|
+
return desired && context?.desiredFromAwsReadback === true && context.declaredTrueProperties?.has("EnableLocalWriteForwarding") !== true ? "withheld" : desired;
|
|
462
|
+
}
|
|
463
|
+
function localWriteForwardingApplied(cluster, enabled) {
|
|
464
|
+
const status = cluster.LocalWriteForwardingStatus;
|
|
465
|
+
if (status === void 0) return true;
|
|
466
|
+
if (status === "enabling" || status === "disabling") return false;
|
|
467
|
+
return (status === "requested" || status === "enabled") === enabled;
|
|
468
|
+
}
|
|
469
|
+
function httpEndpointFlag(value) {
|
|
470
|
+
if (value == null) return void 0;
|
|
471
|
+
if (value === true || value === "true") return true;
|
|
472
|
+
if (value === false || value === "false") return false;
|
|
473
|
+
return "malformed";
|
|
474
|
+
}
|
|
475
|
+
const CLUSTER_BOOLEAN_SCALARS = [
|
|
476
|
+
"AutoMinorVersionUpgrade",
|
|
477
|
+
"PerformanceInsightsEnabled",
|
|
478
|
+
"EnableHttpEndpoint",
|
|
479
|
+
"EnableLocalWriteForwarding"
|
|
480
|
+
];
|
|
481
|
+
function retentionPeriodValue(value) {
|
|
482
|
+
if (value == null) return void 0;
|
|
483
|
+
const parsed = typeof value === "number" ? value : typeof value === "string" && /^\d+$/.test(value.trim()) ? Number(value) : NaN;
|
|
484
|
+
return Number.isInteger(parsed) && parsed >= 0 ? parsed : "malformed";
|
|
485
|
+
}
|
|
486
|
+
function clusterHttpEndpointAction(properties, previousProperties, resourceType, logicalId, physicalId, context) {
|
|
487
|
+
const desired = httpEndpointFlag(properties["EnableHttpEndpoint"]);
|
|
488
|
+
if (desired === "malformed") {
|
|
489
|
+
if (context?.replayingState === true || context?.desiredFromAwsReadback === true) return "skip";
|
|
490
|
+
throw markNonRetryable(new ProvisioningError(`${resourceType} ${logicalId}: EnableHttpEndpoint must be true or false`, resourceType, logicalId, physicalId));
|
|
491
|
+
}
|
|
492
|
+
const engine = properties["Engine"];
|
|
493
|
+
if (typeof engine !== "string") return void 0;
|
|
494
|
+
if (!["aurora-mysql", "aurora-postgresql"].includes(engine.toLowerCase())) return void 0;
|
|
495
|
+
const recorded = httpEndpointFlag(previousProperties["EnableHttpEndpoint"]);
|
|
496
|
+
if (desired === (recorded === "malformed" ? void 0 : recorded)) return void 0;
|
|
497
|
+
if (desired !== true) return "disable";
|
|
498
|
+
return context?.desiredFromAwsReadback === true && context.declaredTrueProperties?.has("EnableHttpEndpoint") !== true ? "withheld" : "enable";
|
|
499
|
+
}
|
|
500
|
+
function withPreviousValues(properties, previousProperties, skipped) {
|
|
501
|
+
const out = { ...properties };
|
|
502
|
+
for (const [key, usable] of skipped) {
|
|
503
|
+
delete out[key];
|
|
504
|
+
const previous = previousProperties[key];
|
|
505
|
+
if (previous != null && usable(previous)) out[key] = previous;
|
|
506
|
+
}
|
|
507
|
+
return out;
|
|
508
|
+
}
|
|
509
|
+
const usableHttpEndpoint = (value) => typeof httpEndpointFlag(value) === "boolean";
|
|
510
|
+
const usableRetentionPeriod = (value) => typeof retentionPeriodValue(value) === "number";
|
|
511
|
+
const usableBacktrackWindow = (value) => typeof backtrackWindowValue(value) === "number";
|
|
512
|
+
const usableLocalWriteForwarding = (value) => typeof localWriteForwardingFlag(value) === "boolean";
|
|
513
|
+
const usableAvailabilityZones = (value) => value == null || Array.isArray(value) && value.every((zone) => typeof zone === "string" && zone.trim() !== "");
|
|
514
|
+
function clusterEngineVersionChanged(properties, previousProperties, context) {
|
|
515
|
+
if (context?.replayingState === true) return false;
|
|
516
|
+
return instanceValueChanged(properties, previousProperties, "EngineVersion", context);
|
|
517
|
+
}
|
|
518
|
+
const SECURITY_GROUP_CHANGE_MEMBER_STATUSES = /* @__PURE__ */ new Set(["modifying"]);
|
|
519
|
+
const PORT_CHANGE_MEMBER_STATUSES = /* @__PURE__ */ new Set(["modifying", "rebooting"]);
|
|
520
|
+
function clusterPortToSend(properties, previousProperties) {
|
|
521
|
+
if (properties["Port"] != null) return Number(properties["Port"]);
|
|
522
|
+
if (previousProperties["Port"] == null) return void 0;
|
|
523
|
+
const engine = properties["Engine"] ?? previousProperties["Engine"];
|
|
524
|
+
const reset = typeof engine === "string" ? CLUSTER_REMOVED_PORT.get(engine.toLowerCase()) : void 0;
|
|
525
|
+
return reset === Number(previousProperties["Port"]) ? void 0 : reset;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
// src/provisioning/providers/rds/cluster-create.ts
|
|
529
|
+
async function createDBCluster(logicalId, resourceType, properties, mask, replaying = false) {
|
|
530
|
+
this.logger.debug(`Creating DBCluster ${logicalId}`);
|
|
531
|
+
const tags = refuseMalformedDesiredTags(properties["Tags"], resourceType, logicalId);
|
|
532
|
+
let httpEndpoint = httpEndpointFlag(properties["EnableHttpEndpoint"]);
|
|
533
|
+
if (httpEndpoint === "malformed") {
|
|
534
|
+
if (!replaying) throw markNonRetryable(new ProvisioningError(`${resourceType} ${logicalId}: EnableHttpEndpoint must be true or false`, resourceType, logicalId));
|
|
535
|
+
this.logger.warn(safeMsg`DBCluster ${logicalId}: the replayed EnableHttpEndpoint is not true or false; the cluster is created with the Data API off`);
|
|
536
|
+
httpEndpoint = void 0;
|
|
537
|
+
}
|
|
538
|
+
const retentionSkipped = retentionPeriodValue(properties["PerformanceInsightsRetentionPeriod"]) === "malformed";
|
|
539
|
+
if (retentionSkipped) {
|
|
540
|
+
if (!replaying) throw markNonRetryable(new ProvisioningError(`${resourceType} ${logicalId}: PerformanceInsightsRetentionPeriod must be a whole number of days`, resourceType, logicalId));
|
|
541
|
+
this.logger.warn(safeMsg`DBCluster ${logicalId}: the replayed PerformanceInsightsRetentionPeriod is not a whole number of days; the cluster is created with AWS's default retention`);
|
|
542
|
+
}
|
|
543
|
+
const backtrackSkipped = backtrackWindowValue(properties["BacktrackWindow"]) === "malformed";
|
|
544
|
+
const forwardingSkipped = localWriteForwardingFlag(properties["EnableLocalWriteForwarding"]) === "malformed";
|
|
545
|
+
const rawAvailabilityZones = properties["AvailabilityZones"];
|
|
546
|
+
const availabilityZonesSkipped = !usableAvailabilityZones(rawAvailabilityZones);
|
|
547
|
+
const availabilityZones = rawAvailabilityZones != null && !availabilityZonesSkipped ? rawAvailabilityZones : void 0;
|
|
548
|
+
const globalClusterSkipped = !readableGlobalClusterId(properties["GlobalClusterIdentifier"]);
|
|
549
|
+
const globalClusterId = globalClusterSkipped ? void 0 : recordedGlobalClusterIdentifier(properties);
|
|
550
|
+
for (const [skipped, key, expected, created] of [
|
|
551
|
+
[
|
|
552
|
+
backtrackSkipped,
|
|
553
|
+
"BacktrackWindow",
|
|
554
|
+
"a whole number of seconds",
|
|
555
|
+
"backtracking off"
|
|
556
|
+
],
|
|
557
|
+
[
|
|
558
|
+
forwardingSkipped,
|
|
559
|
+
"EnableLocalWriteForwarding",
|
|
560
|
+
"true or false",
|
|
561
|
+
"write forwarding off"
|
|
562
|
+
],
|
|
563
|
+
[
|
|
564
|
+
globalClusterSkipped,
|
|
565
|
+
"GlobalClusterIdentifier",
|
|
566
|
+
"a string",
|
|
567
|
+
"no global cluster"
|
|
568
|
+
],
|
|
569
|
+
[
|
|
570
|
+
availabilityZonesSkipped,
|
|
571
|
+
"AvailabilityZones",
|
|
572
|
+
"a list of Availability Zone names",
|
|
573
|
+
"the Availability Zones RDS picks"
|
|
574
|
+
]
|
|
575
|
+
]) {
|
|
576
|
+
if (!skipped) continue;
|
|
577
|
+
if (!replaying) throw markNonRetryable(new ProvisioningError(`${resourceType} ${logicalId}: ${key} must be ${expected}`, resourceType, logicalId));
|
|
578
|
+
this.logger.warn(safeMsg`DBCluster ${logicalId}: the replayed ${key} is not ${expected}; the cluster is created with ${created}`);
|
|
579
|
+
}
|
|
580
|
+
const roles = this.desiredAssociatedRoles(properties, resourceType, logicalId, void 0, replaying);
|
|
581
|
+
const skippedKeys = [
|
|
582
|
+
...roles === "skipped" ? ["AssociatedRoles"] : [],
|
|
583
|
+
...properties["EnableHttpEndpoint"] != null && httpEndpoint === void 0 ? ["EnableHttpEndpoint"] : [],
|
|
584
|
+
...retentionSkipped ? ["PerformanceInsightsRetentionPeriod"] : [],
|
|
585
|
+
...backtrackSkipped ? ["BacktrackWindow"] : [],
|
|
586
|
+
...forwardingSkipped ? ["EnableLocalWriteForwarding"] : [],
|
|
587
|
+
...availabilityZonesSkipped ? ["AvailabilityZones"] : [],
|
|
588
|
+
...globalClusterSkipped ? ["GlobalClusterIdentifier"] : []
|
|
589
|
+
];
|
|
590
|
+
const effectiveProperties = skippedKeys.length > 0 ? Object.fromEntries(Object.entries(properties).filter(([key]) => !skippedKeys.includes(key))) : void 0;
|
|
591
|
+
const logExports = desiredLogExports(properties, resourceType, logicalId);
|
|
592
|
+
const dbClusterIdentifier = properties["DBClusterIdentifier"] || generatedNameFor("AWS::RDS::DBCluster", logicalId);
|
|
593
|
+
let clusterLeftBehind = false;
|
|
594
|
+
let createdResourceId;
|
|
595
|
+
try {
|
|
596
|
+
const serverlessV2Config = properties["ServerlessV2ScalingConfiguration"];
|
|
597
|
+
const masterUserSecret = properties["MasterUserSecret"];
|
|
598
|
+
const response = await this.getCreateClient().send(new CreateDBClusterCommand({
|
|
599
|
+
DBClusterIdentifier: dbClusterIdentifier,
|
|
600
|
+
Engine: properties["Engine"],
|
|
601
|
+
EngineVersion: properties["EngineVersion"],
|
|
602
|
+
MasterUsername: properties["MasterUsername"],
|
|
603
|
+
MasterUserPassword: properties["MasterUserPassword"],
|
|
604
|
+
DatabaseName: properties["DatabaseName"],
|
|
605
|
+
Port: properties["Port"] != null ? Number(properties["Port"]) : void 0,
|
|
606
|
+
VpcSecurityGroupIds: properties["VpcSecurityGroupIds"],
|
|
607
|
+
DBSubnetGroupName: properties["DBSubnetGroupName"],
|
|
608
|
+
StorageEncrypted: properties["StorageEncrypted"],
|
|
609
|
+
KmsKeyId: properties["KmsKeyId"],
|
|
610
|
+
BackupRetentionPeriod: properties["BackupRetentionPeriod"] != null ? Number(properties["BackupRetentionPeriod"]) : void 0,
|
|
611
|
+
DeletionProtection: properties["DeletionProtection"],
|
|
612
|
+
...properties["ManageMasterUserPassword"] !== void 0 && { ManageMasterUserPassword: properties["ManageMasterUserPassword"] },
|
|
613
|
+
...masterUserSecret?.KmsKeyId !== void 0 && { MasterUserSecretKmsKeyId: masterUserSecret.KmsKeyId },
|
|
614
|
+
...properties["MonitoringRoleArn"] !== void 0 && { MonitoringRoleArn: properties["MonitoringRoleArn"] },
|
|
615
|
+
...properties["MonitoringInterval"] !== void 0 && { MonitoringInterval: Number(properties["MonitoringInterval"]) },
|
|
616
|
+
...properties["EnableIAMDatabaseAuthentication"] !== void 0 && { EnableIAMDatabaseAuthentication: properties["EnableIAMDatabaseAuthentication"] },
|
|
617
|
+
...properties["PubliclyAccessible"] !== void 0 && { PubliclyAccessible: properties["PubliclyAccessible"] },
|
|
618
|
+
...serverlessV2Config && { ServerlessV2ScalingConfiguration: serverlessV2ScalingToSend(serverlessV2Config) },
|
|
619
|
+
...clusterCreateBackfillMembers(properties),
|
|
620
|
+
...logExports !== void 0 && logExports.length > 0 && { EnableCloudwatchLogsExports: logExports },
|
|
621
|
+
...clusterCreateScalarMembers(properties),
|
|
622
|
+
...httpEndpoint !== void 0 && { EnableHttpEndpoint: httpEndpoint },
|
|
623
|
+
...properties["ClusterScalabilityType"] != null && { ClusterScalabilityType: properties["ClusterScalabilityType"] },
|
|
624
|
+
...properties["EngineMode"] != null && { EngineMode: properties["EngineMode"] },
|
|
625
|
+
...availabilityZones !== void 0 && availabilityZones.length > 0 && { AvailabilityZones: availabilityZones },
|
|
626
|
+
...globalClusterId !== void 0 && { GlobalClusterIdentifier: globalClusterId },
|
|
627
|
+
...tags.length > 0 && { Tags: tags }
|
|
628
|
+
}));
|
|
629
|
+
clusterLeftBehind = true;
|
|
630
|
+
createdResourceId = response.DBCluster?.DbClusterResourceId;
|
|
631
|
+
reportCreatedResource(logicalId, resourceType, dbClusterIdentifier, createdResourceId);
|
|
632
|
+
if (!response.DBCluster) throw new Error("CreateDBCluster did not return DBCluster");
|
|
633
|
+
this.logger.debug(`Successfully created DBCluster ${logicalId}: ${dbClusterIdentifier}`);
|
|
634
|
+
const wantsDeletionProtection = properties["DeletionProtection"] === true;
|
|
635
|
+
try {
|
|
636
|
+
if (process.env["CDKD_NO_WAIT"] !== "true") {
|
|
637
|
+
await this.waitForClusterAvailable(logicalId, dbClusterIdentifier);
|
|
638
|
+
if (localWriteForwardingFlag(properties["EnableLocalWriteForwarding"]) === true) await this.waitForClusterState(logicalId, dbClusterIdentifier, (cluster) => localWriteForwardingApplied(cluster, true), "local write forwarding setting");
|
|
639
|
+
}
|
|
640
|
+
if (roles !== "skipped") try {
|
|
641
|
+
await this.applyAssociatedRoles("cluster", logicalId, dbClusterIdentifier, roles, [], mask, void 0);
|
|
642
|
+
} catch (roleError) {
|
|
643
|
+
markAuxiliaryFailure(roleError, logicalId);
|
|
644
|
+
throw roleError;
|
|
645
|
+
}
|
|
646
|
+
const described = await this.describeDBCluster(dbClusterIdentifier);
|
|
647
|
+
return {
|
|
648
|
+
physicalId: dbClusterIdentifier,
|
|
649
|
+
attributes: definedAttributes({
|
|
650
|
+
"Endpoint.Address": described?.Endpoint,
|
|
651
|
+
"Endpoint.Port": stringifyIfAssigned(described?.Port),
|
|
652
|
+
"ReadEndpoint.Address": described?.ReaderEndpoint,
|
|
653
|
+
Arn: described?.DBClusterArn,
|
|
654
|
+
DBClusterResourceId: described?.DbClusterResourceId
|
|
655
|
+
}),
|
|
656
|
+
...effectiveProperties !== void 0 && { effectiveProperties }
|
|
657
|
+
};
|
|
658
|
+
} catch (innerError) {
|
|
659
|
+
try {
|
|
660
|
+
if (wantsDeletionProtection) try {
|
|
661
|
+
await this.getClient().send(new ModifyDBClusterCommand({
|
|
662
|
+
DBClusterIdentifier: dbClusterIdentifier,
|
|
663
|
+
DeletionProtection: false,
|
|
664
|
+
ApplyImmediately: true
|
|
665
|
+
}));
|
|
666
|
+
} catch (disableError) {
|
|
667
|
+
this.logger.debug(maskerOrIdentity(mask)(`Could not disable DeletionProtection on partially-created DBCluster ${dbClusterIdentifier}: ${describeAwsFailure(disableError).detail} (proceeding with DeleteDBCluster anyway)`));
|
|
668
|
+
}
|
|
669
|
+
await this.getClient().send(new DeleteDBClusterCommand({
|
|
670
|
+
DBClusterIdentifier: dbClusterIdentifier,
|
|
671
|
+
SkipFinalSnapshot: true
|
|
672
|
+
}));
|
|
673
|
+
clusterLeftBehind = false;
|
|
674
|
+
retractCreatedResource(logicalId, resourceType, dbClusterIdentifier);
|
|
675
|
+
this.logger.debug(`Delete requested for partially-created DBCluster ${logicalId} (${dbClusterIdentifier}) after wiring failure (not waiting for deleted state)`);
|
|
676
|
+
} catch (cleanupError) {
|
|
677
|
+
const retiring = await this.partialClusterRetiring(dbClusterIdentifier);
|
|
678
|
+
if (retiring !== void 0) {
|
|
679
|
+
this.logger.debug(maskerOrIdentity(mask)(`Cleanup delete of partially-created DBCluster ${logicalId} refused: ${maskerOrIdentity(mask)(describeAwsFailure(cleanupError).detail)}`));
|
|
680
|
+
this.logger.warn(maskerOrIdentity(mask)(`Partially-created DBCluster ${logicalId} (${dbClusterIdentifier}) is ${retiring === "gone" ? "read as already deleted" : "already in status 'deleting'"}; cdkd did not delete it again. Outside a rollback's re-create, the failed deploy's rollback journal still records it, so \`cdkd rollback --revert-failed\` confirms it is gone`));
|
|
681
|
+
throw innerError;
|
|
682
|
+
}
|
|
683
|
+
const aws = pasteableAwsCommand();
|
|
684
|
+
const unprotect = wantsDeletionProtection ? aws`aws rds modify-db-cluster --db-cluster-identifier ${dbClusterIdentifier} --no-deletion-protection --apply-immediately; ` : aws``;
|
|
685
|
+
const m = maskerOrIdentity(mask);
|
|
686
|
+
const cleanupFailure = describeAwsFailure(cleanupError);
|
|
687
|
+
const cleanupHead = `Failed to delete partially-created DBCluster ${logicalId} (${dbClusterIdentifier}): `;
|
|
688
|
+
if (cleanupFailure.redacted) this.logger.debug(m(`${cleanupHead}${m(cleanupFailure.detail)}`));
|
|
689
|
+
this.logger.warn(`${cleanupHead}${cleanupFailure.redacted ? `${m(cleanupFailure.summary)} ` : `${m(cleanupFailure.detail)}. `}THE CLUSTER IS STILL RUNNING AND BILLING. Outside a rollback's re-create, the failed deploy's rollback journal records it for \`cdkd rollback --revert-failed\`${wantsDeletionProtection ? ", which cannot delete it while its DeletionProtection is on" : ""}; otherwise delete it yourself: ${aws`${unprotect}aws rds delete-db-cluster --db-cluster-identifier ${dbClusterIdentifier} --skip-final-snapshot`.render()}`);
|
|
690
|
+
}
|
|
691
|
+
throw innerError;
|
|
692
|
+
}
|
|
693
|
+
} catch (error) {
|
|
694
|
+
const thrown = error instanceof ProvisioningError ? error : this.wrapCaughtError(mask, error, (text) => new ProvisioningError(`Failed to create DBCluster ${logicalId}: ${text}`, resourceType, logicalId, dbClusterIdentifier, error instanceof Error ? error : void 0));
|
|
695
|
+
if (clusterLeftBehind) markCreatedBeforeFailure(thrown, logicalId, resourceType, dbClusterIdentifier, createdResourceId);
|
|
696
|
+
throw thrown;
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
// src/provisioning/providers/rds/master-credentials.ts
|
|
701
|
+
function propertyChangedForUpdate(key, desired, recorded, context) {
|
|
702
|
+
const changedProperties = context?.changedProperties;
|
|
703
|
+
if (changedProperties !== void 0) return changedProperties.has(key);
|
|
704
|
+
return holdsRecordedStandIn(recorded) || !isDeepStrictEqual(desired, recorded);
|
|
705
|
+
}
|
|
706
|
+
function holdsRecordedStandIn(value) {
|
|
707
|
+
if (typeof value === "string") return value === "***" || dynamicReferenceTokens(value).length > 0;
|
|
708
|
+
if (Array.isArray(value)) return value.some(holdsRecordedStandIn);
|
|
709
|
+
if (value !== null && typeof value === "object") return Object.values(value).some(holdsRecordedStandIn);
|
|
710
|
+
return false;
|
|
711
|
+
}
|
|
712
|
+
function masterUserPasswordToSend(properties, previousProperties, context) {
|
|
713
|
+
const desired = properties["MasterUserPassword"];
|
|
714
|
+
if (desired === void 0 || desired === null) return void 0;
|
|
715
|
+
return propertyChangedForUpdate("MasterUserPassword", desired, previousProperties["MasterUserPassword"], context) ? desired : void 0;
|
|
716
|
+
}
|
|
717
|
+
function masterCredentialSettingsChanged(properties, previousProperties, context) {
|
|
718
|
+
return propertyChangedForUpdate("MasterUserPassword", properties["MasterUserPassword"], previousProperties["MasterUserPassword"], context) || propertyChangedForUpdate("ManageMasterUserPassword", properties["ManageMasterUserPassword"], previousProperties["ManageMasterUserPassword"], context) || propertyChangedForUpdate("MasterUserSecret", properties["MasterUserSecret"], previousProperties["MasterUserSecret"], context);
|
|
719
|
+
}
|
|
720
|
+
function managedPasswordSettingRides(credentialSettingsChanged, authenticationType) {
|
|
721
|
+
return credentialSettingsChanged || authenticationType !== void 0;
|
|
722
|
+
}
|
|
723
|
+
function passwordAuthenticationCompanion(properties, previousProperties, authenticationType) {
|
|
724
|
+
if (authenticationType !== "password") return void 0;
|
|
725
|
+
if (String(properties["ManageMasterUserPassword"]) === "true") {
|
|
726
|
+
const previous = previousProperties["MasterUserAuthenticationType"];
|
|
727
|
+
return previous != null && previous !== "" && previous !== "password" ? { kind: "managed" } : void 0;
|
|
728
|
+
}
|
|
729
|
+
const password = properties["MasterUserPassword"];
|
|
730
|
+
return typeof password === "string" && password !== "" ? {
|
|
731
|
+
kind: "password",
|
|
732
|
+
password
|
|
733
|
+
} : { kind: "missing" };
|
|
734
|
+
}
|
|
735
|
+
function passwordAuthenticationMissingText(resourceType, logicalId) {
|
|
736
|
+
return `${resourceType} ${logicalId}: MasterUserAuthenticationType changes to password, which RDS accepts only beside a master password or the managed one in the same call, and the template declares neither MasterUserPassword nor ManageMasterUserPassword: true. Nothing was applied. Declare one of them.`;
|
|
737
|
+
}
|
|
738
|
+
function masterUserAuthenticationTypeToSend(properties, previousProperties, context) {
|
|
739
|
+
return instanceValueChanged(properties, previousProperties, "MasterUserAuthenticationType", context) ? properties["MasterUserAuthenticationType"] : void 0;
|
|
740
|
+
}
|
|
741
|
+
function managedPasswordOnRemoval(properties, previousProperties) {
|
|
742
|
+
const previous = previousProperties["ManageMasterUserPassword"];
|
|
743
|
+
return properties["ManageMasterUserPassword"] === void 0 && (previous === true || previous === "true");
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
// src/provisioning/providers/rds/cluster-update.ts
|
|
747
|
+
async function updateDBCluster(logicalId, physicalId, resourceType, properties, previousProperties, context) {
|
|
748
|
+
this.logger.debug(`Updating DBCluster ${logicalId}: ${physicalId}`);
|
|
749
|
+
refuseMalformedDesiredTags(properties["Tags"], resourceType, logicalId, physicalId);
|
|
750
|
+
const roles = this.desiredAssociatedRoles(properties, resourceType, logicalId, physicalId, false);
|
|
751
|
+
const logExportConfig = logExportsDelta(desiredLogExports(properties, resourceType, logicalId, physicalId), previousProperties["EnableCloudwatchLogsExports"]);
|
|
752
|
+
const httpEndpointAction = clusterHttpEndpointAction(properties, previousProperties, resourceType, logicalId, physicalId, context);
|
|
753
|
+
if (httpEndpointAction === "skip") this.logger.warn(safeMsg`DBCluster ${logicalId}: the replayed EnableHttpEndpoint is not true or false; the Data API setting is left as it is`);
|
|
754
|
+
if (httpEndpointAction === "withheld") this.logger.warn(safeMsg`DBCluster ${logicalId}: drift --revert does not turn the Data API (EnableHttpEndpoint) back on, because the template does not declare EnableHttpEndpoint: true; declare it and deploy, or turn the Data API on with aws rds enable-http-endpoint`);
|
|
755
|
+
const skippedKeys = httpEndpointAction === "skip" || httpEndpointAction === "withheld" ? [["EnableHttpEndpoint", usableHttpEndpoint]] : [];
|
|
756
|
+
if (retentionPeriodValue(properties["PerformanceInsightsRetentionPeriod"]) === "malformed") {
|
|
757
|
+
if (context?.replayingState !== true && context?.desiredFromAwsReadback !== true) throw markNonRetryable(new ProvisioningError(`${resourceType} ${logicalId}: PerformanceInsightsRetentionPeriod must be a whole number of days`, resourceType, logicalId, physicalId));
|
|
758
|
+
this.logger.warn(safeMsg`DBCluster ${logicalId}: the replayed PerformanceInsightsRetentionPeriod is not a whole number of days; the retention period is left as it is`);
|
|
759
|
+
skippedKeys.push(["PerformanceInsightsRetentionPeriod", usableRetentionPeriod]);
|
|
760
|
+
}
|
|
761
|
+
if (!usableAvailabilityZones(properties["AvailabilityZones"])) {
|
|
762
|
+
if (context?.replayingState !== true && context?.desiredFromAwsReadback !== true) throw markNonRetryable(new ProvisioningError(`${resourceType} ${logicalId}: AvailabilityZones must be a list of Availability Zone names`, resourceType, logicalId, physicalId));
|
|
763
|
+
this.logger.warn(safeMsg`DBCluster ${logicalId}: the replayed AvailabilityZones is not a list of Availability Zone names; the record keeps the previous list`);
|
|
764
|
+
skippedKeys.push(["AvailabilityZones", usableAvailabilityZones]);
|
|
765
|
+
}
|
|
766
|
+
for (const [malformed, key, expected, usable] of [[
|
|
767
|
+
backtrackWindowValue(properties["BacktrackWindow"]) === "malformed",
|
|
768
|
+
"BacktrackWindow",
|
|
769
|
+
"a whole number of seconds",
|
|
770
|
+
usableBacktrackWindow
|
|
771
|
+
], [
|
|
772
|
+
localWriteForwardingFlag(properties["EnableLocalWriteForwarding"]) === "malformed",
|
|
773
|
+
"EnableLocalWriteForwarding",
|
|
774
|
+
"true or false",
|
|
775
|
+
usableLocalWriteForwarding
|
|
776
|
+
]]) {
|
|
777
|
+
if (!malformed) continue;
|
|
778
|
+
if (context?.replayingState !== true && context?.desiredFromAwsReadback !== true) throw markNonRetryable(new ProvisioningError(`${resourceType} ${logicalId}: ${key} must be ${expected}`, resourceType, logicalId, physicalId));
|
|
779
|
+
this.logger.warn(safeMsg`DBCluster ${logicalId}: the replayed ${key} is not ${expected}; the setting is left as it is`);
|
|
780
|
+
skippedKeys.push([key, usable]);
|
|
781
|
+
}
|
|
782
|
+
if (localWriteForwardingToSend(properties, previousProperties, context) === "withheld") {
|
|
783
|
+
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`);
|
|
784
|
+
skippedKeys.push(["EnableLocalWriteForwarding", usableLocalWriteForwarding]);
|
|
785
|
+
}
|
|
786
|
+
let detachedFrom;
|
|
787
|
+
try {
|
|
788
|
+
const globalClusterPlan = await planGlobalClusterUpdate.call(this, physicalId, properties, previousProperties, resourceType, logicalId, context);
|
|
789
|
+
if (globalClusterPlan.kind === "keep") skippedKeys.push(["GlobalClusterIdentifier", usableGlobalClusterId]);
|
|
790
|
+
if (globalClusterPlan.kind === "drop") skippedKeys.push(["GlobalClusterIdentifier", () => false]);
|
|
791
|
+
const engineLifecycleSupport = await this.engineLifecycleSupportToSend("DB cluster", logicalId, physicalId, resourceType, properties, previousProperties, context);
|
|
792
|
+
let authenticationType = masterUserAuthenticationTypeToSend(properties, previousProperties, context);
|
|
793
|
+
let passwordCompanion = passwordAuthenticationCompanion(properties, previousProperties, authenticationType);
|
|
794
|
+
if (passwordCompanion?.kind === "missing" && context?.replayingState === true) {
|
|
795
|
+
this.logger.warn(safeMsg`${logicalId}: the rollback leaves MasterUserAuthenticationType as it is, because the restored properties declare neither MasterUserPassword nor ManageMasterUserPassword: true, which RDS needs beside a switch to password`);
|
|
796
|
+
authenticationType = void 0;
|
|
797
|
+
passwordCompanion = void 0;
|
|
798
|
+
}
|
|
799
|
+
if (passwordCompanion?.kind === "missing") throw markNonRetryable(new ProvisioningError(passwordAuthenticationMissingText(resourceType, logicalId), resourceType, logicalId, physicalId));
|
|
800
|
+
const vpcSgIds = await this.securityGroupsToSend("DBCluster", logicalId, physicalId, resourceType, properties, previousProperties, context);
|
|
801
|
+
const serverlessV2Config = properties["ServerlessV2ScalingConfiguration"];
|
|
802
|
+
const hasServerlessV2 = serverlessV2Config !== void 0 && (serverlessV2Config.MinCapacity !== void 0 || serverlessV2Config.MaxCapacity !== void 0 || serverlessV2Config.SecondsUntilAutoPause !== void 0);
|
|
803
|
+
const masterUserSecret = properties["MasterUserSecret"];
|
|
804
|
+
const sendCredentialSettings = masterCredentialSettingsChanged(properties, previousProperties, context);
|
|
805
|
+
const sendManagedPasswordSetting = managedPasswordSettingRides(sendCredentialSettings, authenticationType);
|
|
806
|
+
const manageMasterUserPasswordOff = managedPasswordOnRemoval(properties, previousProperties);
|
|
807
|
+
const portToSend = clusterPortToSend(properties, previousProperties);
|
|
808
|
+
const engineVersionChanged = clusterEngineVersionChanged(properties, previousProperties, context);
|
|
809
|
+
const scalarMembers = clusterModifyScalarMembers(properties, previousProperties, context);
|
|
810
|
+
if (globalClusterPlan.kind === "detach") {
|
|
811
|
+
if (await this.detachFromGlobalCluster(logicalId, physicalId, globalClusterPlan.globalClusterId, {
|
|
812
|
+
beforeDelete: false,
|
|
813
|
+
removeProtection: false
|
|
814
|
+
}, { stripped: false }, maskerOrIdentity(context?.maskSecrets))) detachedFrom = globalClusterPlan.globalClusterId;
|
|
815
|
+
}
|
|
816
|
+
await this.getClient().send(new ModifyDBClusterCommand({
|
|
817
|
+
DBClusterIdentifier: physicalId,
|
|
818
|
+
...engineVersionChanged && {
|
|
819
|
+
EngineVersion: properties["EngineVersion"],
|
|
820
|
+
AllowMajorVersionUpgrade: true
|
|
821
|
+
},
|
|
822
|
+
DeletionProtection: properties["DeletionProtection"],
|
|
823
|
+
BackupRetentionPeriod: clearOnUpdateRemoval(properties["BackupRetentionPeriod"] != null ? Number(properties["BackupRetentionPeriod"]) : void 0, previousProperties["BackupRetentionPeriod"] != null ? Number(previousProperties["BackupRetentionPeriod"]) : void 0, 1),
|
|
824
|
+
...vpcSgIds !== void 0 && { VpcSecurityGroupIds: vpcSgIds },
|
|
825
|
+
MasterUserPassword: masterUserPasswordToSend(properties, previousProperties, context) ?? (passwordCompanion?.kind === "password" ? passwordCompanion.password : void 0),
|
|
826
|
+
Port: portToSend,
|
|
827
|
+
...sendManagedPasswordSetting && properties["ManageMasterUserPassword"] !== void 0 && { ManageMasterUserPassword: properties["ManageMasterUserPassword"] },
|
|
828
|
+
...manageMasterUserPasswordOff && { ManageMasterUserPassword: false },
|
|
829
|
+
...(sendCredentialSettings || passwordCompanion?.kind === "managed") && masterUserSecret?.KmsKeyId !== void 0 && { MasterUserSecretKmsKeyId: masterUserSecret.KmsKeyId },
|
|
830
|
+
...properties["MonitoringRoleArn"] !== void 0 && { MonitoringRoleArn: properties["MonitoringRoleArn"] },
|
|
831
|
+
...properties["MonitoringInterval"] != null && { MonitoringInterval: Number(properties["MonitoringInterval"]) },
|
|
832
|
+
EnableIAMDatabaseAuthentication: properties["EnableIAMDatabaseAuthentication"],
|
|
833
|
+
...hasServerlessV2 && { ServerlessV2ScalingConfiguration: serverlessV2ScalingToSend(serverlessV2Config) },
|
|
834
|
+
...clusterModifyBackfillMembers(properties, previousProperties, context),
|
|
835
|
+
...scalarMembers,
|
|
836
|
+
...engineLifecycleSupport !== void 0 && { EngineLifecycleSupport: engineLifecycleSupport },
|
|
837
|
+
...authenticationType !== void 0 && { MasterUserAuthenticationType: authenticationType },
|
|
838
|
+
...logExportConfig !== void 0 && { CloudwatchLogsExportConfiguration: logExportConfig },
|
|
839
|
+
ApplyImmediately: true
|
|
840
|
+
}));
|
|
841
|
+
this.logger.debug(`Successfully updated DBCluster ${logicalId}`);
|
|
842
|
+
const noWait = process.env["CDKD_NO_WAIT"] === "true";
|
|
843
|
+
const portChanged = portToSend !== void 0 && portToSend !== numberOrUndefined(previousProperties["Port"]);
|
|
844
|
+
if (!noWait && portChanged) await this.waitForClusterPortApplied(physicalId, logicalId, portToSend);
|
|
845
|
+
if (!noWait && logExportConfig !== void 0) await this.waitForClusterState(logicalId, physicalId, (cluster) => logExportsApplied(logExportConfig, cluster.EnabledCloudwatchLogsExports, cluster.PendingModifiedValues?.PendingCloudwatchLogsExports), "CloudWatch Logs exports");
|
|
846
|
+
const forwardingSent = scalarMembers.EnableLocalWriteForwarding;
|
|
847
|
+
if (!noWait && forwardingSent !== void 0) await this.waitForClusterState(logicalId, physicalId, (cluster) => localWriteForwardingApplied(cluster, forwardingSent), "local write forwarding setting");
|
|
848
|
+
const backtrackSent = scalarMembers.BacktrackWindow;
|
|
849
|
+
if (!noWait && backtrackSent !== void 0) await this.waitForClusterState(logicalId, physicalId, (cluster) => cluster.BacktrackWindow === void 0 || cluster.BacktrackWindow === backtrackSent, "backtrack window");
|
|
850
|
+
const described = await this.describeDBCluster(physicalId);
|
|
851
|
+
if (httpEndpointAction === "enable" || httpEndpointAction === "disable") {
|
|
852
|
+
const arn = described?.DBClusterArn;
|
|
853
|
+
if (!arn) throw new Error(`DescribeDBClusters did not report the cluster ARN, which ${httpEndpointAction === "enable" ? "EnableHttpEndpoint" : "DisableHttpEndpoint"} needs`);
|
|
854
|
+
const enable = httpEndpointAction === "enable";
|
|
855
|
+
await this.sendHttpEndpointChange(logicalId, physicalId, arn, enable);
|
|
856
|
+
if (!noWait) await this.waitForClusterState(logicalId, physicalId, (cluster) => (cluster.HttpEndpointEnabled ?? false) === enable, "HTTP endpoint (Data API) setting");
|
|
857
|
+
}
|
|
858
|
+
if (!noWait && portChanged) {
|
|
859
|
+
for (const member of described?.DBClusterMembers ?? []) if (member.DBInstanceIdentifier) await this.waitForMemberAfterClusterChange(member.DBInstanceIdentifier, logicalId, PORT_CHANGE_MEMBER_STATUSES, "port");
|
|
860
|
+
}
|
|
861
|
+
if (!noWait && securityGroupListChanged(vpcSgIds, previousProperties["VpcSecurityGroupIds"])) {
|
|
862
|
+
await this.waitForSecurityGroupsApplied(physicalId, logicalId, vpcSgIds ?? []);
|
|
863
|
+
for (const member of described?.DBClusterMembers ?? []) if (member.DBInstanceIdentifier) await this.waitForMemberAfterClusterChange(member.DBInstanceIdentifier, logicalId, SECURITY_GROUP_CHANGE_MEMBER_STATUSES, "VPC security groups");
|
|
864
|
+
}
|
|
865
|
+
await this.applyAssociatedRoles("cluster", logicalId, physicalId, roles, associatedRoleList(previousProperties["AssociatedRoles"]) ?? [], context?.maskSecrets, context);
|
|
866
|
+
if (described?.DBClusterArn) await this.applyTagDiff(described.DBClusterArn, resourceType, logicalId, previousProperties["Tags"], properties["Tags"]);
|
|
867
|
+
return {
|
|
868
|
+
physicalId,
|
|
869
|
+
wasReplaced: false,
|
|
870
|
+
attributes: definedAttributes({
|
|
871
|
+
"Endpoint.Address": described?.Endpoint,
|
|
872
|
+
"Endpoint.Port": stringifyIfAssigned(noWait && portChanged && described !== void 0 ? portToSend : described?.Port),
|
|
873
|
+
"ReadEndpoint.Address": described?.ReaderEndpoint,
|
|
874
|
+
Arn: described?.DBClusterArn,
|
|
875
|
+
DBClusterResourceId: described?.DbClusterResourceId
|
|
876
|
+
}),
|
|
877
|
+
...skippedKeys.length > 0 && { effectiveProperties: withPreviousValues(properties, previousProperties, skippedKeys) }
|
|
878
|
+
};
|
|
879
|
+
} catch (error) {
|
|
880
|
+
if (error instanceof ProvisioningError) throw error;
|
|
881
|
+
if (error instanceof GlobalClusterDetachError) throw markNonRetryable(new ProvisioningError(`Failed to update DBCluster ${logicalId}: ${error.message}`, resourceType, logicalId, physicalId, error));
|
|
882
|
+
const cause = error instanceof Error ? error : void 0;
|
|
883
|
+
const detachedNote = detachedFrom !== void 0 ? " (it was already detached from its global cluster, and stays a standalone cluster)" : "";
|
|
884
|
+
throw this.wrapCaughtError(context?.maskSecrets, error, (text) => new ProvisioningError(`Failed to update DBCluster ${logicalId}: ${text}${detachedNote}`, resourceType, logicalId, physicalId, cause));
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
async function planGlobalClusterUpdate(physicalId, properties, previousProperties, resourceType, logicalId, context) {
|
|
888
|
+
const desired = properties["GlobalClusterIdentifier"];
|
|
889
|
+
if (context?.desiredFromAwsReadback === true && desired === void 0) return previousProperties["GlobalClusterIdentifier"] !== void 0 ? { kind: "keep" } : { kind: "none" };
|
|
890
|
+
const mask = maskerOrIdentity(context?.maskSecrets);
|
|
891
|
+
const stateBorne = context?.replayingState === true || context?.desiredFromAwsReadback === true;
|
|
892
|
+
const readable = readableGlobalClusterId(desired);
|
|
893
|
+
const desiredId = recordedGlobalClusterIdentifier(properties);
|
|
894
|
+
const previousId = recordedGlobalClusterIdentifier(previousProperties);
|
|
895
|
+
if (readable && desiredId === previousId) {
|
|
896
|
+
if (!stateBorne || desiredId === void 0) return { kind: "none" };
|
|
897
|
+
const live = await liveGlobalClusterMembership.call(this, physicalId, desiredId);
|
|
898
|
+
if (live.kind !== "answered" || live.member) return { kind: "none" };
|
|
899
|
+
this.logger.warn(mask(safeMsg`${logicalId} (${resourceType}): the cluster is no longer a member of global cluster ${desiredId}, so the record drops GlobalClusterIdentifier.`));
|
|
900
|
+
return { kind: "drop" };
|
|
901
|
+
}
|
|
902
|
+
if (readable && desiredId === void 0 && previousId !== void 0) {
|
|
903
|
+
if (!stateBorne) return {
|
|
904
|
+
kind: "detach",
|
|
905
|
+
globalClusterId: previousId
|
|
906
|
+
};
|
|
907
|
+
const live = await liveGlobalClusterMembership.call(this, physicalId, previousId);
|
|
908
|
+
if (live.kind !== "answered" || live.member) this.logger.warn(mask(safeMsg`${logicalId} (${resourceType}): the restored state has no GlobalClusterIdentifier; cdkd never detaches on a restore, so the cluster stays wherever it is${live.kind === "answered" ? safeMsg` (a member of global cluster ${previousId})` : ""}. A destroy is refused while it is a member: detach it first with aws rds remove-from-global-cluster.`));
|
|
909
|
+
return { kind: "none" };
|
|
910
|
+
}
|
|
911
|
+
let unreadable = "";
|
|
912
|
+
if (readable) {
|
|
913
|
+
const live = await liveGlobalClusterMembership.call(this, physicalId, desiredId);
|
|
914
|
+
if (live.kind === "answered" && live.member) return { kind: "none" };
|
|
915
|
+
if (live.kind === "unreadable") unreadable = ` (cdkd could not read the cluster's global cluster membership: ${live.summary})`;
|
|
916
|
+
}
|
|
917
|
+
if (!stateBorne) throw markNonRetryable(new ProvisioningError(`${resourceType} ${logicalId}: ${readable ? GLOBAL_CLUSTER_CHANGE_REFUSED : "GlobalClusterIdentifier must be a string"}${unreadable}`, resourceType, logicalId, physicalId));
|
|
918
|
+
this.logger.warn(mask(readable ? safeMsg`${logicalId} (${resourceType}): the restored state names global cluster ${desiredId ?? ""}, but cdkd never adds an existing cluster to a global cluster, so it keeps its current membership.` : safeMsg`${logicalId} (${resourceType}): the restored GlobalClusterIdentifier is not a string; the cluster keeps its current membership.`));
|
|
919
|
+
return { kind: "keep" };
|
|
920
|
+
}
|
|
921
|
+
async function liveGlobalClusterMembership(physicalId, desiredId) {
|
|
922
|
+
try {
|
|
923
|
+
const arn = (await this.describeDBCluster(physicalId))?.DBClusterArn;
|
|
924
|
+
if (typeof arn !== "string" || arn === "") return {
|
|
925
|
+
kind: "unreadable",
|
|
926
|
+
summary: "DescribeDBClusters reported no cluster ARN"
|
|
927
|
+
};
|
|
928
|
+
let liveId;
|
|
929
|
+
let marker;
|
|
930
|
+
do {
|
|
931
|
+
const page = await this.getClient().send(new DescribeGlobalClustersCommand({ ...marker !== void 0 && { Marker: marker } }));
|
|
932
|
+
const holder = (page.GlobalClusters ?? []).find((global) => (global.GlobalClusterMembers ?? []).some((member) => member.DBClusterArn === arn));
|
|
933
|
+
if (holder !== void 0) {
|
|
934
|
+
liveId = holder.GlobalClusterIdentifier;
|
|
935
|
+
break;
|
|
936
|
+
}
|
|
937
|
+
marker = page.Marker;
|
|
938
|
+
} while (marker);
|
|
939
|
+
return {
|
|
940
|
+
kind: "answered",
|
|
941
|
+
member: liveId === desiredId
|
|
942
|
+
};
|
|
943
|
+
} catch (error) {
|
|
944
|
+
const failure = describeAwsFailure(error);
|
|
945
|
+
this.logger.debug(safeMsg`Could not read an RDS cluster's global cluster membership: ${failure.summary}`);
|
|
946
|
+
return {
|
|
947
|
+
kind: "unreadable",
|
|
948
|
+
summary: failure.summary
|
|
949
|
+
};
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
// src/provisioning/providers/rds/cluster-delete.ts
|
|
954
|
+
async function deleteDBCluster(logicalId, physicalId, resourceType, properties, context) {
|
|
955
|
+
await deleteWithProtectionCompensation({
|
|
956
|
+
registry: this.protectionFlips,
|
|
957
|
+
key: protectionFlipKey(resourceType, physicalId, context?.expectedRegion),
|
|
958
|
+
run: (flip) => this.deleteDBClusterOnce(logicalId, physicalId, resourceType, properties, context, flip),
|
|
959
|
+
compensation: {
|
|
960
|
+
logicalId,
|
|
961
|
+
physicalId,
|
|
962
|
+
logger: this.logger,
|
|
963
|
+
site: rdsFamilyProtectionSite({
|
|
964
|
+
cliService: "rds",
|
|
965
|
+
serviceLabel: "RDS",
|
|
966
|
+
kind: "cluster",
|
|
967
|
+
physicalId,
|
|
968
|
+
region: context?.expectedRegion,
|
|
969
|
+
notFoundFault: "DBClusterNotFoundFault",
|
|
970
|
+
isNotFound: (error) => this.isNotFoundError(error, "DBClusterNotFoundFault")
|
|
971
|
+
}),
|
|
972
|
+
reEnable: async () => {
|
|
973
|
+
await modifyDbInstanceWhenAvailable({
|
|
974
|
+
send: () => this.getClient().send(new ModifyDBClusterCommand({
|
|
975
|
+
DBClusterIdentifier: physicalId,
|
|
976
|
+
DeletionProtection: true,
|
|
977
|
+
ApplyImmediately: true
|
|
978
|
+
})),
|
|
979
|
+
readStatus: async () => (await this.describeDBCluster(physicalId))?.Status,
|
|
980
|
+
sleep: (ms) => this.sleep(ms),
|
|
981
|
+
logger: this.logger,
|
|
982
|
+
label: "RDS DBCluster",
|
|
983
|
+
subject: "cluster",
|
|
984
|
+
isRefusal: isClusterBusyRefusal,
|
|
985
|
+
logicalId,
|
|
986
|
+
remainingMs: enclosingDeadlineRemainingMs(),
|
|
987
|
+
maxWaitMs: PROTECTION_FLIP_RETRY_WAIT_MS,
|
|
988
|
+
command: "destroy"
|
|
989
|
+
});
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
});
|
|
993
|
+
}
|
|
994
|
+
async function deleteDBClusterOnce(logicalId, physicalId, resourceType, properties, context, flip) {
|
|
995
|
+
this.logger.debug(`Deleting DBCluster ${logicalId}`);
|
|
996
|
+
let detachedFrom;
|
|
997
|
+
const progress = { stripped: false };
|
|
998
|
+
try {
|
|
999
|
+
if (context?.removeProtection === true) try {
|
|
1000
|
+
await observeThenDisableProtection({
|
|
1001
|
+
flip,
|
|
1002
|
+
logger: this.logger,
|
|
1003
|
+
physicalId,
|
|
1004
|
+
mask: context?.maskSecrets,
|
|
1005
|
+
guardName: "DeletionProtection",
|
|
1006
|
+
observe: async () => (await this.describeDBCluster(physicalId))?.DeletionProtection === true,
|
|
1007
|
+
disable: async () => {
|
|
1008
|
+
await modifyDbInstanceWhenAvailable({
|
|
1009
|
+
send: () => this.getClient().send(new ModifyDBClusterCommand({
|
|
1010
|
+
DBClusterIdentifier: physicalId,
|
|
1011
|
+
DeletionProtection: false,
|
|
1012
|
+
ApplyImmediately: true
|
|
1013
|
+
})),
|
|
1014
|
+
readStatus: async () => (await this.describeDBCluster(physicalId))?.Status,
|
|
1015
|
+
sleep: (ms) => this.sleep(ms),
|
|
1016
|
+
logger: this.logger,
|
|
1017
|
+
label: "RDS DBCluster",
|
|
1018
|
+
subject: "cluster",
|
|
1019
|
+
isRefusal: isClusterBusyRefusal,
|
|
1020
|
+
logicalId,
|
|
1021
|
+
remainingMs: enclosingDeadlineRemainingMs(),
|
|
1022
|
+
maxWaitMs: PROTECTION_FLIP_RETRY_WAIT_MS,
|
|
1023
|
+
command: "destroy"
|
|
1024
|
+
});
|
|
1025
|
+
}
|
|
1026
|
+
});
|
|
1027
|
+
this.logger.debug(`Disabled DeletionProtection on DBCluster ${logicalId} before delete`);
|
|
1028
|
+
} catch (disableError) {
|
|
1029
|
+
if (!this.isNotFoundError(disableError, "DBClusterNotFoundFault")) this.logger.debug(maskerOrIdentity(context?.maskSecrets)(`Could not disable deletion protection for DBCluster ${logicalId}: ${describeAwsFailure(disableError).detail}`));
|
|
1030
|
+
}
|
|
1031
|
+
const globalClusterId = recordedGlobalClusterIdentifier(properties);
|
|
1032
|
+
if (globalClusterId !== void 0) detachedFrom = await this.detachFromGlobalCluster(logicalId, physicalId, globalClusterId, {
|
|
1033
|
+
beforeDelete: true,
|
|
1034
|
+
removeProtection: context?.removeProtection === true
|
|
1035
|
+
}, progress, maskerOrIdentity(context?.maskSecrets)) ? globalClusterId : void 0;
|
|
1036
|
+
const finalSnapshotId = context?.finalSnapshotIdentifier;
|
|
1037
|
+
const sendDelete = () => this.getClient().send(new DeleteDBClusterCommand({
|
|
1038
|
+
DBClusterIdentifier: physicalId,
|
|
1039
|
+
...finalSnapshotId ? {
|
|
1040
|
+
SkipFinalSnapshot: false,
|
|
1041
|
+
FinalDBSnapshotIdentifier: finalSnapshotId
|
|
1042
|
+
} : { SkipFinalSnapshot: true },
|
|
1043
|
+
...deleteAutomatedBackupsInput(properties)
|
|
1044
|
+
}));
|
|
1045
|
+
if (finalSnapshotId && flip.flippedOffByThisRun && !flip.deleteAccepted) await this.deleteAfterProtectionFlip(logicalId, physicalId, sendDelete);
|
|
1046
|
+
else await sendDelete();
|
|
1047
|
+
flip.deleteAccepted = true;
|
|
1048
|
+
if (finalSnapshotId) this.logger.info(`Deleting DBCluster ${logicalId} with a final snapshot (DeletionPolicy: Snapshot)`);
|
|
1049
|
+
this.logger.debug(`Successfully initiated deletion of DBCluster ${logicalId}`);
|
|
1050
|
+
await this.waitForClusterDeleted(logicalId, physicalId, RDS_DELETE_WAIT_MS);
|
|
1051
|
+
} catch (error) {
|
|
1052
|
+
if (error instanceof GlobalClusterDetachError) {
|
|
1053
|
+
const detachFailure = markNotGone(markNonRetryable(new ProvisioningError(`Failed to delete DBCluster ${logicalId}: ${error.message}`, resourceType, logicalId, physicalId, error)));
|
|
1054
|
+
throw progress.stripped ? markDeleteStarted(detachFailure) : detachFailure;
|
|
1055
|
+
}
|
|
1056
|
+
if (this.isNotFoundError(error, "DBClusterNotFoundFault")) {
|
|
1057
|
+
const clientRegion = await this.getClient().config.region();
|
|
1058
|
+
assertRegionMatch(clientRegion, context?.expectedRegion, resourceType, logicalId, physicalId);
|
|
1059
|
+
if (context?.failedCreateOrphan === true) this.logger.info(safeMsg` RDS DB cluster ${physicalId} (${logicalId}), which a failed deploy created, is already gone; nothing to delete`);
|
|
1060
|
+
else this.logger.debug(`DBCluster ${logicalId} does not exist, skipping deletion`);
|
|
1061
|
+
return;
|
|
1062
|
+
}
|
|
1063
|
+
const cause = error instanceof Error ? error : void 0;
|
|
1064
|
+
const detachedNote = detachedFrom !== void 0 ? " (it was already detached from its global cluster, and stays a standalone cluster)" : "";
|
|
1065
|
+
const failure = this.wrapDeleteError(context?.maskSecrets, error, (text) => new ProvisioningError(`Failed to delete DBCluster ${logicalId}: ${text}${detachedNote}`, resourceType, logicalId, physicalId, cause));
|
|
1066
|
+
throw progress.stripped ? markDeleteStarted(failure) : failure;
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
async function partialClusterRetiring(dbClusterIdentifier) {
|
|
1070
|
+
try {
|
|
1071
|
+
return (await this.describeDBCluster(dbClusterIdentifier))?.Status === "deleting" ? "deleting" : void 0;
|
|
1072
|
+
} catch (error) {
|
|
1073
|
+
return error instanceof Error && error.name === "DBClusterNotFoundFault" ? "gone" : void 0;
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
function wrapGlobalClusterDetachError(error, mask, build) {
|
|
1077
|
+
const failure = describeAwsFailure(error);
|
|
1078
|
+
if (failure.redacted) this.logger.debug(mask(build(mask(failure.detail))));
|
|
1079
|
+
return new GlobalClusterDetachError(build(mask(failure.summary)));
|
|
1080
|
+
}
|
|
1081
|
+
async function detachFromGlobalCluster(logicalId, physicalId, globalClusterId, { beforeDelete, removeProtection }, progress, mask) {
|
|
1082
|
+
let cluster = await this.describeDBCluster(physicalId);
|
|
1083
|
+
for (let i = 0; removeProtection && cluster?.DeletionProtection === true && i < 6; i++) {
|
|
1084
|
+
await this.sleep(5e3);
|
|
1085
|
+
cluster = await this.describeDBCluster(physicalId);
|
|
1086
|
+
}
|
|
1087
|
+
if (cluster === void 0) return false;
|
|
1088
|
+
if (beforeDelete && cluster.DeletionProtection === true) throw new GlobalClusterDetachError(safeMsg`${physicalId} has deletion protection on, so cdkd did not detach it from global cluster ${globalClusterId}; turn it off (cdkd destroy --remove-protection does) and re-run`);
|
|
1089
|
+
const clusterArn = cluster.DBClusterArn;
|
|
1090
|
+
if (typeof clusterArn !== "string" || clusterArn === "") throw new GlobalClusterDetachError(safeMsg`could not read the ARN of ${physicalId} to detach it from global cluster ${globalClusterId}`);
|
|
1091
|
+
const startTime = Date.now();
|
|
1092
|
+
let delay = 5e3;
|
|
1093
|
+
const backOff = async () => {
|
|
1094
|
+
if (Date.now() - startTime >= RDS_DELETE_WAIT_MS) throw new GlobalClusterDetachError(safeMsg`timed out waiting for ${physicalId} to leave global cluster ${globalClusterId}`);
|
|
1095
|
+
await this.sleep(delay);
|
|
1096
|
+
delay = Math.min(delay * 2, 1e4);
|
|
1097
|
+
};
|
|
1098
|
+
for (;;) {
|
|
1099
|
+
let members;
|
|
1100
|
+
try {
|
|
1101
|
+
members = (await this.getClient().send(new DescribeGlobalClustersCommand({ GlobalClusterIdentifier: globalClusterId }))).GlobalClusters?.[0]?.GlobalClusterMembers ?? [];
|
|
1102
|
+
} catch (error) {
|
|
1103
|
+
const name = awsErrorName(error);
|
|
1104
|
+
if (name === "GlobalClusterNotFoundFault") members = [];
|
|
1105
|
+
else if (!TRANSIENT_DETACH_FAULTS.has(name)) throw this.wrapGlobalClusterDetachError(error, mask, (text) => safeMsg`could not read the members of global cluster ${globalClusterId} to detach ${physicalId} (${text})`);
|
|
1106
|
+
}
|
|
1107
|
+
if (members === void 0) {
|
|
1108
|
+
await backOff();
|
|
1109
|
+
continue;
|
|
1110
|
+
}
|
|
1111
|
+
const own = members.find((member) => member.DBClusterArn === clusterArn);
|
|
1112
|
+
const others = members.filter((member) => member.DBClusterArn !== clusterArn).map((member) => /^arn:[^:]*:rds:[^:]*:[^:]*:cluster:(.+)$/.exec(member.DBClusterArn ?? "")?.[1] ?? "(unnamed)");
|
|
1113
|
+
if (own?.IsWriter === true && others.length > 0) throw new GlobalClusterDetachError(mask(safeMsg`${physicalId} is the primary of global cluster ${globalClusterId}, which still has other members (${others.join(", ")}); detach or delete them first, then re-run`));
|
|
1114
|
+
break;
|
|
1115
|
+
}
|
|
1116
|
+
for (;;) try {
|
|
1117
|
+
await this.getClient().send(new RemoveFromGlobalClusterCommand({
|
|
1118
|
+
GlobalClusterIdentifier: globalClusterId,
|
|
1119
|
+
DbClusterIdentifier: clusterArn
|
|
1120
|
+
}));
|
|
1121
|
+
progress.stripped = true;
|
|
1122
|
+
this.logger.info(mask(beforeDelete ? safeMsg`Detaching DBCluster ${logicalId} from global cluster ${globalClusterId} before the delete` : safeMsg`Detaching DBCluster ${logicalId} from global cluster ${globalClusterId}: GlobalClusterIdentifier was removed`));
|
|
1123
|
+
break;
|
|
1124
|
+
} catch (error) {
|
|
1125
|
+
const name = awsErrorName(error);
|
|
1126
|
+
if (name === "GlobalClusterNotFoundFault") return false;
|
|
1127
|
+
if (name === "DBClusterNotFoundFault") break;
|
|
1128
|
+
if (!TRANSIENT_DETACH_FAULTS.has(name)) throw this.wrapGlobalClusterDetachError(error, mask, (text) => safeMsg`detaching ${physicalId} from global cluster ${globalClusterId} failed (${text})`);
|
|
1129
|
+
await backOff();
|
|
1130
|
+
}
|
|
1131
|
+
for (;;) {
|
|
1132
|
+
let stillMember;
|
|
1133
|
+
try {
|
|
1134
|
+
stillMember = ((await this.getClient().send(new DescribeGlobalClustersCommand({ GlobalClusterIdentifier: globalClusterId }))).GlobalClusters?.[0]?.GlobalClusterMembers ?? []).some((member) => member.DBClusterArn === clusterArn);
|
|
1135
|
+
} catch (error) {
|
|
1136
|
+
const name = awsErrorName(error);
|
|
1137
|
+
if (name === "GlobalClusterNotFoundFault") stillMember = false;
|
|
1138
|
+
else if (!TRANSIENT_DETACH_FAULTS.has(name)) throw this.wrapGlobalClusterDetachError(error, mask, (text) => safeMsg`could not confirm ${physicalId} left global cluster ${globalClusterId} (${text})`);
|
|
1139
|
+
}
|
|
1140
|
+
if (stillMember === false) {
|
|
1141
|
+
const after = await this.describeDBCluster(physicalId);
|
|
1142
|
+
if (after === void 0) return true;
|
|
1143
|
+
this.logger.debug(safeMsg`DBCluster ${physicalId} status after the detach: ${after.Status}`);
|
|
1144
|
+
if (after.Status === "available") return true;
|
|
1145
|
+
}
|
|
1146
|
+
await backOff();
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
async function deleteAfterProtectionFlip(logicalId, physicalId, send) {
|
|
1150
|
+
await deleteAfterProtectionFlipWithFinalSnapshot({
|
|
1151
|
+
stateFault: "InvalidDBClusterStateFault",
|
|
1152
|
+
send,
|
|
1153
|
+
noun: "cluster",
|
|
1154
|
+
label: "DBCluster",
|
|
1155
|
+
logicalId,
|
|
1156
|
+
read: async () => {
|
|
1157
|
+
const current = await this.describeDBCluster(physicalId);
|
|
1158
|
+
return current === void 0 ? void 0 : {
|
|
1159
|
+
deletionProtection: current.DeletionProtection,
|
|
1160
|
+
status: current.Status
|
|
1161
|
+
};
|
|
1162
|
+
},
|
|
1163
|
+
sleep: (ms) => this.sleep(ms),
|
|
1164
|
+
logger: this.logger,
|
|
1165
|
+
remainingMs: enclosingDeadlineRemainingMs()
|
|
1166
|
+
});
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
// src/provisioning/providers/rds/instance-create.ts
|
|
1170
|
+
async function createDBInstance(logicalId, resourceType, properties, mask, replaying = false) {
|
|
1171
|
+
this.logger.debug(`Creating DBInstance ${logicalId}`);
|
|
1172
|
+
const tags = refuseMalformedDesiredTags(properties["Tags"], resourceType, logicalId);
|
|
1173
|
+
const roles = this.desiredAssociatedRoles(properties, resourceType, logicalId, void 0, replaying);
|
|
1174
|
+
const logExports = desiredLogExports(properties, resourceType, logicalId);
|
|
1175
|
+
const dbInstanceIdentifier = properties["DBInstanceIdentifier"] || generatedNameFor("AWS::RDS::DBInstance", logicalId);
|
|
1176
|
+
let instanceCreated = false;
|
|
1177
|
+
let createdResourceId;
|
|
1178
|
+
try {
|
|
1179
|
+
const masterUserSecret = properties["MasterUserSecret"];
|
|
1180
|
+
const response = await this.getCreateClient().send(new CreateDBInstanceCommand({
|
|
1181
|
+
DBInstanceIdentifier: dbInstanceIdentifier,
|
|
1182
|
+
DBInstanceClass: properties["DBInstanceClass"],
|
|
1183
|
+
Engine: properties["Engine"],
|
|
1184
|
+
DBClusterIdentifier: properties["DBClusterIdentifier"],
|
|
1185
|
+
DBSubnetGroupName: properties["DBSubnetGroupName"],
|
|
1186
|
+
PubliclyAccessible: properties["PubliclyAccessible"],
|
|
1187
|
+
...properties["AllocatedStorage"] !== void 0 && { AllocatedStorage: Number(properties["AllocatedStorage"]) },
|
|
1188
|
+
...properties["MasterUsername"] !== void 0 && { MasterUsername: properties["MasterUsername"] },
|
|
1189
|
+
...properties["DeletionProtection"] !== void 0 && { DeletionProtection: properties["DeletionProtection"] },
|
|
1190
|
+
...properties["EngineVersion"] !== void 0 && { EngineVersion: properties["EngineVersion"] },
|
|
1191
|
+
...properties["Port"] !== void 0 && { Port: Number(properties["Port"]) },
|
|
1192
|
+
...properties["MasterUserPassword"] !== void 0 && { MasterUserPassword: properties["MasterUserPassword"] },
|
|
1193
|
+
...properties["StorageEncrypted"] !== void 0 && { StorageEncrypted: properties["StorageEncrypted"] },
|
|
1194
|
+
...properties["VPCSecurityGroups"] !== void 0 && { VpcSecurityGroupIds: properties["VPCSecurityGroups"] },
|
|
1195
|
+
...properties["KmsKeyId"] !== void 0 && { KmsKeyId: properties["KmsKeyId"] },
|
|
1196
|
+
...masterUserSecret?.KmsKeyId !== void 0 && { MasterUserSecretKmsKeyId: masterUserSecret.KmsKeyId },
|
|
1197
|
+
...properties["ManageMasterUserPassword"] !== void 0 && { ManageMasterUserPassword: properties["ManageMasterUserPassword"] },
|
|
1198
|
+
...properties["MonitoringRoleArn"] !== void 0 && { MonitoringRoleArn: properties["MonitoringRoleArn"] },
|
|
1199
|
+
...properties["MonitoringInterval"] !== void 0 && { MonitoringInterval: Number(properties["MonitoringInterval"]) },
|
|
1200
|
+
...properties["EnableIAMDatabaseAuthentication"] !== void 0 && { EnableIAMDatabaseAuthentication: properties["EnableIAMDatabaseAuthentication"] },
|
|
1201
|
+
...properties["BackupRetentionPeriod"] != null && { BackupRetentionPeriod: Number(properties["BackupRetentionPeriod"]) },
|
|
1202
|
+
...properties["PreferredBackupWindow"] != null && { PreferredBackupWindow: properties["PreferredBackupWindow"] },
|
|
1203
|
+
...properties["PreferredMaintenanceWindow"] != null && { PreferredMaintenanceWindow: properties["PreferredMaintenanceWindow"] },
|
|
1204
|
+
...properties["StorageType"] != null && { StorageType: properties["StorageType"] },
|
|
1205
|
+
...properties["Iops"] != null && { Iops: Number(properties["Iops"]) },
|
|
1206
|
+
...properties["StorageThroughput"] != null && { StorageThroughput: Number(properties["StorageThroughput"]) },
|
|
1207
|
+
...properties["MaxAllocatedStorage"] != null && { MaxAllocatedStorage: Number(properties["MaxAllocatedStorage"]) },
|
|
1208
|
+
...properties["MultiAZ"] != null && { MultiAZ: properties["MultiAZ"] },
|
|
1209
|
+
...properties["AutoMinorVersionUpgrade"] != null && { AutoMinorVersionUpgrade: properties["AutoMinorVersionUpgrade"] },
|
|
1210
|
+
...properties["CopyTagsToSnapshot"] != null && { CopyTagsToSnapshot: properties["CopyTagsToSnapshot"] },
|
|
1211
|
+
...properties["OptionGroupName"] != null && { OptionGroupName: properties["OptionGroupName"] },
|
|
1212
|
+
...properties["CACertificateIdentifier"] != null && { CACertificateIdentifier: properties["CACertificateIdentifier"] },
|
|
1213
|
+
...String(properties["EnablePerformanceInsights"]) === "true" && {
|
|
1214
|
+
EnablePerformanceInsights: true,
|
|
1215
|
+
...properties["PerformanceInsightsKMSKeyId"] != null && { PerformanceInsightsKMSKeyId: properties["PerformanceInsightsKMSKeyId"] }
|
|
1216
|
+
},
|
|
1217
|
+
...properties["PerformanceInsightsRetentionPeriod"] != null && { PerformanceInsightsRetentionPeriod: Number(properties["PerformanceInsightsRetentionPeriod"]) },
|
|
1218
|
+
...properties["NetworkType"] != null && { NetworkType: properties["NetworkType"] },
|
|
1219
|
+
...properties["LicenseModel"] != null && { LicenseModel: properties["LicenseModel"] },
|
|
1220
|
+
...properties["PromotionTier"] != null && { PromotionTier: Number(properties["PromotionTier"]) },
|
|
1221
|
+
...properties["DatabaseInsightsMode"] != null && { DatabaseInsightsMode: properties["DatabaseInsightsMode"] },
|
|
1222
|
+
...properties["DedicatedLogVolume"] != null && { DedicatedLogVolume: properties["DedicatedLogVolume"] },
|
|
1223
|
+
...engineLifecycleSupportOf(properties) !== void 0 && { EngineLifecycleSupport: engineLifecycleSupportOf(properties) },
|
|
1224
|
+
...properties["MasterUserAuthenticationType"] != null && { MasterUserAuthenticationType: properties["MasterUserAuthenticationType"] },
|
|
1225
|
+
...properties["DBParameterGroupName"] != null && { DBParameterGroupName: properties["DBParameterGroupName"] },
|
|
1226
|
+
...logExports !== void 0 && logExports.length > 0 && { EnableCloudwatchLogsExports: logExports },
|
|
1227
|
+
...properties["DBName"] != null && { DBName: properties["DBName"] },
|
|
1228
|
+
...properties["AvailabilityZone"] != null && { AvailabilityZone: properties["AvailabilityZone"] },
|
|
1229
|
+
...tags.length > 0 && { Tags: tags }
|
|
1230
|
+
}));
|
|
1231
|
+
instanceCreated = true;
|
|
1232
|
+
createdResourceId = response.DBInstance?.DbiResourceId;
|
|
1233
|
+
reportCreatedResource(logicalId, resourceType, dbInstanceIdentifier, createdResourceId);
|
|
1234
|
+
if (!response.DBInstance) throw new Error("CreateDBInstance did not return DBInstance");
|
|
1235
|
+
this.logger.debug(`Successfully created DBInstance ${logicalId}: ${dbInstanceIdentifier}`);
|
|
1236
|
+
if (process.env["CDKD_NO_WAIT"] !== "true") await this.waitForInstanceAvailable(logicalId, dbInstanceIdentifier);
|
|
1237
|
+
if (roles !== "skipped") try {
|
|
1238
|
+
await this.applyAssociatedRoles("instance", logicalId, dbInstanceIdentifier, roles, [], mask, void 0);
|
|
1239
|
+
} catch (roleError) {
|
|
1240
|
+
markAuxiliaryFailure(roleError, logicalId);
|
|
1241
|
+
throw roleError;
|
|
1242
|
+
}
|
|
1243
|
+
const described = await this.describeDBInstance(dbInstanceIdentifier);
|
|
1244
|
+
return {
|
|
1245
|
+
physicalId: dbInstanceIdentifier,
|
|
1246
|
+
attributes: definedAttributes({
|
|
1247
|
+
"Endpoint.Address": described?.Endpoint?.Address,
|
|
1248
|
+
"Endpoint.Port": stringifyIfAssigned(described?.Endpoint?.Port),
|
|
1249
|
+
Arn: described?.DBInstanceArn
|
|
1250
|
+
}),
|
|
1251
|
+
...roles === "skipped" && { effectiveProperties: Object.fromEntries(Object.entries(properties).filter(([key]) => key !== "AssociatedRoles")) }
|
|
1252
|
+
};
|
|
1253
|
+
} catch (error) {
|
|
1254
|
+
const thrown = error instanceof ProvisioningError ? error : this.wrapCaughtError(mask, error, (text) => new ProvisioningError(`Failed to create DBInstance ${logicalId}: ${text}`, resourceType, logicalId, dbInstanceIdentifier, error instanceof Error ? error : void 0));
|
|
1255
|
+
if (instanceCreated) markCreatedBeforeFailure(thrown, logicalId, resourceType, dbInstanceIdentifier, createdResourceId);
|
|
1256
|
+
throw thrown;
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
// src/provisioning/providers/rds/instance-update.ts
|
|
1261
|
+
async function updateDBInstance(logicalId, physicalId, resourceType, properties, previousProperties, context) {
|
|
1262
|
+
this.logger.debug(`Updating DBInstance ${logicalId}: ${physicalId}`);
|
|
1263
|
+
refuseMalformedDesiredTags(properties["Tags"], resourceType, logicalId, physicalId);
|
|
1264
|
+
const roles = this.desiredAssociatedRoles(properties, resourceType, logicalId, physicalId, false);
|
|
1265
|
+
const logExportConfig = logExportsDelta(desiredLogExports(properties, resourceType, logicalId, physicalId), previousProperties["EnableCloudwatchLogsExports"]);
|
|
1266
|
+
const vpcSgIds = await this.securityGroupsToSend("DBInstance", logicalId, physicalId, resourceType, properties, previousProperties, context);
|
|
1267
|
+
const engineLifecycleSupport = await this.engineLifecycleSupportToSend("DB instance", logicalId, physicalId, resourceType, properties, previousProperties, context);
|
|
1268
|
+
let authenticationType = masterUserAuthenticationTypeToSend(properties, previousProperties, context);
|
|
1269
|
+
let passwordCompanion = passwordAuthenticationCompanion(properties, previousProperties, authenticationType);
|
|
1270
|
+
if (passwordCompanion?.kind === "missing" && context?.replayingState === true) {
|
|
1271
|
+
this.logger.warn(safeMsg`${logicalId}: the rollback leaves MasterUserAuthenticationType as it is, because the restored properties declare neither MasterUserPassword nor ManageMasterUserPassword: true, which RDS needs beside a switch to password`);
|
|
1272
|
+
authenticationType = void 0;
|
|
1273
|
+
passwordCompanion = void 0;
|
|
1274
|
+
}
|
|
1275
|
+
if (passwordCompanion?.kind === "missing") throw markNonRetryable(new ProvisioningError(passwordAuthenticationMissingText(resourceType, logicalId), resourceType, logicalId, physicalId));
|
|
1276
|
+
try {
|
|
1277
|
+
const { mask: zoneMask } = withDerivedNameMasks(this.logger, createMaskedLogSinks(this.logger, context?.maskSecrets), [[previousProperties["DBInstanceIdentifier"], physicalId]]);
|
|
1278
|
+
const desiredZone = properties["AvailabilityZone"];
|
|
1279
|
+
let zoneKept = context?.desiredFromAwsReadback === true || context?.replayingState === true && (desiredZone == null || desiredZone === "") || instanceAvailabilityZoneKept(properties, previousProperties);
|
|
1280
|
+
let liveZoneRead = "read";
|
|
1281
|
+
if (!zoneKept && typeof desiredZone === "string" && desiredZone !== "") zoneKept = await this.describeDBInstance(physicalId).then((instance) => {
|
|
1282
|
+
if (instance === void 0) liveZoneRead = "not-found";
|
|
1283
|
+
return instance?.AvailabilityZone;
|
|
1284
|
+
}, (err) => {
|
|
1285
|
+
liveZoneRead = err?.name === "DBInstanceNotFoundFault" ? "not-found" : "unreadable";
|
|
1286
|
+
this.logger.debug(zoneMask(safeMsg`DBInstance ${logicalId}: could not read the live zone: ${describeAwsFailure(err).summary}`));
|
|
1287
|
+
}) === desiredZone;
|
|
1288
|
+
if (!zoneKept && context?.replayingState !== true) throw new ResourceUpdateNotSupportedError(resourceType, logicalId, zoneMask(`AvailabilityZone cannot change on an existing DB instance — ModifyDBInstance has no such member, and CloudFormation refuses the same update ("Resource is immutable"). Nothing was applied to DB instance ${physicalId}. ` + (liveZoneRead === "not-found" ? "RDS reports no such DB instance: it was deleted outside cdkd, so the state record no longer matches AWS. " : liveZoneRead === "unreadable" ? "cdkd could not read the instance's live zone (an AWS read failed), so it could not tell whether the instance already sits in the declared one; a re-run may succeed. " : "") + "To keep the instance where it is, declare the zone the previous deploy declared (or none, if it declared none), or drop the zone and declare MultiAZ: true. The replace flags below apply to the WHOLE deploy: every other stateful resource in the same run whose in-place update is refused or that needs a replacement is recreated too, so run them with nothing else pending. To move it, " + (String(previousProperties["DeletionProtection"]) === "true" ? protectedReplacementAdvice({
|
|
1289
|
+
evidence: "cdkd's properties for this DB instance carry DeletionProtection: true",
|
|
1290
|
+
replaceFlags: "cdkd deploy --replace --force-stateful-recreation",
|
|
1291
|
+
disable: {
|
|
1292
|
+
before: "aws rds modify-db-instance --db-instance-identifier",
|
|
1293
|
+
identifier: physicalId,
|
|
1294
|
+
after: "--no-deletion-protection --apply-immediately",
|
|
1295
|
+
maskSecrets: zoneMask
|
|
1296
|
+
}
|
|
1297
|
+
}) : "note AWS::RDS::DBInstance is a stateful type: re-run with cdkd deploy --replace --force-stateful-recreation to recreate it in the new zone (this deletes the instance and its data)")));
|
|
1298
|
+
if (!zoneKept) this.logger.warn(zoneMask(safeMsg`DBInstance ${logicalId} (${physicalId}): AvailabilityZone cannot change in place ` + safeMsg`(ModifyDBInstance has no such member), so the instance keeps its current zone ` + safeMsg`and cdkd records that zone.`));
|
|
1299
|
+
const effectiveProperties = zoneKept ? void 0 : withPreviousAvailabilityZone(properties, previousProperties);
|
|
1300
|
+
const masterUserSecret = properties["MasterUserSecret"];
|
|
1301
|
+
const sendCredentialSettings = masterCredentialSettingsChanged(properties, previousProperties, context);
|
|
1302
|
+
const sendManagedPasswordSetting = managedPasswordSettingRides(sendCredentialSettings, authenticationType);
|
|
1303
|
+
const instancePassword = masterUserPasswordToSend(properties, previousProperties, context) ?? (passwordCompanion?.kind === "password" ? passwordCompanion.password : void 0);
|
|
1304
|
+
const manageMasterUserPasswordOff = managedPasswordOnRemoval(properties, previousProperties);
|
|
1305
|
+
let liveInstance;
|
|
1306
|
+
const backfillMembers = await instanceModifyBackfillMembers(properties, previousProperties, () => liveInstance ??= this.describeDBInstance(physicalId).then((instance) => instance?.AllocatedStorage), logicalId, context);
|
|
1307
|
+
await modifyDbInstanceWhenAvailable({
|
|
1308
|
+
send: () => this.getClient().send(new ModifyDBInstanceCommand({
|
|
1309
|
+
DBInstanceIdentifier: physicalId,
|
|
1310
|
+
DBInstanceClass: properties["DBInstanceClass"],
|
|
1311
|
+
PubliclyAccessible: properties["PubliclyAccessible"],
|
|
1312
|
+
ApplyImmediately: true,
|
|
1313
|
+
...backfillMembers,
|
|
1314
|
+
DeletionProtection: properties["DeletionProtection"],
|
|
1315
|
+
...previousProperties["Engine"] !== properties["Engine"] && dbInstanceEngineChangeIsInPlace(previousProperties["Engine"], properties["Engine"]) && { Engine: properties["Engine"] },
|
|
1316
|
+
...properties["Port"] !== void 0 && { DBPortNumber: Number(properties["Port"]) },
|
|
1317
|
+
...instancePassword !== void 0 && { MasterUserPassword: instancePassword },
|
|
1318
|
+
...vpcSgIds !== void 0 && { VpcSecurityGroupIds: vpcSgIds },
|
|
1319
|
+
...(sendCredentialSettings || passwordCompanion?.kind === "managed") && masterUserSecret?.KmsKeyId !== void 0 && { MasterUserSecretKmsKeyId: masterUserSecret.KmsKeyId },
|
|
1320
|
+
...sendManagedPasswordSetting && properties["ManageMasterUserPassword"] !== void 0 && { ManageMasterUserPassword: properties["ManageMasterUserPassword"] },
|
|
1321
|
+
...manageMasterUserPasswordOff && { ManageMasterUserPassword: false },
|
|
1322
|
+
...properties["MonitoringRoleArn"] !== void 0 && { MonitoringRoleArn: properties["MonitoringRoleArn"] },
|
|
1323
|
+
...properties["MonitoringInterval"] != null && { MonitoringInterval: Number(properties["MonitoringInterval"]) },
|
|
1324
|
+
EnableIAMDatabaseAuthentication: properties["EnableIAMDatabaseAuthentication"],
|
|
1325
|
+
...logExportConfig !== void 0 && { CloudwatchLogsExportConfiguration: logExportConfig },
|
|
1326
|
+
...engineLifecycleSupport !== void 0 && { EngineLifecycleSupport: engineLifecycleSupport },
|
|
1327
|
+
...authenticationType !== void 0 && { MasterUserAuthenticationType: authenticationType }
|
|
1328
|
+
})),
|
|
1329
|
+
readStatus: async () => (await this.describeDBInstance(physicalId))?.DBInstanceStatus,
|
|
1330
|
+
sleep: (ms) => this.sleep(ms),
|
|
1331
|
+
logger: this.logger,
|
|
1332
|
+
label: "RDS DBInstance",
|
|
1333
|
+
logicalId,
|
|
1334
|
+
remainingMs: enclosingDeadlineRemainingMs()
|
|
1335
|
+
});
|
|
1336
|
+
this.logger.debug(`Successfully updated DBInstance ${logicalId}`);
|
|
1337
|
+
if (process.env["CDKD_NO_WAIT"] !== "true" && logExportConfig !== void 0) await this.waitForInstanceState(logicalId, physicalId, (instance) => logExportsApplied(logExportConfig, instance.EnabledCloudwatchLogsExports, instance.PendingModifiedValues?.PendingCloudwatchLogsExports), "CloudWatch Logs exports change");
|
|
1338
|
+
let described = await this.describeDBInstance(physicalId);
|
|
1339
|
+
const sentGroup = backfillMembers.DBParameterGroupName;
|
|
1340
|
+
if (sentGroup !== void 0 || instanceParameterGroupPendingReboot(described) || instanceParameterGroupApplying(described)) described = await this.rebootForPendingParameterGroup(logicalId, physicalId, sentGroup, String(properties["CertificateRotationRestart"]) === "true");
|
|
1341
|
+
await this.applyAssociatedRoles("instance", logicalId, physicalId, roles, associatedRoleList(previousProperties["AssociatedRoles"], { featureNameRequired: true }) ?? [], context?.maskSecrets, context);
|
|
1342
|
+
if (described?.DBInstanceArn) await this.applyTagDiff(described.DBInstanceArn, resourceType, logicalId, previousProperties["Tags"], properties["Tags"]);
|
|
1343
|
+
return {
|
|
1344
|
+
physicalId,
|
|
1345
|
+
wasReplaced: false,
|
|
1346
|
+
attributes: definedAttributes({
|
|
1347
|
+
"Endpoint.Address": described?.Endpoint?.Address,
|
|
1348
|
+
"Endpoint.Port": stringifyIfAssigned(described?.Endpoint?.Port),
|
|
1349
|
+
Arn: described?.DBInstanceArn
|
|
1350
|
+
}),
|
|
1351
|
+
...effectiveProperties !== void 0 && { effectiveProperties }
|
|
1352
|
+
};
|
|
1353
|
+
} catch (error) {
|
|
1354
|
+
if (error instanceof ResourceUpdateNotSupportedError) throw error;
|
|
1355
|
+
const cause = error instanceof Error ? error : void 0;
|
|
1356
|
+
throw this.wrapCaughtError(context?.maskSecrets, error, (text) => new ProvisioningError(`Failed to update DBInstance ${logicalId}: ${text}`, resourceType, logicalId, physicalId, cause));
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1360
|
+
// src/provisioning/providers/rds/instance-delete.ts
|
|
1361
|
+
async function deleteDBInstance(logicalId, physicalId, resourceType, properties, context) {
|
|
1362
|
+
await deleteWithProtectionCompensation({
|
|
1363
|
+
registry: this.protectionFlips,
|
|
1364
|
+
key: protectionFlipKey(resourceType, physicalId, context?.expectedRegion),
|
|
1365
|
+
run: (flip) => this.deleteDBInstanceOnce(logicalId, physicalId, resourceType, properties, context, flip),
|
|
1366
|
+
compensation: {
|
|
1367
|
+
logicalId,
|
|
1368
|
+
physicalId,
|
|
1369
|
+
logger: this.logger,
|
|
1370
|
+
site: rdsFamilyProtectionSite({
|
|
1371
|
+
cliService: "rds",
|
|
1372
|
+
serviceLabel: "RDS",
|
|
1373
|
+
kind: "instance",
|
|
1374
|
+
physicalId,
|
|
1375
|
+
region: context?.expectedRegion,
|
|
1376
|
+
notFoundFault: "DBInstanceNotFoundFault",
|
|
1377
|
+
isNotFound: (error) => this.isNotFoundError(error, "DBInstanceNotFoundFault")
|
|
1378
|
+
}),
|
|
1379
|
+
reEnable: async () => {
|
|
1380
|
+
await modifyDbInstanceWhenAvailable({
|
|
1381
|
+
send: () => this.getClient().send(new ModifyDBInstanceCommand({
|
|
1382
|
+
DBInstanceIdentifier: physicalId,
|
|
1383
|
+
DeletionProtection: true,
|
|
1384
|
+
ApplyImmediately: true
|
|
1385
|
+
})),
|
|
1386
|
+
readStatus: async () => (await this.describeDBInstance(physicalId))?.DBInstanceStatus,
|
|
1387
|
+
sleep: (ms) => this.sleep(ms),
|
|
1388
|
+
logger: this.logger,
|
|
1389
|
+
label: "RDS DBInstance",
|
|
1390
|
+
logicalId,
|
|
1391
|
+
remainingMs: enclosingDeadlineRemainingMs(),
|
|
1392
|
+
maxWaitMs: PROTECTION_FLIP_RETRY_WAIT_MS,
|
|
1393
|
+
command: "destroy"
|
|
1394
|
+
});
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1397
|
+
});
|
|
1398
|
+
}
|
|
1399
|
+
async function deleteDBInstanceOnce(logicalId, physicalId, resourceType, properties, context, flip) {
|
|
1400
|
+
this.logger.debug(`Deleting DBInstance ${logicalId}`);
|
|
1401
|
+
try {
|
|
1402
|
+
if (context?.removeProtection === true) try {
|
|
1403
|
+
await observeThenDisableProtection({
|
|
1404
|
+
flip,
|
|
1405
|
+
logger: this.logger,
|
|
1406
|
+
physicalId,
|
|
1407
|
+
mask: context?.maskSecrets,
|
|
1408
|
+
guardName: "DeletionProtection",
|
|
1409
|
+
observe: async () => (await this.describeDBInstance(physicalId))?.DeletionProtection === true,
|
|
1410
|
+
disable: async () => {
|
|
1411
|
+
await modifyDbInstanceWhenAvailable({
|
|
1412
|
+
send: () => this.getClient().send(new ModifyDBInstanceCommand({
|
|
1413
|
+
DBInstanceIdentifier: physicalId,
|
|
1414
|
+
DeletionProtection: false,
|
|
1415
|
+
ApplyImmediately: true
|
|
1416
|
+
})),
|
|
1417
|
+
readStatus: async () => (await this.describeDBInstance(physicalId))?.DBInstanceStatus,
|
|
1418
|
+
sleep: (ms) => this.sleep(ms),
|
|
1419
|
+
logger: this.logger,
|
|
1420
|
+
label: "RDS DBInstance",
|
|
1421
|
+
logicalId,
|
|
1422
|
+
remainingMs: enclosingDeadlineRemainingMs(),
|
|
1423
|
+
maxWaitMs: PROTECTION_FLIP_RETRY_WAIT_MS,
|
|
1424
|
+
command: "destroy"
|
|
1425
|
+
});
|
|
1426
|
+
}
|
|
1427
|
+
});
|
|
1428
|
+
this.logger.debug(`Disabled DeletionProtection on DBInstance ${logicalId} before delete`);
|
|
1429
|
+
} catch (disableError) {
|
|
1430
|
+
if (!this.isNotFoundError(disableError, "DBInstanceNotFoundFault")) this.logger.debug(maskerOrIdentity(context?.maskSecrets)(`Could not disable deletion protection for DBInstance ${logicalId}: ${describeAwsFailure(disableError).detail}`));
|
|
1431
|
+
}
|
|
1432
|
+
const finalSnapshotId = properties?.["DBClusterIdentifier"] === void 0 ? context?.finalSnapshotIdentifier : void 0;
|
|
1433
|
+
const sendDelete = () => this.getClient().send(new DeleteDBInstanceCommand({
|
|
1434
|
+
DBInstanceIdentifier: physicalId,
|
|
1435
|
+
...finalSnapshotId ? {
|
|
1436
|
+
SkipFinalSnapshot: false,
|
|
1437
|
+
FinalDBSnapshotIdentifier: finalSnapshotId
|
|
1438
|
+
} : { SkipFinalSnapshot: true },
|
|
1439
|
+
...deleteAutomatedBackupsInput(properties)
|
|
1440
|
+
}));
|
|
1441
|
+
if (finalSnapshotId && flip.flippedOffByThisRun && !flip.deleteAccepted) await this.deleteInstanceAfterProtectionFlip(logicalId, physicalId, sendDelete);
|
|
1442
|
+
else await sendDelete();
|
|
1443
|
+
flip.deleteAccepted = true;
|
|
1444
|
+
if (finalSnapshotId) this.logger.info(`Deleting DBInstance ${logicalId} with a final snapshot (DeletionPolicy: Snapshot)`);
|
|
1445
|
+
this.logger.debug(`Successfully initiated deletion of DBInstance ${logicalId}`);
|
|
1446
|
+
await this.waitForInstanceDeleted(logicalId, physicalId, RDS_DELETE_WAIT_MS);
|
|
1447
|
+
} catch (error) {
|
|
1448
|
+
if (this.isNotFoundError(error, "DBInstanceNotFoundFault")) {
|
|
1449
|
+
const clientRegion = await this.getClient().config.region();
|
|
1450
|
+
assertRegionMatch(clientRegion, context?.expectedRegion, resourceType, logicalId, physicalId);
|
|
1451
|
+
if (context?.failedCreateOrphan === true) this.logger.info(safeMsg` RDS DB instance ${physicalId} (${logicalId}), which a failed deploy created, is already gone; nothing to delete`);
|
|
1452
|
+
else this.logger.debug(`DBInstance ${logicalId} does not exist, skipping deletion`);
|
|
1453
|
+
return;
|
|
1454
|
+
}
|
|
1455
|
+
const cause = error instanceof Error ? error : void 0;
|
|
1456
|
+
throw this.wrapDeleteError(context?.maskSecrets, error, (text) => new ProvisioningError(`Failed to delete DBInstance ${logicalId}: ${text}`, resourceType, logicalId, physicalId, cause));
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1459
|
+
async function deleteInstanceAfterProtectionFlip(logicalId, physicalId, send) {
|
|
1460
|
+
await deleteAfterProtectionFlipWithFinalSnapshot({
|
|
1461
|
+
stateFault: "InvalidDBInstanceStateFault",
|
|
1462
|
+
send,
|
|
1463
|
+
noun: "instance",
|
|
1464
|
+
label: "DBInstance",
|
|
1465
|
+
logicalId,
|
|
1466
|
+
read: async () => {
|
|
1467
|
+
const current = await this.describeDBInstance(physicalId);
|
|
1468
|
+
return current === void 0 ? void 0 : {
|
|
1469
|
+
deletionProtection: current.DeletionProtection,
|
|
1470
|
+
status: current.DBInstanceStatus
|
|
1471
|
+
};
|
|
1472
|
+
},
|
|
1473
|
+
sleep: (ms) => this.sleep(ms),
|
|
1474
|
+
logger: this.logger,
|
|
1475
|
+
remainingMs: enclosingDeadlineRemainingMs()
|
|
1476
|
+
});
|
|
1477
|
+
}
|
|
1478
|
+
|
|
1479
|
+
// src/provisioning/providers/rds/calls.ts
|
|
1480
|
+
async function applyTagDiff(arn, resourceType, logicalId, oldTagsRaw, newTagsRaw) {
|
|
1481
|
+
const plan = planTagDiff(oldTagsRaw, newTagsRaw);
|
|
1482
|
+
const tagWarning = tagPlanWarning(plan, resourceType, logicalId);
|
|
1483
|
+
if (tagWarning !== void 0) this.logger.warn(tagWarning);
|
|
1484
|
+
const tagsToAdd = [...plan.set].map(([Key, Value]) => ({
|
|
1485
|
+
Key,
|
|
1486
|
+
Value
|
|
1487
|
+
}));
|
|
1488
|
+
const tagsToRemove = plan.remove;
|
|
1489
|
+
if (tagsToRemove.length > 0) {
|
|
1490
|
+
await this.getClient().send(new RemoveTagsFromResourceCommand({
|
|
1491
|
+
ResourceName: arn,
|
|
1492
|
+
TagKeys: tagsToRemove
|
|
1493
|
+
}));
|
|
1494
|
+
this.logger.debug(`Removed ${tagsToRemove.length} tag(s) from RDS resource ${arn}`);
|
|
1495
|
+
}
|
|
1496
|
+
if (tagsToAdd.length > 0) {
|
|
1497
|
+
await this.getClient().send(new AddTagsToResourceCommand({
|
|
1498
|
+
ResourceName: arn,
|
|
1499
|
+
Tags: tagsToAdd
|
|
1500
|
+
}));
|
|
1501
|
+
this.logger.debug(`Added/updated ${tagsToAdd.length} tag(s) on RDS resource ${arn}`);
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
function isNotFoundError(error, faultName) {
|
|
1505
|
+
if (!(error instanceof Error)) return false;
|
|
1506
|
+
const name = error.name ?? "";
|
|
1507
|
+
const message = error.message.toLowerCase();
|
|
1508
|
+
return name === faultName || message.includes("not found") || message.includes("does not exist");
|
|
1509
|
+
}
|
|
1510
|
+
function wrapCaughtError(mask, error, build) {
|
|
1511
|
+
const m = maskerOrIdentity(mask);
|
|
1512
|
+
const failure = describeAwsFailure(error);
|
|
1513
|
+
if (!failure.redacted) return wrapMaskedAwsError(m, error, build);
|
|
1514
|
+
this.logger.debug(m(build(m(failure.detail)).message));
|
|
1515
|
+
const wrapped = build(`${m(failure.summary)}${relayedNameCollision(failure.detail)}`);
|
|
1516
|
+
return error instanceof Error ? markRedactedCause(wrapped) : wrapped;
|
|
1517
|
+
}
|
|
1518
|
+
function wrapDeleteError(mask, error, build) {
|
|
1519
|
+
const thrown = this.wrapCaughtError(mask, error, build);
|
|
1520
|
+
return error instanceof Error && error.name.includes("NotFound") ? markNotGone(thrown) : thrown;
|
|
1521
|
+
}
|
|
1522
|
+
async function engineLifecycleSupportToSend(kind, logicalId, physicalId, resourceType, properties, previousProperties, context) {
|
|
1523
|
+
const action = engineLifecycleSupportAction(properties, previousProperties, context);
|
|
1524
|
+
if (action === "unchanged") return void 0;
|
|
1525
|
+
const desired = engineLifecycleSupportOf(properties);
|
|
1526
|
+
if (action === "send") return desired;
|
|
1527
|
+
const idKey = kind === "DB cluster" ? "DBClusterIdentifier" : "DBInstanceIdentifier";
|
|
1528
|
+
const { mask } = withDerivedNameMasks(this.logger, createMaskedLogSinks(this.logger, context?.maskSecrets), [[previousProperties[idKey], physicalId]]);
|
|
1529
|
+
let liveRead = "read";
|
|
1530
|
+
if (action === "check-live") try {
|
|
1531
|
+
const resource = kind === "DB cluster" ? await this.describeDBCluster(physicalId) : await this.describeDBInstance(physicalId);
|
|
1532
|
+
if (resource === void 0) liveRead = "not-found";
|
|
1533
|
+
else if (resource.EngineLifecycleSupport === desired) liveRead = void 0;
|
|
1534
|
+
} catch (err) {
|
|
1535
|
+
if (err instanceof CdkdError) throw err;
|
|
1536
|
+
const faultName = err?.name;
|
|
1537
|
+
if (faultName === "DBClusterNotFoundFault" || faultName === "DBInstanceNotFoundFault") liveRead = "not-found";
|
|
1538
|
+
else throw this.wrapCaughtError(mask, err, (text) => new ProvisioningError(`${mask(engineLifecycleSupportRefusalText(resourceType, logicalId, physicalId, kind, "unreadable"))} The read failed: ${text}`, resourceType, logicalId, physicalId, err instanceof Error ? err : void 0));
|
|
1539
|
+
}
|
|
1540
|
+
if (liveRead === void 0) return void 0;
|
|
1541
|
+
throw markNonRetryable(new ProvisioningError(mask(engineLifecycleSupportRefusalText(resourceType, logicalId, physicalId, kind, liveRead)), resourceType, logicalId, physicalId));
|
|
1542
|
+
}
|
|
1543
|
+
async function describeDBCluster(dbClusterIdentifier) {
|
|
1544
|
+
return (await this.getClient().send(new DescribeDBClustersCommand({ DBClusterIdentifier: dbClusterIdentifier }))).DBClusters?.[0];
|
|
1545
|
+
}
|
|
1546
|
+
async function securityGroupsToSend(target, logicalId, physicalId, resourceType, properties, previousProperties, context) {
|
|
1547
|
+
const key = target === "DBCluster" ? "VpcSecurityGroupIds" : "VPCSecurityGroups";
|
|
1548
|
+
const noun = target === "DBCluster" ? "cluster" : "instance";
|
|
1549
|
+
const desired = properties[key];
|
|
1550
|
+
if (desired !== void 0) return desired.length > 0 ? desired : void 0;
|
|
1551
|
+
const previous = previousProperties[key];
|
|
1552
|
+
if (context?.desiredFromAwsReadback === true) return void 0;
|
|
1553
|
+
if (!Array.isArray(previous) || previous.length === 0) return void 0;
|
|
1554
|
+
let groupId;
|
|
1555
|
+
let missing;
|
|
1556
|
+
let awsError;
|
|
1557
|
+
try {
|
|
1558
|
+
let subnetGroupName;
|
|
1559
|
+
let vpcId;
|
|
1560
|
+
if (target === "DBInstance") {
|
|
1561
|
+
const subnetGroup = (await this.describeDBInstance(physicalId))?.DBSubnetGroup;
|
|
1562
|
+
subnetGroupName = subnetGroup?.DBSubnetGroupName;
|
|
1563
|
+
vpcId = subnetGroupName ? subnetGroup?.VpcId : void 0;
|
|
1564
|
+
} else {
|
|
1565
|
+
subnetGroupName = (await this.describeDBCluster(physicalId))?.DBSubnetGroup;
|
|
1566
|
+
vpcId = subnetGroupName ? (await this.getClient().send(new DescribeDBSubnetGroupsCommand({ DBSubnetGroupName: subnetGroupName }))).DBSubnetGroups?.[0]?.VpcId : void 0;
|
|
1567
|
+
}
|
|
1568
|
+
if (!subnetGroupName) missing = `the ${noun} reports no DB subnet group`;
|
|
1569
|
+
else if (!vpcId) missing = `DB subnet group ${subnetGroupName} reports no VPC`;
|
|
1570
|
+
else {
|
|
1571
|
+
groupId = (await this.getEc2Client().send(new DescribeSecurityGroupsCommand({ Filters: [{
|
|
1572
|
+
Name: "vpc-id",
|
|
1573
|
+
Values: [vpcId]
|
|
1574
|
+
}, {
|
|
1575
|
+
Name: "group-name",
|
|
1576
|
+
Values: ["default"]
|
|
1577
|
+
}] }))).SecurityGroups?.[0]?.GroupId;
|
|
1578
|
+
if (!groupId) missing = `VPC ${vpcId} has no security group named default`;
|
|
1579
|
+
}
|
|
1580
|
+
} catch (error) {
|
|
1581
|
+
awsError = error;
|
|
1582
|
+
}
|
|
1583
|
+
if (groupId === void 0) {
|
|
1584
|
+
const mask = context?.maskSecrets ?? ((text) => text);
|
|
1585
|
+
const failure = missing === void 0 ? describeAwsFailure(awsError) : void 0;
|
|
1586
|
+
if (failure?.redacted === true) this.logger.debug(safeMsg`${logicalId}: the VPC default security group lookup failed: ${mask(failure.detail)}`);
|
|
1587
|
+
const shown = mask(failure?.summary ?? "");
|
|
1588
|
+
const refusal = new ProvisioningError(`Failed to update ${target} ${logicalId}: ${key} was removed from the template, so the ${noun} moves to its VPC's default security group (as CloudFormation does), but cdkd could not find that group: ${missing ?? shown}. Declare ${key} in the template to choose the ${noun}'s security groups.`, resourceType, logicalId, physicalId, awsError instanceof Error ? awsError : void 0);
|
|
1589
|
+
if (missing !== void 0) throw markNonRetryable(refusal);
|
|
1590
|
+
throw awsError instanceof Error && (failure?.redacted === true || shown !== (failure?.summary ?? "")) ? markRedactedCause(refusal) : refusal;
|
|
1591
|
+
}
|
|
1592
|
+
this.logger.warn(safeMsg`${logicalId}: ${key} was removed from the template; attaching the VPC's default security group ${groupId}, as CloudFormation does.`);
|
|
1593
|
+
return [groupId];
|
|
1594
|
+
}
|
|
1595
|
+
async function describeDBInstance(dbInstanceIdentifier) {
|
|
1596
|
+
return (await this.getClient().send(new DescribeDBInstancesCommand({ DBInstanceIdentifier: dbInstanceIdentifier }))).DBInstances?.[0];
|
|
1597
|
+
}
|
|
1598
|
+
async function sendHttpEndpointChange(logicalId, physicalId, arn, enable) {
|
|
1599
|
+
let delay = 5e3;
|
|
1600
|
+
for (let attempt = 1;; attempt += 1) {
|
|
1601
|
+
await this.waitForClusterState(logicalId, physicalId, (cluster) => cluster.Status === "available", "pending changes to settle before the Data API call");
|
|
1602
|
+
try {
|
|
1603
|
+
await this.getClient().send(enable ? new EnableHttpEndpointCommand({ ResourceArn: arn }) : new DisableHttpEndpointCommand({ ResourceArn: arn }));
|
|
1604
|
+
return;
|
|
1605
|
+
} catch (error) {
|
|
1606
|
+
const name = awsErrorName(error);
|
|
1607
|
+
if (!HTTP_ENDPOINT_BUSY_FAULTS.has(name) || attempt >= 8) throw error;
|
|
1608
|
+
this.logger.debug(safeMsg`DBCluster ${logicalId}: the Data API call was refused as busy (${name}); retrying`);
|
|
1609
|
+
await this.sleep(delay);
|
|
1610
|
+
delay = Math.min(delay * 2, 1e4);
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1613
|
+
}
|
|
1614
|
+
async function attachTags(result, arn) {
|
|
1615
|
+
try {
|
|
1616
|
+
const tagsResp = await this.getClient().send(new ListTagsForResourceCommand({ ResourceName: arn }));
|
|
1617
|
+
result["Tags"] = normalizeAwsTagsToCfn(tagsResp.TagList);
|
|
1618
|
+
} catch (err) {
|
|
1619
|
+
this.logger.debug(`RDS ListTagsForResource(${arn}) failed: ${describeAwsFailure(err).detail}`);
|
|
1620
|
+
}
|
|
1621
|
+
}
|
|
1622
|
+
|
|
1623
|
+
// src/provisioning/providers/rds/waits.ts
|
|
1624
|
+
async function waitForMemberAfterClusterChange(dbInstanceIdentifier, clusterLogicalId, transitional, change, maxWaitMs = 18e5) {
|
|
1625
|
+
const startTime = Date.now();
|
|
1626
|
+
let delay = 5e3;
|
|
1627
|
+
while (Date.now() - startTime < maxWaitMs) {
|
|
1628
|
+
let status;
|
|
1629
|
+
try {
|
|
1630
|
+
status = (await this.describeDBInstance(dbInstanceIdentifier))?.DBInstanceStatus;
|
|
1631
|
+
} catch (error) {
|
|
1632
|
+
if (this.isNotFoundError(error, "DBInstanceNotFoundFault")) return;
|
|
1633
|
+
throw error;
|
|
1634
|
+
}
|
|
1635
|
+
if (status === void 0 || !transitional.has(status)) return;
|
|
1636
|
+
await this.sleep(delay);
|
|
1637
|
+
delay = Math.min(delay * 2, 1e4);
|
|
1638
|
+
}
|
|
1639
|
+
throw new Error(safeMsg`Timed out waiting for a member instance of DBCluster ${clusterLogicalId} to finish applying its new ${change}`);
|
|
1640
|
+
}
|
|
1641
|
+
function requireClusterWhileWaiting(cluster, logicalId, change) {
|
|
1642
|
+
if (cluster === void 0) throw new Error(safeMsg`DescribeDBClusters returned no cluster for DBCluster ${logicalId} while waiting for its new ${change}`);
|
|
1643
|
+
if (isTerminalDbWaitStatus(cluster.Status)) throw new Error(safeMsg`DBCluster ${logicalId} entered status ${cluster.Status ?? ""} while applying its new ${change}`);
|
|
1644
|
+
return cluster;
|
|
1645
|
+
}
|
|
1646
|
+
async function waitForClusterPortApplied(dbClusterIdentifier, logicalId, port, maxWaitMs = 18e5) {
|
|
1647
|
+
const startTime = Date.now();
|
|
1648
|
+
let delay = 5e3;
|
|
1649
|
+
while (Date.now() - startTime < maxWaitMs) {
|
|
1650
|
+
const cluster = this.requireClusterWhileWaiting(await this.describeDBCluster(dbClusterIdentifier), logicalId, "port");
|
|
1651
|
+
if (cluster.Status !== "modifying" && cluster.Port === port) return;
|
|
1652
|
+
this.logger.debug(safeMsg`DBCluster ${logicalId} port not applied yet (status ${cluster.Status ?? "unknown"})`);
|
|
1653
|
+
await this.sleep(delay);
|
|
1654
|
+
delay = Math.min(delay * 2, 1e4);
|
|
1655
|
+
}
|
|
1656
|
+
throw new Error(`Timed out waiting for DBCluster ${logicalId} to apply its new port`);
|
|
1657
|
+
}
|
|
1658
|
+
async function waitForSecurityGroupsApplied(dbClusterIdentifier, logicalId, expected, maxWaitMs = 18e5) {
|
|
1659
|
+
const want = [...new Set(expected)].sort().join(" ");
|
|
1660
|
+
const startTime = Date.now();
|
|
1661
|
+
let delay = 5e3;
|
|
1662
|
+
while (Date.now() - startTime < maxWaitMs) {
|
|
1663
|
+
const cluster = this.requireClusterWhileWaiting(await this.describeDBCluster(dbClusterIdentifier), logicalId, "VPC security groups");
|
|
1664
|
+
const groups = cluster.VpcSecurityGroups ?? [];
|
|
1665
|
+
const ids = groups.map((group) => group.VpcSecurityGroupId ?? "").sort().join(" ");
|
|
1666
|
+
if (cluster.Status !== "modifying" && groups.every((group) => group.Status === "active") && ids === want) return;
|
|
1667
|
+
this.logger.debug(safeMsg`DBCluster ${logicalId} security groups not settled yet (status ${cluster.Status ?? "unknown"})`);
|
|
1668
|
+
await this.sleep(delay);
|
|
1669
|
+
delay = Math.min(delay * 2, 1e4);
|
|
1670
|
+
}
|
|
1671
|
+
throw new Error(`Timed out waiting for DBCluster ${logicalId} to apply its new VPC security groups`);
|
|
1672
|
+
}
|
|
1673
|
+
async function waitForClusterState(logicalId, dbClusterIdentifier, done, change) {
|
|
1674
|
+
const remaining = enclosingDeadlineRemainingMs();
|
|
1675
|
+
const maxWaitMs = Number.isFinite(remaining) ? remaining : 18e5;
|
|
1676
|
+
const startTime = Date.now();
|
|
1677
|
+
let delay = 5e3;
|
|
1678
|
+
while (Date.now() - startTime < maxWaitMs) {
|
|
1679
|
+
const cluster = this.requireClusterWhileWaiting(await this.describeDBCluster(dbClusterIdentifier), logicalId, change);
|
|
1680
|
+
if (done(cluster)) return;
|
|
1681
|
+
this.logger.debug(safeMsg`DBCluster ${logicalId} waiting for its ${change} (status ${cluster.Status ?? "unknown"})`);
|
|
1682
|
+
await this.sleep(delay);
|
|
1683
|
+
delay = Math.min(delay * 2, 1e4);
|
|
1684
|
+
}
|
|
1685
|
+
throw new Error(safeMsg`Timed out waiting for DBCluster ${logicalId}'s ${change}`);
|
|
1686
|
+
}
|
|
1687
|
+
async function waitForClusterAvailable(logicalId, dbClusterIdentifier, maxWaitMs = 18e5, doing = "being created") {
|
|
1688
|
+
const startTime = Date.now();
|
|
1689
|
+
let delay = 5e3;
|
|
1690
|
+
while (Date.now() - startTime < maxWaitMs) {
|
|
1691
|
+
const status = (await this.describeDBCluster(dbClusterIdentifier))?.Status;
|
|
1692
|
+
this.logger.debug(`DBCluster ${dbClusterIdentifier} status: ${status}`);
|
|
1693
|
+
if (status === "available") return;
|
|
1694
|
+
if (isTerminalDbWaitStatus(status)) throw new Error(safeMsg`DBCluster ${logicalId} entered status ${status ?? ""} while ${doing}, which it does not leave on its own`);
|
|
1695
|
+
await this.sleep(delay);
|
|
1696
|
+
delay = Math.min(delay * 2, 1e4);
|
|
1697
|
+
}
|
|
1698
|
+
throw new Error(`Timed out waiting for DBCluster ${dbClusterIdentifier} to become available`);
|
|
1699
|
+
}
|
|
1700
|
+
async function waitForClusterDeleted(logicalId, dbClusterIdentifier, maxWaitMs = 18e5) {
|
|
1701
|
+
const startTime = Date.now();
|
|
1702
|
+
let delay = 5e3;
|
|
1703
|
+
while (Date.now() - startTime < maxWaitMs) {
|
|
1704
|
+
try {
|
|
1705
|
+
const cluster = await this.describeDBCluster(dbClusterIdentifier);
|
|
1706
|
+
const status = cluster?.Status;
|
|
1707
|
+
this.logger.debug(`DBCluster ${logicalId} status: ${status}`);
|
|
1708
|
+
if (!cluster) return;
|
|
1709
|
+
} catch (error) {
|
|
1710
|
+
if (this.isNotFoundError(error, "DBClusterNotFoundFault")) return;
|
|
1711
|
+
throw error;
|
|
1712
|
+
}
|
|
1713
|
+
await this.sleep(delay);
|
|
1714
|
+
delay = Math.min(delay * 2, 1e4);
|
|
1715
|
+
}
|
|
1716
|
+
throw new Error(`Timed out waiting for DBCluster ${logicalId} to be deleted`);
|
|
1717
|
+
}
|
|
1718
|
+
async function rebootForPendingParameterGroup(logicalId, physicalId, sentGroup, caRotationRestarts) {
|
|
1719
|
+
const settled = await this.waitForInstanceState(logicalId, physicalId, (instance) => instanceParameterGroupSettled(instance, sentGroup, caRotationRestarts), "parameter group change to settle");
|
|
1720
|
+
if (!instanceParameterGroupPendingReboot(settled)) return settled;
|
|
1721
|
+
this.logger.info(safeMsg`Rebooting DBInstance ${logicalId} to apply its parameter group (pending-reboot), as CloudFormation does after an update`);
|
|
1722
|
+
await this.getClient().send(new RebootDBInstanceCommand({ DBInstanceIdentifier: physicalId }));
|
|
1723
|
+
if (process.env["CDKD_NO_WAIT"] === "true") return settled;
|
|
1724
|
+
return this.waitForInstanceState(logicalId, physicalId, instanceRebootApplied, "reboot to apply its parameter group");
|
|
1725
|
+
}
|
|
1726
|
+
async function waitForInstanceState(logicalId, dbInstanceIdentifier, done, change) {
|
|
1727
|
+
const remaining = enclosingDeadlineRemainingMs();
|
|
1728
|
+
const maxWaitMs = Number.isFinite(remaining) ? remaining : 18e5;
|
|
1729
|
+
const startTime = Date.now();
|
|
1730
|
+
let delay = 5e3;
|
|
1731
|
+
while (Date.now() - startTime < maxWaitMs) {
|
|
1732
|
+
const instance = await this.describeDBInstance(dbInstanceIdentifier);
|
|
1733
|
+
if (instance === void 0) throw new Error(safeMsg`DescribeDBInstances returned no instance for DBInstance ${logicalId} while waiting for its ${change}`);
|
|
1734
|
+
if (isTerminalDbWaitStatus(instance.DBInstanceStatus)) throw new Error(safeMsg`DBInstance ${logicalId} entered status ${instance.DBInstanceStatus ?? ""} while waiting for its ${change}`);
|
|
1735
|
+
if (done(instance)) return instance;
|
|
1736
|
+
this.logger.debug(safeMsg`DBInstance ${logicalId} waiting for its ${change} (status ${instance.DBInstanceStatus ?? "unknown"})`);
|
|
1737
|
+
await this.sleep(delay);
|
|
1738
|
+
delay = Math.min(delay * 2, 1e4);
|
|
1739
|
+
}
|
|
1740
|
+
throw new Error(safeMsg`Timed out waiting for DBInstance ${logicalId}'s ${change}`);
|
|
1741
|
+
}
|
|
1742
|
+
async function waitForInstanceAvailable(logicalId, dbInstanceIdentifier, maxWaitMs = 18e5, doing = "being created") {
|
|
1743
|
+
const startTime = Date.now();
|
|
1744
|
+
let delay = 1e4;
|
|
1745
|
+
while (Date.now() - startTime < maxWaitMs) {
|
|
1746
|
+
const status = (await this.describeDBInstance(dbInstanceIdentifier))?.DBInstanceStatus;
|
|
1747
|
+
this.logger.debug(`DBInstance ${dbInstanceIdentifier} status: ${status}`);
|
|
1748
|
+
if (status === "available") return;
|
|
1749
|
+
if (isTerminalDbWaitStatus(status)) throw new Error(safeMsg`DBInstance ${logicalId} entered status ${status ?? ""} while ${doing}, which it does not leave on its own`);
|
|
1750
|
+
await this.sleep(delay);
|
|
1751
|
+
delay = Math.min(delay * 2, 1e4);
|
|
1752
|
+
}
|
|
1753
|
+
throw new Error(`Timed out waiting for DBInstance ${dbInstanceIdentifier} to become available`);
|
|
1754
|
+
}
|
|
1755
|
+
async function waitForInstanceDeleted(logicalId, dbInstanceIdentifier, maxWaitMs = 18e5) {
|
|
1756
|
+
const startTime = Date.now();
|
|
1757
|
+
let delay = 1e4;
|
|
1758
|
+
while (Date.now() - startTime < maxWaitMs) {
|
|
1759
|
+
try {
|
|
1760
|
+
const instance = await this.describeDBInstance(dbInstanceIdentifier);
|
|
1761
|
+
const status = instance?.DBInstanceStatus;
|
|
1762
|
+
this.logger.debug(`DBInstance ${logicalId} status: ${status}`);
|
|
1763
|
+
if (!instance) return;
|
|
1764
|
+
} catch (error) {
|
|
1765
|
+
if (this.isNotFoundError(error, "DBInstanceNotFoundFault")) return;
|
|
1766
|
+
throw error;
|
|
1767
|
+
}
|
|
1768
|
+
await this.sleep(delay);
|
|
1769
|
+
delay = Math.min(delay * 2, 1e4);
|
|
1770
|
+
}
|
|
1771
|
+
throw new Error(`Timed out waiting for DBInstance ${logicalId} to be deleted`);
|
|
1772
|
+
}
|
|
1773
|
+
|
|
1774
|
+
// src/provisioning/providers/rds/associated-roles.ts
|
|
1775
|
+
function desiredAssociatedRoles(properties, resourceType, logicalId, physicalId, replayingCreate) {
|
|
1776
|
+
const instance = resourceType === "AWS::RDS::DBInstance";
|
|
1777
|
+
const roles = associatedRoleList(properties["AssociatedRoles"], { featureNameRequired: instance });
|
|
1778
|
+
if (roles !== void 0) return roles;
|
|
1779
|
+
const expected = instance ? "a list of objects with a RoleArn and a FeatureName" : "a list of objects with a RoleArn";
|
|
1780
|
+
if (!replayingCreate) throw markNonRetryable(new ProvisioningError(`${resourceType} ${logicalId}: AssociatedRoles must be ${expected}; nothing was changed`, resourceType, logicalId, physicalId));
|
|
1781
|
+
this.logger.warn(safeMsg`${logicalId} (${resourceType}): the replayed AssociatedRoles is not ${expected}, so no role is attached`);
|
|
1782
|
+
return "skipped";
|
|
1783
|
+
}
|
|
1784
|
+
async function applyAssociatedRoles(target, logicalId, physicalId, desired, previous, mask, marks) {
|
|
1785
|
+
const candidates = planAssociatedRoleChanges(desired, previous);
|
|
1786
|
+
if (candidates.toAdd.length === 0 && candidates.toRemove.length === 0) return;
|
|
1787
|
+
const label = target === "cluster" ? "RDS DBCluster" : "RDS DBInstance";
|
|
1788
|
+
const waitBudgetMs = Math.min(18e5, enclosingDeadlineRemainingMs() - 3e4);
|
|
1789
|
+
if (waitBudgetMs <= 0) throw new Error(`the resource timeout leaves no more time to change the roles of the ${target}; re-run the deploy, or with a longer --resource-timeout`);
|
|
1790
|
+
if (target === "cluster") await this.waitForClusterAvailable(logicalId, physicalId, waitBudgetMs, "changing its roles");
|
|
1791
|
+
else await this.waitForInstanceAvailable(logicalId, physicalId, waitBudgetMs, "changing its roles");
|
|
1792
|
+
const resource = target === "cluster" ? await this.describeDBCluster(physicalId) : await this.describeDBInstance(physicalId);
|
|
1793
|
+
if (resource === void 0) throw new Error(`Describe returned no ${target} while planning its role changes; no role was attached or detached`);
|
|
1794
|
+
const { toAdd, toRemove } = planAssociatedRoleChanges(desired, previous, resource.AssociatedRoles ?? []);
|
|
1795
|
+
if (toAdd.length === 0 && toRemove.length === 0) return;
|
|
1796
|
+
marks?.markUnsettled?.("AssociatedRoles");
|
|
1797
|
+
const readStatus = target === "cluster" ? async () => (await this.describeDBCluster(physicalId))?.Status : async () => (await this.describeDBInstance(physicalId))?.DBInstanceStatus;
|
|
1798
|
+
const whenAvailable = (send) => modifyDbInstanceWhenAvailable({
|
|
1799
|
+
send,
|
|
1800
|
+
readStatus,
|
|
1801
|
+
sleep: (ms) => this.sleep(ms),
|
|
1802
|
+
logger: this.logger,
|
|
1803
|
+
label,
|
|
1804
|
+
subject: target,
|
|
1805
|
+
isRefusal: (error) => isRoleCallNotAvailableRefusal(error) || isModifyNotAvailableRefusal(error),
|
|
1806
|
+
logicalId,
|
|
1807
|
+
remainingMs: enclosingDeadlineRemainingMs()
|
|
1808
|
+
});
|
|
1809
|
+
for (const role of toRemove) {
|
|
1810
|
+
marks?.markAttempted?.("AssociatedRoles", [associatedRoleKey(role)]);
|
|
1811
|
+
await whenAvailable(() => target === "cluster" ? this.getClient().send(new RemoveRoleFromDBClusterCommand({
|
|
1812
|
+
DBClusterIdentifier: physicalId,
|
|
1813
|
+
...role
|
|
1814
|
+
})) : this.getClient().send(new RemoveRoleFromDBInstanceCommand({
|
|
1815
|
+
DBInstanceIdentifier: physicalId,
|
|
1816
|
+
RoleArn: role.RoleArn,
|
|
1817
|
+
FeatureName: role.FeatureName
|
|
1818
|
+
})));
|
|
1819
|
+
}
|
|
1820
|
+
for (const role of toAdd) {
|
|
1821
|
+
await whenAvailable(() => target === "cluster" ? this.getClient().send(new AddRoleToDBClusterCommand({
|
|
1822
|
+
DBClusterIdentifier: physicalId,
|
|
1823
|
+
...role
|
|
1824
|
+
})) : this.getClient().send(new AddRoleToDBInstanceCommand({
|
|
1825
|
+
DBInstanceIdentifier: physicalId,
|
|
1826
|
+
RoleArn: role.RoleArn,
|
|
1827
|
+
FeatureName: role.FeatureName
|
|
1828
|
+
})));
|
|
1829
|
+
marks?.markAttempted?.("AssociatedRoles", [associatedRoleKey(role)]);
|
|
1830
|
+
}
|
|
1831
|
+
if (process.env["CDKD_NO_WAIT"] === "true") return;
|
|
1832
|
+
const attached = toAdd.map(associatedRoleKey);
|
|
1833
|
+
const detached = toRemove.map(associatedRoleKey);
|
|
1834
|
+
const settled = (roles) => {
|
|
1835
|
+
const held = new Set((roles ?? []).map(associatedRoleKey));
|
|
1836
|
+
return attached.every((key) => held.has(key)) && detached.every((key) => !held.has(key));
|
|
1837
|
+
};
|
|
1838
|
+
const change = `IAM role associations (${maskerOrIdentity(mask)(associatedRoleArns([...attached, ...detached]))})`;
|
|
1839
|
+
if (target === "cluster") await this.waitForClusterState(logicalId, physicalId, (cluster) => settled(cluster.AssociatedRoles), change);
|
|
1840
|
+
else await this.waitForInstanceState(logicalId, physicalId, (instance) => settled(instance.AssociatedRoles), change);
|
|
1841
|
+
}
|
|
1842
|
+
|
|
1843
|
+
// src/provisioning/providers/rds/drift.ts
|
|
1844
|
+
function getDriftUnorderedPaths(resourceType) {
|
|
1845
|
+
return resourceType === "AWS::RDS::DBCluster" || resourceType === "AWS::RDS::DBInstance" ? ["EnableCloudwatchLogsExports", "AssociatedRoles"] : [];
|
|
1846
|
+
}
|
|
1847
|
+
function getDriftUnknownPaths(resourceType, properties) {
|
|
1848
|
+
if (resourceType === "AWS::RDS::DBInstance") return ["AllowMajorVersionUpgrade", "CertificateRotationRestart"];
|
|
1849
|
+
if (resourceType !== "AWS::RDS::DBCluster") return [];
|
|
1850
|
+
const neverRead = [
|
|
1851
|
+
"EngineMode",
|
|
1852
|
+
"AvailabilityZones",
|
|
1853
|
+
"ClusterScalabilityType",
|
|
1854
|
+
"MasterUserAuthenticationType",
|
|
1855
|
+
"GlobalClusterIdentifier"
|
|
1856
|
+
];
|
|
1857
|
+
if (properties === void 0 || Object.keys(properties).length === 0) return neverRead;
|
|
1858
|
+
return (properties?.["ServerlessV2ScalingConfiguration"])?.SecondsUntilAutoPause === void 0 ? [...neverRead, "ServerlessV2ScalingConfiguration.SecondsUntilAutoPause"] : neverRead;
|
|
1859
|
+
}
|
|
1860
|
+
function canonicalizeDriftProperties(resourceType, properties) {
|
|
1861
|
+
if (resourceType !== "AWS::RDS::DBCluster" && resourceType !== "AWS::RDS::DBInstance") return properties;
|
|
1862
|
+
let out;
|
|
1863
|
+
const set = (key, value) => {
|
|
1864
|
+
out ??= { ...properties };
|
|
1865
|
+
out[key] = value;
|
|
1866
|
+
};
|
|
1867
|
+
if (Array.isArray(properties["AssociatedRoles"])) set("AssociatedRoles", canonicalAssociatedRoles(properties["AssociatedRoles"]));
|
|
1868
|
+
if (resourceType !== "AWS::RDS::DBCluster") return out ?? properties;
|
|
1869
|
+
for (const key of CLUSTER_BOOLEAN_SCALARS) {
|
|
1870
|
+
const value = properties[key];
|
|
1871
|
+
if (value === "true" || value === "false") set(key, value === "true");
|
|
1872
|
+
}
|
|
1873
|
+
for (const key of ["PerformanceInsightsRetentionPeriod", "BacktrackWindow"]) {
|
|
1874
|
+
const value = properties[key];
|
|
1875
|
+
if (typeof value === "string") {
|
|
1876
|
+
const parsed = retentionPeriodValue(value);
|
|
1877
|
+
if (typeof parsed === "number") set(key, parsed);
|
|
1878
|
+
}
|
|
1879
|
+
}
|
|
1880
|
+
return out ?? properties;
|
|
1881
|
+
}
|
|
1882
|
+
function canonicalizeUnsettledProperties(resourceType, properties) {
|
|
1883
|
+
return this.canonicalizeDriftProperties(resourceType, properties);
|
|
1884
|
+
}
|
|
1885
|
+
|
|
1886
|
+
// src/provisioning/providers/rds/read-state.ts
|
|
1887
|
+
async function readUnsettled(physicalId, logicalId, resourceType, names, recordedProperties, desiredProperties, attemptedItems) {
|
|
1888
|
+
const live = await this.readCurrentState(physicalId, logicalId, resourceType);
|
|
1889
|
+
if (live === void 0 || live === RESOURCE_NOT_FOUND) return live;
|
|
1890
|
+
if (!names.has("AssociatedRoles")) return live;
|
|
1891
|
+
return {
|
|
1892
|
+
...live,
|
|
1893
|
+
AssociatedRoles: associatedRolesNamed(live["AssociatedRoles"], recordedProperties?.["AssociatedRoles"], desiredProperties?.["AssociatedRoles"], attemptedItems?.get("AssociatedRoles"))
|
|
1894
|
+
};
|
|
1895
|
+
}
|
|
1896
|
+
async function readCurrentState(physicalId, _logicalId, resourceType) {
|
|
1897
|
+
switch (resourceType) {
|
|
1898
|
+
case "AWS::RDS::DBInstance": return this.readCurrentStateDBInstance(physicalId);
|
|
1899
|
+
case "AWS::RDS::DBCluster": return this.readCurrentStateDBCluster(physicalId);
|
|
1900
|
+
case "AWS::RDS::DBSubnetGroup": return this.readCurrentStateDBSubnetGroup(physicalId);
|
|
1901
|
+
default: return;
|
|
1902
|
+
}
|
|
1903
|
+
}
|
|
1904
|
+
async function isSameResource(journaledPhysicalId, record, resourceType, context) {
|
|
1905
|
+
if (resourceType !== "AWS::RDS::DBCluster" && resourceType !== "AWS::RDS::DBInstance") return "unknown";
|
|
1906
|
+
if (!isDbIdentifier(journaledPhysicalId) || !isDbIdentifier(record.physicalId)) return "unknown";
|
|
1907
|
+
if (journaledPhysicalId.toLowerCase() === record.physicalId.toLowerCase()) return "same";
|
|
1908
|
+
if (await this.getClient().config.region() !== context.expectedRegion) return "unknown";
|
|
1909
|
+
const recordResourceId = await this.readDbResourceIdIfExists(resourceType, record.physicalId);
|
|
1910
|
+
if (recordResourceId === void 0) return "unknown";
|
|
1911
|
+
const journaledResourceId = await this.readDbResourceIdIfExists(resourceType, journaledPhysicalId);
|
|
1912
|
+
if (journaledResourceId === void 0) return "different";
|
|
1913
|
+
return journaledResourceId === recordResourceId ? "same" : "different";
|
|
1914
|
+
}
|
|
1915
|
+
async function resourceIdentity(physicalId, resourceType, context) {
|
|
1916
|
+
if (resourceType !== "AWS::RDS::DBCluster" && resourceType !== "AWS::RDS::DBInstance") return;
|
|
1917
|
+
if (!isDbIdentifier(physicalId)) return void 0;
|
|
1918
|
+
if (await this.getClient().config.region() !== context.expectedRegion) return void 0;
|
|
1919
|
+
const live = await this.readDbResourceIdIfExists(resourceType, physicalId);
|
|
1920
|
+
return live === void 0 ? RESOURCE_NOT_FOUND : live;
|
|
1921
|
+
}
|
|
1922
|
+
async function readDbResourceIdIfExists(resourceType, identifier) {
|
|
1923
|
+
const isCluster = resourceType === "AWS::RDS::DBCluster";
|
|
1924
|
+
let found;
|
|
1925
|
+
try {
|
|
1926
|
+
if (isCluster) {
|
|
1927
|
+
const cluster = await this.describeDBCluster(identifier);
|
|
1928
|
+
found = cluster && {
|
|
1929
|
+
identifier: cluster.DBClusterIdentifier,
|
|
1930
|
+
resourceId: cluster.DbClusterResourceId
|
|
1931
|
+
};
|
|
1932
|
+
} else {
|
|
1933
|
+
const instance = await this.describeDBInstance(identifier);
|
|
1934
|
+
found = instance && {
|
|
1935
|
+
identifier: instance.DBInstanceIdentifier,
|
|
1936
|
+
resourceId: instance.DbiResourceId
|
|
1937
|
+
};
|
|
1938
|
+
}
|
|
1939
|
+
} catch (error) {
|
|
1940
|
+
const notFound = isCluster ? "DBClusterNotFoundFault" : "DBInstanceNotFoundFault";
|
|
1941
|
+
if (error?.name === notFound) return void 0;
|
|
1942
|
+
throw error;
|
|
1943
|
+
}
|
|
1944
|
+
if (found === void 0) return void 0;
|
|
1945
|
+
const api = isCluster ? "DescribeDBClusters" : "DescribeDBInstances";
|
|
1946
|
+
if (found.identifier?.toLowerCase() !== identifier.toLowerCase()) throw new Error(`${api} answered for another identifier`);
|
|
1947
|
+
if (typeof found.resourceId !== "string" || found.resourceId === "") throw new Error(`${api} returned no resource id`);
|
|
1948
|
+
return found.resourceId;
|
|
1949
|
+
}
|
|
1950
|
+
async function readCurrentStateDBInstance(physicalId) {
|
|
1951
|
+
let inst;
|
|
1952
|
+
try {
|
|
1953
|
+
inst = await this.describeDBInstance(physicalId);
|
|
1954
|
+
} catch (err) {
|
|
1955
|
+
if (err?.name === "DBInstanceNotFoundFault") return RESOURCE_NOT_FOUND;
|
|
1956
|
+
if (this.isNotFoundError(err, "DBInstanceNotFoundFault")) return void 0;
|
|
1957
|
+
throw err;
|
|
1958
|
+
}
|
|
1959
|
+
if (!inst) return RESOURCE_NOT_FOUND;
|
|
1960
|
+
const result = {};
|
|
1961
|
+
if (inst.DBInstanceIdentifier !== void 0) result["DBInstanceIdentifier"] = inst.DBInstanceIdentifier;
|
|
1962
|
+
if (inst.DBInstanceClass !== void 0) result["DBInstanceClass"] = inst.DBInstanceClass;
|
|
1963
|
+
if (inst.Engine !== void 0) result["Engine"] = inst.Engine;
|
|
1964
|
+
if (inst.DBClusterIdentifier !== void 0) result["DBClusterIdentifier"] = inst.DBClusterIdentifier;
|
|
1965
|
+
if (inst.DBSubnetGroup?.DBSubnetGroupName !== void 0) result["DBSubnetGroupName"] = inst.DBSubnetGroup.DBSubnetGroupName;
|
|
1966
|
+
if (inst.PubliclyAccessible !== void 0) result["PubliclyAccessible"] = inst.PubliclyAccessible;
|
|
1967
|
+
if (inst.AllocatedStorage !== void 0) result["AllocatedStorage"] = inst.AllocatedStorage;
|
|
1968
|
+
if (inst.MasterUsername !== void 0) result["MasterUsername"] = inst.MasterUsername;
|
|
1969
|
+
if (inst.DeletionProtection !== void 0) result["DeletionProtection"] = inst.DeletionProtection;
|
|
1970
|
+
if (inst.EngineVersion !== void 0) result["EngineVersion"] = inst.EngineVersion;
|
|
1971
|
+
if (inst.Endpoint?.Port !== void 0) result["Port"] = inst.Endpoint.Port;
|
|
1972
|
+
if (inst.StorageEncrypted !== void 0) result["StorageEncrypted"] = inst.StorageEncrypted;
|
|
1973
|
+
const sgIds = (inst.VpcSecurityGroups ?? []).map((sg) => sg.VpcSecurityGroupId).filter((id) => !!id);
|
|
1974
|
+
if (sgIds.length > 0) result["VPCSecurityGroups"] = sgIds;
|
|
1975
|
+
if (inst.KmsKeyId !== void 0) result["KmsKeyId"] = inst.KmsKeyId;
|
|
1976
|
+
if (inst.MonitoringRoleArn !== void 0) result["MonitoringRoleArn"] = inst.MonitoringRoleArn;
|
|
1977
|
+
if (inst.MonitoringInterval !== void 0) result["MonitoringInterval"] = inst.MonitoringInterval;
|
|
1978
|
+
if (inst.IAMDatabaseAuthenticationEnabled !== void 0) result["EnableIAMDatabaseAuthentication"] = inst.IAMDatabaseAuthenticationEnabled;
|
|
1979
|
+
if (inst.MasterUserSecret?.KmsKeyId !== void 0) result["MasterUserSecret"] = { KmsKeyId: inst.MasterUserSecret.KmsKeyId };
|
|
1980
|
+
for (const key of [
|
|
1981
|
+
"BackupRetentionPeriod",
|
|
1982
|
+
"PreferredBackupWindow",
|
|
1983
|
+
"PreferredMaintenanceWindow",
|
|
1984
|
+
"StorageType",
|
|
1985
|
+
"MultiAZ",
|
|
1986
|
+
"MaxAllocatedStorage",
|
|
1987
|
+
"AutoMinorVersionUpgrade",
|
|
1988
|
+
"CopyTagsToSnapshot",
|
|
1989
|
+
"PerformanceInsightsKMSKeyId",
|
|
1990
|
+
"PerformanceInsightsRetentionPeriod",
|
|
1991
|
+
"Iops",
|
|
1992
|
+
"StorageThroughput",
|
|
1993
|
+
"CACertificateIdentifier",
|
|
1994
|
+
"NetworkType",
|
|
1995
|
+
"LicenseModel",
|
|
1996
|
+
"PromotionTier",
|
|
1997
|
+
"DatabaseInsightsMode",
|
|
1998
|
+
"DedicatedLogVolume"
|
|
1999
|
+
]) if (inst[key] !== void 0) result[key] = inst[key];
|
|
2000
|
+
if (inst.PerformanceInsightsEnabled !== void 0) result["EnablePerformanceInsights"] = inst.PerformanceInsightsEnabled;
|
|
2001
|
+
const memberships = inst.OptionGroupMemberships ?? [];
|
|
2002
|
+
const optionGroupName = (memberships.find((m) => m.Status === "in-sync" || m.Status === "pending-apply") ?? memberships[0])?.OptionGroupName;
|
|
2003
|
+
if (optionGroupName !== void 0) result["OptionGroupName"] = optionGroupName;
|
|
2004
|
+
const parameterGroupName = inst.DBParameterGroups?.[0]?.DBParameterGroupName;
|
|
2005
|
+
if (parameterGroupName !== void 0) result["DBParameterGroupName"] = parameterGroupName;
|
|
2006
|
+
if (inst.DBClusterIdentifier === void 0) {
|
|
2007
|
+
const instanceLogs = liveLogExports(inst.EnabledCloudwatchLogsExports, inst.PendingModifiedValues?.PendingCloudwatchLogsExports);
|
|
2008
|
+
if (instanceLogs.length > 0) result["EnableCloudwatchLogsExports"] = instanceLogs;
|
|
2009
|
+
}
|
|
2010
|
+
if (inst.DBName !== void 0) result["DBName"] = inst.DBName;
|
|
2011
|
+
if (inst.AvailabilityZone !== void 0 && inst.MultiAZ !== true) result["AvailabilityZone"] = inst.AvailabilityZone;
|
|
2012
|
+
if (inst.EngineLifecycleSupport !== void 0 && inst.DBClusterIdentifier === void 0) result["EngineLifecycleSupport"] = inst.EngineLifecycleSupport;
|
|
2013
|
+
result["AssociatedRoles"] = associatedRolesReadback(inst.AssociatedRoles);
|
|
2014
|
+
if (inst.DBInstanceArn) await this.attachTags(result, inst.DBInstanceArn);
|
|
2015
|
+
return result;
|
|
2016
|
+
}
|
|
2017
|
+
async function readCurrentStateDBCluster(physicalId) {
|
|
2018
|
+
let cluster;
|
|
2019
|
+
try {
|
|
2020
|
+
cluster = await this.describeDBCluster(physicalId);
|
|
2021
|
+
} catch (err) {
|
|
2022
|
+
if (err?.name === "DBClusterNotFoundFault") return RESOURCE_NOT_FOUND;
|
|
2023
|
+
if (this.isNotFoundError(err, "DBClusterNotFoundFault")) return void 0;
|
|
2024
|
+
throw err;
|
|
2025
|
+
}
|
|
2026
|
+
if (!cluster) return RESOURCE_NOT_FOUND;
|
|
2027
|
+
const result = {};
|
|
2028
|
+
if (cluster.DBClusterIdentifier !== void 0) result["DBClusterIdentifier"] = cluster.DBClusterIdentifier;
|
|
2029
|
+
if (cluster.Engine !== void 0) result["Engine"] = cluster.Engine;
|
|
2030
|
+
if (cluster.EngineVersion !== void 0) result["EngineVersion"] = cluster.EngineVersion;
|
|
2031
|
+
if (cluster.MasterUsername !== void 0) result["MasterUsername"] = cluster.MasterUsername;
|
|
2032
|
+
if (cluster.DatabaseName !== void 0) result["DatabaseName"] = cluster.DatabaseName;
|
|
2033
|
+
if (cluster.Port !== void 0) result["Port"] = cluster.Port;
|
|
2034
|
+
result["VpcSecurityGroupIds"] = (cluster.VpcSecurityGroups ?? []).map((sg) => sg.VpcSecurityGroupId).filter((id) => !!id);
|
|
2035
|
+
if (cluster.DBSubnetGroup !== void 0) result["DBSubnetGroupName"] = cluster.DBSubnetGroup;
|
|
2036
|
+
if (cluster.StorageEncrypted !== void 0) result["StorageEncrypted"] = cluster.StorageEncrypted;
|
|
2037
|
+
if (cluster.KmsKeyId !== void 0) result["KmsKeyId"] = cluster.KmsKeyId;
|
|
2038
|
+
if (cluster.BackupRetentionPeriod !== void 0) result["BackupRetentionPeriod"] = cluster.BackupRetentionPeriod;
|
|
2039
|
+
if (cluster.DeletionProtection !== void 0) result["DeletionProtection"] = cluster.DeletionProtection;
|
|
2040
|
+
if (cluster.MonitoringRoleArn !== void 0) result["MonitoringRoleArn"] = cluster.MonitoringRoleArn;
|
|
2041
|
+
if (cluster.MonitoringInterval !== void 0) result["MonitoringInterval"] = cluster.MonitoringInterval;
|
|
2042
|
+
if (cluster.IAMDatabaseAuthenticationEnabled !== void 0) result["EnableIAMDatabaseAuthentication"] = cluster.IAMDatabaseAuthenticationEnabled;
|
|
2043
|
+
if (cluster.PubliclyAccessible !== void 0) result["PubliclyAccessible"] = cluster.PubliclyAccessible;
|
|
2044
|
+
if (cluster.MasterUserSecret?.KmsKeyId !== void 0) result["MasterUserSecret"] = { KmsKeyId: cluster.MasterUserSecret.KmsKeyId };
|
|
2045
|
+
if (cluster.ServerlessV2ScalingConfiguration?.MinCapacity !== void 0 || cluster.ServerlessV2ScalingConfiguration?.MaxCapacity !== void 0) {
|
|
2046
|
+
const sc = {};
|
|
2047
|
+
if (cluster.ServerlessV2ScalingConfiguration?.MinCapacity !== void 0) sc["MinCapacity"] = cluster.ServerlessV2ScalingConfiguration.MinCapacity;
|
|
2048
|
+
if (cluster.ServerlessV2ScalingConfiguration?.MaxCapacity !== void 0) sc["MaxCapacity"] = cluster.ServerlessV2ScalingConfiguration.MaxCapacity;
|
|
2049
|
+
if (cluster.ServerlessV2ScalingConfiguration?.SecondsUntilAutoPause !== void 0) sc["SecondsUntilAutoPause"] = cluster.ServerlessV2ScalingConfiguration.SecondsUntilAutoPause;
|
|
2050
|
+
result["ServerlessV2ScalingConfiguration"] = sc;
|
|
2051
|
+
}
|
|
2052
|
+
if (cluster.DBClusterParameterGroup !== void 0) result["DBClusterParameterGroupName"] = cluster.DBClusterParameterGroup;
|
|
2053
|
+
if (cluster.PreferredBackupWindow !== void 0) result["PreferredBackupWindow"] = cluster.PreferredBackupWindow;
|
|
2054
|
+
if (cluster.PreferredMaintenanceWindow !== void 0) result["PreferredMaintenanceWindow"] = cluster.PreferredMaintenanceWindow;
|
|
2055
|
+
if (cluster.CopyTagsToSnapshot !== void 0) result["CopyTagsToSnapshot"] = cluster.CopyTagsToSnapshot;
|
|
2056
|
+
const storageType = cluster.PendingModifiedValues?.StorageType ?? cluster.StorageType ?? (cluster.Engine?.toLowerCase().startsWith("aurora") ? "aurora" : void 0);
|
|
2057
|
+
if (storageType !== void 0) result["StorageType"] = storageType;
|
|
2058
|
+
const clusterLogs = liveLogExports(cluster.EnabledCloudwatchLogsExports, cluster.PendingModifiedValues?.PendingCloudwatchLogsExports);
|
|
2059
|
+
if (clusterLogs.length > 0) result["EnableCloudwatchLogsExports"] = clusterLogs;
|
|
2060
|
+
if (cluster.AutoMinorVersionUpgrade !== void 0) result["AutoMinorVersionUpgrade"] = cluster.AutoMinorVersionUpgrade;
|
|
2061
|
+
if (cluster.NetworkType !== void 0) result["NetworkType"] = cluster.NetworkType;
|
|
2062
|
+
if (cluster.PerformanceInsightsEnabled !== void 0) result["PerformanceInsightsEnabled"] = cluster.PerformanceInsightsEnabled;
|
|
2063
|
+
if (cluster.PerformanceInsightsKMSKeyId !== void 0) result["PerformanceInsightsKmsKeyId"] = cluster.PerformanceInsightsKMSKeyId;
|
|
2064
|
+
if (cluster.PerformanceInsightsRetentionPeriod !== void 0) result["PerformanceInsightsRetentionPeriod"] = cluster.PerformanceInsightsRetentionPeriod;
|
|
2065
|
+
if (cluster.HttpEndpointEnabled !== void 0) result["EnableHttpEndpoint"] = cluster.HttpEndpointEnabled;
|
|
2066
|
+
if (cluster.DatabaseInsightsMode !== void 0) result["DatabaseInsightsMode"] = cluster.DatabaseInsightsMode;
|
|
2067
|
+
if (cluster.EngineLifecycleSupport !== void 0) result["EngineLifecycleSupport"] = cluster.EngineLifecycleSupport;
|
|
2068
|
+
if (cluster.BacktrackWindow !== void 0) result["BacktrackWindow"] = cluster.BacktrackWindow;
|
|
2069
|
+
if (cluster.LocalWriteForwardingStatus !== void 0) result["EnableLocalWriteForwarding"] = cluster.LocalWriteForwardingStatus === "requested" || cluster.LocalWriteForwardingStatus === "enabled";
|
|
2070
|
+
result["AssociatedRoles"] = associatedRolesReadback(cluster.AssociatedRoles);
|
|
2071
|
+
if (cluster.DBClusterArn) await this.attachTags(result, cluster.DBClusterArn);
|
|
2072
|
+
return result;
|
|
2073
|
+
}
|
|
2074
|
+
async function importDBInstance(input) {
|
|
2075
|
+
const explicit = resolveExplicitPhysicalId(input, "DBInstanceIdentifier");
|
|
2076
|
+
if (explicit) try {
|
|
2077
|
+
const described = (await this.getClient().send(new DescribeDBInstancesCommand({ DBInstanceIdentifier: explicit }))).DBInstances?.[0];
|
|
2078
|
+
return {
|
|
2079
|
+
physicalId: explicit,
|
|
2080
|
+
attributes: definedAttributes({
|
|
2081
|
+
"Endpoint.Address": described?.Endpoint?.Address,
|
|
2082
|
+
"Endpoint.Port": stringifyIfAssigned(described?.Endpoint?.Port),
|
|
2083
|
+
Arn: described?.DBInstanceArn
|
|
2084
|
+
})
|
|
2085
|
+
};
|
|
2086
|
+
} catch (err) {
|
|
2087
|
+
if (err.name === "DBInstanceNotFoundFault") return null;
|
|
2088
|
+
throw err;
|
|
2089
|
+
}
|
|
2090
|
+
return null;
|
|
2091
|
+
}
|
|
2092
|
+
async function importDBCluster(input) {
|
|
2093
|
+
const explicit = resolveExplicitPhysicalId(input, "DBClusterIdentifier");
|
|
2094
|
+
if (explicit) try {
|
|
2095
|
+
const described = (await this.getClient().send(new DescribeDBClustersCommand({ DBClusterIdentifier: explicit }))).DBClusters?.[0];
|
|
2096
|
+
return {
|
|
2097
|
+
physicalId: explicit,
|
|
2098
|
+
attributes: definedAttributes({
|
|
2099
|
+
"Endpoint.Address": described?.Endpoint,
|
|
2100
|
+
"Endpoint.Port": stringifyIfAssigned(described?.Port),
|
|
2101
|
+
"ReadEndpoint.Address": described?.ReaderEndpoint,
|
|
2102
|
+
Arn: described?.DBClusterArn,
|
|
2103
|
+
DBClusterResourceId: described?.DbClusterResourceId
|
|
2104
|
+
})
|
|
2105
|
+
};
|
|
2106
|
+
} catch (err) {
|
|
2107
|
+
if (err.name === "DBClusterNotFoundFault") return null;
|
|
2108
|
+
throw err;
|
|
2109
|
+
}
|
|
2110
|
+
return null;
|
|
2111
|
+
}
|
|
2112
|
+
|
|
2113
|
+
// src/provisioning/providers/rds-provider.ts
|
|
2114
|
+
var RDSProvider = class {
|
|
2115
|
+
rdsClient;
|
|
2116
|
+
createClient;
|
|
2117
|
+
ec2Client;
|
|
2118
|
+
providerRegion;
|
|
2119
|
+
logger = getLogger().child("RDSProvider");
|
|
2120
|
+
protectionFlips = new ProtectionFlipRegistry();
|
|
2121
|
+
removalDefaults = /* @__PURE__ */ new Map();
|
|
2122
|
+
handledProperties = /* @__PURE__ */ new Map([
|
|
2123
|
+
["AWS::RDS::DBSubnetGroup", /* @__PURE__ */ new Set([
|
|
2124
|
+
"DBSubnetGroupName",
|
|
2125
|
+
"DBSubnetGroupDescription",
|
|
2126
|
+
"SubnetIds",
|
|
2127
|
+
"Tags"
|
|
2128
|
+
])],
|
|
2129
|
+
["AWS::RDS::DBCluster", /* @__PURE__ */ new Set([
|
|
2130
|
+
"DBClusterIdentifier",
|
|
2131
|
+
"Engine",
|
|
2132
|
+
"EngineVersion",
|
|
2133
|
+
"MasterUsername",
|
|
2134
|
+
"MasterUserPassword",
|
|
2135
|
+
"DatabaseName",
|
|
2136
|
+
"Port",
|
|
2137
|
+
"VpcSecurityGroupIds",
|
|
2138
|
+
"DBSubnetGroupName",
|
|
2139
|
+
"StorageEncrypted",
|
|
2140
|
+
"KmsKeyId",
|
|
2141
|
+
"BackupRetentionPeriod",
|
|
2142
|
+
"DeletionProtection",
|
|
2143
|
+
"ServerlessV2ScalingConfiguration",
|
|
2144
|
+
"Tags",
|
|
2145
|
+
"ManageMasterUserPassword",
|
|
2146
|
+
"MasterUserSecret",
|
|
2147
|
+
"MonitoringRoleArn",
|
|
2148
|
+
"MonitoringInterval",
|
|
2149
|
+
"EnableIAMDatabaseAuthentication",
|
|
2150
|
+
"PubliclyAccessible",
|
|
2151
|
+
"DBClusterParameterGroupName",
|
|
2152
|
+
"PreferredBackupWindow",
|
|
2153
|
+
"PreferredMaintenanceWindow",
|
|
2154
|
+
"CopyTagsToSnapshot",
|
|
2155
|
+
"StorageType",
|
|
2156
|
+
"EnableCloudwatchLogsExports",
|
|
2157
|
+
"AutoMinorVersionUpgrade",
|
|
2158
|
+
"NetworkType",
|
|
2159
|
+
"PerformanceInsightsEnabled",
|
|
2160
|
+
"PerformanceInsightsKmsKeyId",
|
|
2161
|
+
"PerformanceInsightsRetentionPeriod",
|
|
2162
|
+
"EnableHttpEndpoint",
|
|
2163
|
+
"DatabaseInsightsMode",
|
|
2164
|
+
"EngineLifecycleSupport",
|
|
2165
|
+
"MasterUserAuthenticationType",
|
|
2166
|
+
"BacktrackWindow",
|
|
2167
|
+
"EnableLocalWriteForwarding",
|
|
2168
|
+
"ClusterScalabilityType",
|
|
2169
|
+
"AssociatedRoles",
|
|
2170
|
+
"EngineMode",
|
|
2171
|
+
"AvailabilityZones",
|
|
2172
|
+
"GlobalClusterIdentifier"
|
|
2173
|
+
])],
|
|
2174
|
+
["AWS::RDS::DBInstance", /* @__PURE__ */ new Set([
|
|
2175
|
+
"DBInstanceIdentifier",
|
|
2176
|
+
"DBInstanceClass",
|
|
2177
|
+
"Engine",
|
|
2178
|
+
"DBClusterIdentifier",
|
|
2179
|
+
"DBSubnetGroupName",
|
|
2180
|
+
"PubliclyAccessible",
|
|
2181
|
+
"Tags",
|
|
2182
|
+
"AllocatedStorage",
|
|
2183
|
+
"DeletionProtection",
|
|
2184
|
+
"EngineVersion",
|
|
2185
|
+
"MasterUsername",
|
|
2186
|
+
"MasterUserPassword",
|
|
2187
|
+
"Port",
|
|
2188
|
+
"StorageEncrypted",
|
|
2189
|
+
"VPCSecurityGroups",
|
|
2190
|
+
"KmsKeyId",
|
|
2191
|
+
"MasterUserSecret",
|
|
2192
|
+
"ManageMasterUserPassword",
|
|
2193
|
+
"MonitoringRoleArn",
|
|
2194
|
+
"MonitoringInterval",
|
|
2195
|
+
"EnableIAMDatabaseAuthentication",
|
|
2196
|
+
"BackupRetentionPeriod",
|
|
2197
|
+
"PreferredBackupWindow",
|
|
2198
|
+
"PreferredMaintenanceWindow",
|
|
2199
|
+
"StorageType",
|
|
2200
|
+
"MultiAZ",
|
|
2201
|
+
"MaxAllocatedStorage",
|
|
2202
|
+
"AutoMinorVersionUpgrade",
|
|
2203
|
+
"CopyTagsToSnapshot",
|
|
2204
|
+
"EnablePerformanceInsights",
|
|
2205
|
+
"PerformanceInsightsKMSKeyId",
|
|
2206
|
+
"PerformanceInsightsRetentionPeriod",
|
|
2207
|
+
"Iops",
|
|
2208
|
+
"StorageThroughput",
|
|
2209
|
+
"OptionGroupName",
|
|
2210
|
+
"CACertificateIdentifier",
|
|
2211
|
+
"NetworkType",
|
|
2212
|
+
"LicenseModel",
|
|
2213
|
+
"PromotionTier",
|
|
2214
|
+
"DatabaseInsightsMode",
|
|
2215
|
+
"DedicatedLogVolume",
|
|
2216
|
+
"AllowMajorVersionUpgrade",
|
|
2217
|
+
"CertificateRotationRestart",
|
|
2218
|
+
"DBParameterGroupName",
|
|
2219
|
+
"EnableCloudwatchLogsExports",
|
|
2220
|
+
"DBName",
|
|
2221
|
+
"AvailabilityZone",
|
|
2222
|
+
"EngineLifecycleSupport",
|
|
2223
|
+
"MasterUserAuthenticationType",
|
|
2224
|
+
"AssociatedRoles"
|
|
2225
|
+
])]
|
|
2226
|
+
]);
|
|
2227
|
+
unhandledByDesign = /* @__PURE__ */ new Map([["AWS::RDS::DBCluster", /* @__PURE__ */ new Map([["DeleteAutomatedBackups", "delete-time flag, sent on the delete when the record carries it; kept unhandled so a template declaring it keeps its Cloud Control route. Final snapshots are governed by DeletionPolicy: Snapshot, which this flag does not control"], ["ScalingConfiguration", "Aurora Serverless v1 only (EngineMode serverless), retired by AWS: no aurora-mysql or aurora-postgresql engine version supports the serverless engine mode (DescribeDBEngineVersions, us-east-1, 2026-11-06). Aurora Serverless v2 uses ServerlessV2ScalingConfiguration"]])], ["AWS::RDS::DBInstance", /* @__PURE__ */ new Map([
|
|
2228
|
+
["DBSecurityGroups", "EC2-Classic-only feature retired by AWS (2022-08-15); new accounts cannot use this — use VPCSecurityGroups instead"],
|
|
2229
|
+
["ApplyImmediately", "cdkd always applies modifications immediately (rds:ModifyDBInstance.ApplyImmediately=true is hardcoded); users wanting maintenance-window deferral should run aws rds modify-db-instance directly"],
|
|
2230
|
+
["DeleteAutomatedBackups", "delete-time flag, sent on the delete when the record carries it; kept unhandled so a template declaring it keeps its Cloud Control route. Final snapshots are governed by DeletionPolicy: Snapshot, which this flag does not control"]
|
|
2231
|
+
])]]);
|
|
2232
|
+
constructor(options) {
|
|
2233
|
+
this.providerRegion = options?.region ?? ambientRegion();
|
|
2234
|
+
}
|
|
2235
|
+
getClient() {
|
|
2236
|
+
if (!this.rdsClient) {
|
|
2237
|
+
this.rdsClient = new RDSClient({
|
|
2238
|
+
...ambientClientDefaults(),
|
|
2239
|
+
...this.providerRegion ? { region: this.providerRegion } : {}
|
|
2240
|
+
});
|
|
2241
|
+
this.createClient = withoutServerErrorRetries(new RDSClient({
|
|
2242
|
+
...ambientClientDefaults(),
|
|
2243
|
+
...this.providerRegion ? { region: this.providerRegion } : {}
|
|
2244
|
+
}));
|
|
2245
|
+
}
|
|
2246
|
+
return this.rdsClient;
|
|
2247
|
+
}
|
|
2248
|
+
getEc2Client() {
|
|
2249
|
+
if (!this.ec2Client) this.ec2Client = new EC2Client({
|
|
2250
|
+
...ambientClientDefaults(),
|
|
2251
|
+
...this.providerRegion ? { region: this.providerRegion } : {}
|
|
2252
|
+
});
|
|
2253
|
+
return this.ec2Client;
|
|
2254
|
+
}
|
|
2255
|
+
getCreateClient() {
|
|
2256
|
+
this.getClient();
|
|
2257
|
+
return this.createClient;
|
|
2258
|
+
}
|
|
2259
|
+
create(logicalId, resourceType, properties, context) {
|
|
2260
|
+
return create.call(this, logicalId, resourceType, properties, context);
|
|
2261
|
+
}
|
|
2262
|
+
update(logicalId, physicalId, resourceType, properties, previousProperties, context) {
|
|
2263
|
+
return update.call(this, logicalId, physicalId, resourceType, properties, previousProperties, context);
|
|
2264
|
+
}
|
|
2265
|
+
delete(logicalId, physicalId, resourceType, properties, context) {
|
|
2266
|
+
return deleteImpl.call(this, logicalId, physicalId, resourceType, properties, context);
|
|
2267
|
+
}
|
|
2268
|
+
createDBSubnetGroup(logicalId, resourceType, properties, mask) {
|
|
2269
|
+
return createDBSubnetGroup.call(this, logicalId, resourceType, properties, mask);
|
|
2270
|
+
}
|
|
2271
|
+
updateDBSubnetGroup(logicalId, physicalId, resourceType, properties, previousProperties, mask) {
|
|
2272
|
+
return updateDBSubnetGroup.call(this, logicalId, physicalId, resourceType, properties, previousProperties, mask);
|
|
2273
|
+
}
|
|
2274
|
+
deleteDBSubnetGroup(logicalId, physicalId, resourceType, context) {
|
|
2275
|
+
return deleteDBSubnetGroup.call(this, logicalId, physicalId, resourceType, context);
|
|
2276
|
+
}
|
|
2277
|
+
createDBCluster(logicalId, resourceType, properties, mask, replaying = false) {
|
|
2278
|
+
return createDBCluster.call(this, logicalId, resourceType, properties, mask, replaying);
|
|
2279
|
+
}
|
|
2280
|
+
updateDBCluster(logicalId, physicalId, resourceType, properties, previousProperties, context) {
|
|
2281
|
+
return updateDBCluster.call(this, logicalId, physicalId, resourceType, properties, previousProperties, context);
|
|
2282
|
+
}
|
|
2283
|
+
deleteDBCluster(logicalId, physicalId, resourceType, properties, context) {
|
|
2284
|
+
return deleteDBCluster.call(this, logicalId, physicalId, resourceType, properties, context);
|
|
2285
|
+
}
|
|
2286
|
+
deleteDBClusterOnce(logicalId, physicalId, resourceType, properties, context, flip) {
|
|
2287
|
+
return deleteDBClusterOnce.call(this, logicalId, physicalId, resourceType, properties, context, flip);
|
|
2288
|
+
}
|
|
2289
|
+
createDBInstance(logicalId, resourceType, properties, mask, replaying = false) {
|
|
2290
|
+
return createDBInstance.call(this, logicalId, resourceType, properties, mask, replaying);
|
|
2291
|
+
}
|
|
2292
|
+
updateDBInstance(logicalId, physicalId, resourceType, properties, previousProperties, context) {
|
|
2293
|
+
return updateDBInstance.call(this, logicalId, physicalId, resourceType, properties, previousProperties, context);
|
|
2294
|
+
}
|
|
2295
|
+
deleteDBInstance(logicalId, physicalId, resourceType, properties, context) {
|
|
2296
|
+
return deleteDBInstance.call(this, logicalId, physicalId, resourceType, properties, context);
|
|
2297
|
+
}
|
|
2298
|
+
deleteDBInstanceOnce(logicalId, physicalId, resourceType, properties, context, flip) {
|
|
2299
|
+
return deleteDBInstanceOnce.call(this, logicalId, physicalId, resourceType, properties, context, flip);
|
|
2300
|
+
}
|
|
2301
|
+
applyTagDiff(arn, resourceType, logicalId, oldTagsRaw, newTagsRaw) {
|
|
2302
|
+
return applyTagDiff.call(this, arn, resourceType, logicalId, oldTagsRaw, newTagsRaw);
|
|
2303
|
+
}
|
|
2304
|
+
partialClusterRetiring(dbClusterIdentifier) {
|
|
2305
|
+
return partialClusterRetiring.call(this, dbClusterIdentifier);
|
|
2306
|
+
}
|
|
2307
|
+
isNotFoundError(error, faultName) {
|
|
2308
|
+
return isNotFoundError.call(this, error, faultName);
|
|
2309
|
+
}
|
|
2310
|
+
wrapCaughtError(mask, error, build) {
|
|
2311
|
+
return wrapCaughtError.call(this, mask, error, build);
|
|
2312
|
+
}
|
|
2313
|
+
wrapDeleteError(mask, error, build) {
|
|
2314
|
+
return wrapDeleteError.call(this, mask, error, build);
|
|
2315
|
+
}
|
|
2316
|
+
wrapGlobalClusterDetachError(error, mask, build) {
|
|
2317
|
+
return wrapGlobalClusterDetachError.call(this, error, mask, build);
|
|
2318
|
+
}
|
|
2319
|
+
detachFromGlobalCluster(logicalId, physicalId, globalClusterId, options, progress, mask) {
|
|
2320
|
+
return detachFromGlobalCluster.call(this, logicalId, physicalId, globalClusterId, options, progress, mask);
|
|
2321
|
+
}
|
|
2322
|
+
engineLifecycleSupportToSend(kind, logicalId, physicalId, resourceType, properties, previousProperties, context) {
|
|
2323
|
+
return engineLifecycleSupportToSend.call(this, kind, logicalId, physicalId, resourceType, properties, previousProperties, context);
|
|
2324
|
+
}
|
|
2325
|
+
describeDBCluster(dbClusterIdentifier) {
|
|
2326
|
+
return describeDBCluster.call(this, dbClusterIdentifier);
|
|
2327
|
+
}
|
|
2328
|
+
securityGroupsToSend(target, logicalId, physicalId, resourceType, properties, previousProperties, context) {
|
|
2329
|
+
return securityGroupsToSend.call(this, target, logicalId, physicalId, resourceType, properties, previousProperties, context);
|
|
2330
|
+
}
|
|
2331
|
+
describeDBInstance(dbInstanceIdentifier) {
|
|
2332
|
+
return describeDBInstance.call(this, dbInstanceIdentifier);
|
|
2333
|
+
}
|
|
2334
|
+
waitForMemberAfterClusterChange(dbInstanceIdentifier, clusterLogicalId, transitional, change, maxWaitMs = 18e5) {
|
|
2335
|
+
return waitForMemberAfterClusterChange.call(this, dbInstanceIdentifier, clusterLogicalId, transitional, change, maxWaitMs);
|
|
2336
|
+
}
|
|
2337
|
+
requireClusterWhileWaiting(cluster, logicalId, change) {
|
|
2338
|
+
return requireClusterWhileWaiting.call(this, cluster, logicalId, change);
|
|
2339
|
+
}
|
|
2340
|
+
waitForClusterPortApplied(dbClusterIdentifier, logicalId, port, maxWaitMs = 18e5) {
|
|
2341
|
+
return waitForClusterPortApplied.call(this, dbClusterIdentifier, logicalId, port, maxWaitMs);
|
|
2342
|
+
}
|
|
2343
|
+
waitForSecurityGroupsApplied(dbClusterIdentifier, logicalId, expected, maxWaitMs = 18e5) {
|
|
2344
|
+
return waitForSecurityGroupsApplied.call(this, dbClusterIdentifier, logicalId, expected, maxWaitMs);
|
|
2345
|
+
}
|
|
2346
|
+
waitForClusterState(logicalId, dbClusterIdentifier, done, change) {
|
|
2347
|
+
return waitForClusterState.call(this, logicalId, dbClusterIdentifier, done, change);
|
|
2348
|
+
}
|
|
2349
|
+
sendHttpEndpointChange(logicalId, physicalId, arn, enable) {
|
|
2350
|
+
return sendHttpEndpointChange.call(this, logicalId, physicalId, arn, enable);
|
|
2351
|
+
}
|
|
2352
|
+
deleteAfterProtectionFlip(logicalId, physicalId, send) {
|
|
2353
|
+
return deleteAfterProtectionFlip.call(this, logicalId, physicalId, send);
|
|
2354
|
+
}
|
|
2355
|
+
deleteInstanceAfterProtectionFlip(logicalId, physicalId, send) {
|
|
2356
|
+
return deleteInstanceAfterProtectionFlip.call(this, logicalId, physicalId, send);
|
|
2357
|
+
}
|
|
2358
|
+
desiredAssociatedRoles(properties, resourceType, logicalId, physicalId, replayingCreate) {
|
|
2359
|
+
return desiredAssociatedRoles.call(this, properties, resourceType, logicalId, physicalId, replayingCreate);
|
|
2360
|
+
}
|
|
2361
|
+
applyAssociatedRoles(target, logicalId, physicalId, desired, previous, mask, marks) {
|
|
2362
|
+
return applyAssociatedRoles.call(this, target, logicalId, physicalId, desired, previous, mask, marks);
|
|
2363
|
+
}
|
|
2364
|
+
waitForClusterAvailable(logicalId, dbClusterIdentifier, maxWaitMs = 18e5, doing = "being created") {
|
|
2365
|
+
return waitForClusterAvailable.call(this, logicalId, dbClusterIdentifier, maxWaitMs, doing);
|
|
2366
|
+
}
|
|
2367
|
+
waitForClusterDeleted(logicalId, dbClusterIdentifier, maxWaitMs = 18e5) {
|
|
2368
|
+
return waitForClusterDeleted.call(this, logicalId, dbClusterIdentifier, maxWaitMs);
|
|
2369
|
+
}
|
|
2370
|
+
rebootForPendingParameterGroup(logicalId, physicalId, sentGroup, caRotationRestarts) {
|
|
2371
|
+
return rebootForPendingParameterGroup.call(this, logicalId, physicalId, sentGroup, caRotationRestarts);
|
|
2372
|
+
}
|
|
2373
|
+
waitForInstanceState(logicalId, dbInstanceIdentifier, done, change) {
|
|
2374
|
+
return waitForInstanceState.call(this, logicalId, dbInstanceIdentifier, done, change);
|
|
2375
|
+
}
|
|
2376
|
+
waitForInstanceAvailable(logicalId, dbInstanceIdentifier, maxWaitMs = 18e5, doing = "being created") {
|
|
2377
|
+
return waitForInstanceAvailable.call(this, logicalId, dbInstanceIdentifier, maxWaitMs, doing);
|
|
2378
|
+
}
|
|
2379
|
+
waitForInstanceDeleted(logicalId, dbInstanceIdentifier, maxWaitMs = 18e5) {
|
|
2380
|
+
return waitForInstanceDeleted.call(this, logicalId, dbInstanceIdentifier, maxWaitMs);
|
|
2381
|
+
}
|
|
2382
|
+
sleep(ms) {
|
|
2383
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
2384
|
+
}
|
|
2385
|
+
import(input) {
|
|
2386
|
+
return importImpl.call(this, input);
|
|
2387
|
+
}
|
|
2388
|
+
getDriftUnorderedPaths(resourceType) {
|
|
2389
|
+
return getDriftUnorderedPaths.call(this, resourceType);
|
|
2390
|
+
}
|
|
2391
|
+
getDriftUnknownPaths(resourceType, properties) {
|
|
2392
|
+
return getDriftUnknownPaths.call(this, resourceType, properties);
|
|
2393
|
+
}
|
|
2394
|
+
canonicalizeDriftProperties(resourceType, properties) {
|
|
2395
|
+
return canonicalizeDriftProperties.call(this, resourceType, properties);
|
|
2396
|
+
}
|
|
2397
|
+
canonicalizeUnsettledProperties(resourceType, properties) {
|
|
2398
|
+
return canonicalizeUnsettledProperties.call(this, resourceType, properties);
|
|
2399
|
+
}
|
|
2400
|
+
readUnsettled(physicalId, logicalId, resourceType, names, recordedProperties, desiredProperties, attemptedItems) {
|
|
2401
|
+
return readUnsettled.call(this, physicalId, logicalId, resourceType, names, recordedProperties, desiredProperties, attemptedItems);
|
|
2402
|
+
}
|
|
2403
|
+
readCurrentState(physicalId, _logicalId, resourceType) {
|
|
2404
|
+
return readCurrentState.call(this, physicalId, _logicalId, resourceType);
|
|
2405
|
+
}
|
|
2406
|
+
isSameResource(journaledPhysicalId, record, resourceType, context) {
|
|
2407
|
+
return isSameResource.call(this, journaledPhysicalId, record, resourceType, context);
|
|
2408
|
+
}
|
|
2409
|
+
resourceIdentity(physicalId, resourceType, context) {
|
|
2410
|
+
return resourceIdentity.call(this, physicalId, resourceType, context);
|
|
2411
|
+
}
|
|
2412
|
+
readDbResourceIdIfExists(resourceType, identifier) {
|
|
2413
|
+
return readDbResourceIdIfExists.call(this, resourceType, identifier);
|
|
2414
|
+
}
|
|
2415
|
+
readCurrentStateDBInstance(physicalId) {
|
|
2416
|
+
return readCurrentStateDBInstance.call(this, physicalId);
|
|
2417
|
+
}
|
|
2418
|
+
readCurrentStateDBCluster(physicalId) {
|
|
2419
|
+
return readCurrentStateDBCluster.call(this, physicalId);
|
|
2420
|
+
}
|
|
2421
|
+
readCurrentStateDBSubnetGroup(physicalId) {
|
|
2422
|
+
return readCurrentStateDBSubnetGroup.call(this, physicalId);
|
|
2423
|
+
}
|
|
2424
|
+
attachTags(result, arn) {
|
|
2425
|
+
return attachTags.call(this, result, arn);
|
|
2426
|
+
}
|
|
2427
|
+
importDBInstance(input) {
|
|
2428
|
+
return importDBInstance.call(this, input);
|
|
2429
|
+
}
|
|
2430
|
+
importDBCluster(input) {
|
|
2431
|
+
return importDBCluster.call(this, input);
|
|
2432
|
+
}
|
|
2433
|
+
importDBSubnetGroup(input) {
|
|
2434
|
+
return importDBSubnetGroup.call(this, input);
|
|
2435
|
+
}
|
|
2436
|
+
};
|
|
2437
|
+
|
|
2438
|
+
export { RDSProvider };
|
|
2439
|
+
//# sourceMappingURL=rds-provider-BI5PcgWT.js.map
|