@stacksjs/ts-cloud 0.7.5 → 0.7.6
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/aws/index.js +259 -0
- package/dist/bin/cli.js +124 -124
- package/dist/chunk-0wxyppza.js +146 -0
- package/dist/chunk-3knnr7wh.js +601 -0
- package/dist/chunk-3rsfns7x.js +10427 -0
- package/dist/chunk-93hjhs78.js +1752 -0
- package/dist/chunk-arsh1g5h.js +1749 -0
- package/dist/chunk-b82pbxyp.js +1572 -0
- package/dist/chunk-c6rgvg1j.js +46124 -0
- package/dist/chunk-d2p5n2aq.js +23 -0
- package/dist/chunk-d7p84vz5.js +1699 -0
- package/dist/chunk-dpkk640m.js +4392 -0
- package/dist/chunk-eq08r166.js +8 -0
- package/dist/chunk-hsk6fe6x.js +371 -0
- package/dist/chunk-mj1tmhte.js +13 -0
- package/dist/chunk-p6309384.js +12828 -0
- package/dist/chunk-pegd7rmf.js +10 -0
- package/dist/chunk-pqfzdg68.js +12 -0
- package/dist/chunk-qpj3edwz.js +601 -0
- package/dist/chunk-tjjgajbh.js +1032 -0
- package/dist/chunk-tnztxpcb.js +630 -0
- package/dist/chunk-tt4kxske.js +1788 -0
- package/dist/chunk-v0bahtg2.js +4 -0
- package/dist/chunk-vd87cpvn.js +1754 -0
- package/dist/chunk-zn0nxxa8.js +1779 -0
- package/dist/deploy/index.js +87 -0
- package/dist/dns/index.js +31 -0
- package/dist/drivers/index.js +98 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4383 -91358
- package/dist/push/index.js +509 -0
- package/dist/ui/index.html +3 -3
- package/dist/ui/server/actions.html +3 -3
- package/dist/ui/server/backups.html +3 -3
- package/dist/ui/server/database.html +3 -3
- package/dist/ui/server/deployments.html +3 -3
- package/dist/ui/server/firewall.html +3 -3
- package/dist/ui/server/logs.html +3 -3
- package/dist/ui/server/services.html +3 -3
- package/dist/ui/server/sites.html +3 -3
- package/dist/ui/server/ssh-keys.html +3 -3
- package/dist/ui/server/terminal.html +3 -3
- package/dist/ui/server/workers.html +3 -3
- package/dist/ui/serverless/alarms.html +3 -3
- package/dist/ui/serverless/assets.html +3 -3
- package/dist/ui/serverless/data.html +3 -3
- package/dist/ui/serverless/deployments.html +3 -3
- package/dist/ui/serverless/functions.html +3 -3
- package/dist/ui/serverless/logs.html +3 -3
- package/dist/ui/serverless/queues.html +3 -3
- package/dist/ui/serverless/scheduler.html +3 -3
- package/dist/ui/serverless/secrets.html +3 -3
- package/dist/ui/serverless/traces.html +3 -3
- package/dist/ui/serverless.html +3 -3
- package/package.json +3 -3
|
@@ -0,0 +1,601 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AWSClient,
|
|
3
|
+
buildQueryParams
|
|
4
|
+
} from "./chunk-arsh1g5h.js";
|
|
5
|
+
|
|
6
|
+
// src/aws/rds.ts
|
|
7
|
+
class RDSClient {
|
|
8
|
+
client;
|
|
9
|
+
region;
|
|
10
|
+
constructor(region = "us-east-1") {
|
|
11
|
+
this.region = region;
|
|
12
|
+
this.client = new AWSClient;
|
|
13
|
+
}
|
|
14
|
+
async describeDBInstances(options) {
|
|
15
|
+
const params = {
|
|
16
|
+
Action: "DescribeDBInstances",
|
|
17
|
+
Version: "2014-10-31"
|
|
18
|
+
};
|
|
19
|
+
if (options?.DBInstanceIdentifier) {
|
|
20
|
+
params.DBInstanceIdentifier = options.DBInstanceIdentifier;
|
|
21
|
+
}
|
|
22
|
+
if (options?.MaxRecords) {
|
|
23
|
+
params.MaxRecords = options.MaxRecords;
|
|
24
|
+
}
|
|
25
|
+
if (options?.Marker) {
|
|
26
|
+
params.Marker = options.Marker;
|
|
27
|
+
}
|
|
28
|
+
if (options?.Filters) {
|
|
29
|
+
options.Filters.forEach((filter, i) => {
|
|
30
|
+
params[`Filters.Filter.${i + 1}.Name`] = filter.Name;
|
|
31
|
+
filter.Values.forEach((value, j) => {
|
|
32
|
+
params[`Filters.Filter.${i + 1}.Values.Value.${j + 1}`] = value;
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
const queryString = new URLSearchParams(buildQueryParams(params)).toString();
|
|
37
|
+
const result = await this.client.request({
|
|
38
|
+
service: "rds",
|
|
39
|
+
region: this.region,
|
|
40
|
+
method: "POST",
|
|
41
|
+
path: "/",
|
|
42
|
+
headers: {
|
|
43
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
44
|
+
},
|
|
45
|
+
body: queryString
|
|
46
|
+
});
|
|
47
|
+
const response = result.DescribeDBInstancesResult || result;
|
|
48
|
+
let instances = response.DBInstances?.DBInstance || [];
|
|
49
|
+
if (!Array.isArray(instances)) {
|
|
50
|
+
instances = instances ? [instances] : [];
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
DBInstances: instances,
|
|
54
|
+
Marker: response.Marker
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
async describeDBInstance(dbInstanceIdentifier) {
|
|
58
|
+
const result = await this.describeDBInstances({ DBInstanceIdentifier: dbInstanceIdentifier });
|
|
59
|
+
return result.DBInstances?.[0];
|
|
60
|
+
}
|
|
61
|
+
async describeDBClusters(options) {
|
|
62
|
+
const params = {
|
|
63
|
+
Action: "DescribeDBClusters",
|
|
64
|
+
Version: "2014-10-31"
|
|
65
|
+
};
|
|
66
|
+
if (options?.DBClusterIdentifier) {
|
|
67
|
+
params.DBClusterIdentifier = options.DBClusterIdentifier;
|
|
68
|
+
}
|
|
69
|
+
if (options?.MaxRecords) {
|
|
70
|
+
params.MaxRecords = options.MaxRecords;
|
|
71
|
+
}
|
|
72
|
+
if (options?.Marker) {
|
|
73
|
+
params.Marker = options.Marker;
|
|
74
|
+
}
|
|
75
|
+
if (options?.Filters) {
|
|
76
|
+
options.Filters.forEach((filter, i) => {
|
|
77
|
+
params[`Filters.Filter.${i + 1}.Name`] = filter.Name;
|
|
78
|
+
filter.Values.forEach((value, j) => {
|
|
79
|
+
params[`Filters.Filter.${i + 1}.Values.Value.${j + 1}`] = value;
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
const queryString = new URLSearchParams(buildQueryParams(params)).toString();
|
|
84
|
+
const result = await this.client.request({
|
|
85
|
+
service: "rds",
|
|
86
|
+
region: this.region,
|
|
87
|
+
method: "POST",
|
|
88
|
+
path: "/",
|
|
89
|
+
headers: {
|
|
90
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
91
|
+
},
|
|
92
|
+
body: queryString
|
|
93
|
+
});
|
|
94
|
+
const response = result.DescribeDBClustersResult || result;
|
|
95
|
+
let clusters = response.DBClusters?.DBCluster || [];
|
|
96
|
+
if (!Array.isArray(clusters)) {
|
|
97
|
+
clusters = clusters ? [clusters] : [];
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
DBClusters: clusters,
|
|
101
|
+
Marker: response.Marker
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
async describeDBSnapshots(options) {
|
|
105
|
+
const params = {
|
|
106
|
+
Action: "DescribeDBSnapshots",
|
|
107
|
+
Version: "2014-10-31"
|
|
108
|
+
};
|
|
109
|
+
if (options?.DBInstanceIdentifier) {
|
|
110
|
+
params.DBInstanceIdentifier = options.DBInstanceIdentifier;
|
|
111
|
+
}
|
|
112
|
+
if (options?.DBSnapshotIdentifier) {
|
|
113
|
+
params.DBSnapshotIdentifier = options.DBSnapshotIdentifier;
|
|
114
|
+
}
|
|
115
|
+
if (options?.SnapshotType) {
|
|
116
|
+
params.SnapshotType = options.SnapshotType;
|
|
117
|
+
}
|
|
118
|
+
if (options?.MaxRecords) {
|
|
119
|
+
params.MaxRecords = options.MaxRecords;
|
|
120
|
+
}
|
|
121
|
+
if (options?.Marker) {
|
|
122
|
+
params.Marker = options.Marker;
|
|
123
|
+
}
|
|
124
|
+
const queryString = new URLSearchParams(buildQueryParams(params)).toString();
|
|
125
|
+
const result = await this.client.request({
|
|
126
|
+
service: "rds",
|
|
127
|
+
region: this.region,
|
|
128
|
+
method: "POST",
|
|
129
|
+
path: "/",
|
|
130
|
+
headers: {
|
|
131
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
132
|
+
},
|
|
133
|
+
body: queryString
|
|
134
|
+
});
|
|
135
|
+
const response = result.DescribeDBSnapshotsResult || result;
|
|
136
|
+
let snapshots = response.DBSnapshots?.DBSnapshot || [];
|
|
137
|
+
if (!Array.isArray(snapshots)) {
|
|
138
|
+
snapshots = snapshots ? [snapshots] : [];
|
|
139
|
+
}
|
|
140
|
+
return {
|
|
141
|
+
DBSnapshots: snapshots,
|
|
142
|
+
Marker: response.Marker
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
async describeDBSubnetGroups(options) {
|
|
146
|
+
const params = {
|
|
147
|
+
Action: "DescribeDBSubnetGroups",
|
|
148
|
+
Version: "2014-10-31"
|
|
149
|
+
};
|
|
150
|
+
if (options?.DBSubnetGroupName) {
|
|
151
|
+
params.DBSubnetGroupName = options.DBSubnetGroupName;
|
|
152
|
+
}
|
|
153
|
+
if (options?.MaxRecords) {
|
|
154
|
+
params.MaxRecords = options.MaxRecords;
|
|
155
|
+
}
|
|
156
|
+
if (options?.Marker) {
|
|
157
|
+
params.Marker = options.Marker;
|
|
158
|
+
}
|
|
159
|
+
const queryString = new URLSearchParams(buildQueryParams(params)).toString();
|
|
160
|
+
const result = await this.client.request({
|
|
161
|
+
service: "rds",
|
|
162
|
+
region: this.region,
|
|
163
|
+
method: "POST",
|
|
164
|
+
path: "/",
|
|
165
|
+
headers: {
|
|
166
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
167
|
+
},
|
|
168
|
+
body: queryString
|
|
169
|
+
});
|
|
170
|
+
const response = result.DescribeDBSubnetGroupsResult || result;
|
|
171
|
+
let groups = response.DBSubnetGroups?.DBSubnetGroup || [];
|
|
172
|
+
if (!Array.isArray(groups)) {
|
|
173
|
+
groups = groups ? [groups] : [];
|
|
174
|
+
}
|
|
175
|
+
return {
|
|
176
|
+
DBSubnetGroups: groups,
|
|
177
|
+
Marker: response.Marker
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
async createDBInstance(options) {
|
|
181
|
+
const params = {
|
|
182
|
+
Action: "CreateDBInstance",
|
|
183
|
+
Version: "2014-10-31",
|
|
184
|
+
DBInstanceIdentifier: options.DBInstanceIdentifier,
|
|
185
|
+
DBInstanceClass: options.DBInstanceClass,
|
|
186
|
+
Engine: options.Engine
|
|
187
|
+
};
|
|
188
|
+
if (options.DBClusterIdentifier)
|
|
189
|
+
params.DBClusterIdentifier = options.DBClusterIdentifier;
|
|
190
|
+
if (options.MasterUsername)
|
|
191
|
+
params.MasterUsername = options.MasterUsername;
|
|
192
|
+
if (options.MasterUserPassword)
|
|
193
|
+
params.MasterUserPassword = options.MasterUserPassword;
|
|
194
|
+
if (options.DBName)
|
|
195
|
+
params.DBName = options.DBName;
|
|
196
|
+
if (options.AllocatedStorage)
|
|
197
|
+
params.AllocatedStorage = options.AllocatedStorage;
|
|
198
|
+
if (options.DBSubnetGroupName)
|
|
199
|
+
params.DBSubnetGroupName = options.DBSubnetGroupName;
|
|
200
|
+
if (options.AvailabilityZone)
|
|
201
|
+
params.AvailabilityZone = options.AvailabilityZone;
|
|
202
|
+
if (options.PreferredMaintenanceWindow)
|
|
203
|
+
params.PreferredMaintenanceWindow = options.PreferredMaintenanceWindow;
|
|
204
|
+
if (options.PreferredBackupWindow)
|
|
205
|
+
params.PreferredBackupWindow = options.PreferredBackupWindow;
|
|
206
|
+
if (options.BackupRetentionPeriod !== undefined)
|
|
207
|
+
params.BackupRetentionPeriod = options.BackupRetentionPeriod;
|
|
208
|
+
if (options.MultiAZ !== undefined)
|
|
209
|
+
params.MultiAZ = options.MultiAZ;
|
|
210
|
+
if (options.EngineVersion)
|
|
211
|
+
params.EngineVersion = options.EngineVersion;
|
|
212
|
+
if (options.AutoMinorVersionUpgrade !== undefined)
|
|
213
|
+
params.AutoMinorVersionUpgrade = options.AutoMinorVersionUpgrade;
|
|
214
|
+
if (options.LicenseModel)
|
|
215
|
+
params.LicenseModel = options.LicenseModel;
|
|
216
|
+
if (options.PubliclyAccessible !== undefined)
|
|
217
|
+
params.PubliclyAccessible = options.PubliclyAccessible;
|
|
218
|
+
if (options.StorageType)
|
|
219
|
+
params.StorageType = options.StorageType;
|
|
220
|
+
if (options.StorageEncrypted !== undefined)
|
|
221
|
+
params.StorageEncrypted = options.StorageEncrypted;
|
|
222
|
+
if (options.KmsKeyId)
|
|
223
|
+
params.KmsKeyId = options.KmsKeyId;
|
|
224
|
+
if (options.DeletionProtection !== undefined)
|
|
225
|
+
params.DeletionProtection = options.DeletionProtection;
|
|
226
|
+
if (options.VpcSecurityGroupIds) {
|
|
227
|
+
options.VpcSecurityGroupIds.forEach((id, i) => {
|
|
228
|
+
params[`VpcSecurityGroupIds.VpcSecurityGroupId.${i + 1}`] = id;
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
if (options.Tags) {
|
|
232
|
+
options.Tags.forEach((tag, i) => {
|
|
233
|
+
params[`Tags.Tag.${i + 1}.Key`] = tag.Key;
|
|
234
|
+
params[`Tags.Tag.${i + 1}.Value`] = tag.Value;
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
const queryString = new URLSearchParams(buildQueryParams(params)).toString();
|
|
238
|
+
const result = await this.client.request({
|
|
239
|
+
service: "rds",
|
|
240
|
+
region: this.region,
|
|
241
|
+
method: "POST",
|
|
242
|
+
path: "/",
|
|
243
|
+
headers: {
|
|
244
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
245
|
+
},
|
|
246
|
+
body: queryString
|
|
247
|
+
});
|
|
248
|
+
const response = result.CreateDBInstanceResult || result;
|
|
249
|
+
return {
|
|
250
|
+
DBInstance: response.DBInstance
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
async deleteDBInstance(options) {
|
|
254
|
+
const params = {
|
|
255
|
+
Action: "DeleteDBInstance",
|
|
256
|
+
Version: "2014-10-31",
|
|
257
|
+
DBInstanceIdentifier: options.DBInstanceIdentifier
|
|
258
|
+
};
|
|
259
|
+
if (options.SkipFinalSnapshot !== undefined) {
|
|
260
|
+
params.SkipFinalSnapshot = options.SkipFinalSnapshot;
|
|
261
|
+
}
|
|
262
|
+
if (options.FinalDBSnapshotIdentifier) {
|
|
263
|
+
params.FinalDBSnapshotIdentifier = options.FinalDBSnapshotIdentifier;
|
|
264
|
+
}
|
|
265
|
+
if (options.DeleteAutomatedBackups !== undefined) {
|
|
266
|
+
params.DeleteAutomatedBackups = options.DeleteAutomatedBackups;
|
|
267
|
+
}
|
|
268
|
+
const queryString = new URLSearchParams(buildQueryParams(params)).toString();
|
|
269
|
+
const result = await this.client.request({
|
|
270
|
+
service: "rds",
|
|
271
|
+
region: this.region,
|
|
272
|
+
method: "POST",
|
|
273
|
+
path: "/",
|
|
274
|
+
headers: {
|
|
275
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
276
|
+
},
|
|
277
|
+
body: queryString
|
|
278
|
+
});
|
|
279
|
+
const response = result.DeleteDBInstanceResult || result;
|
|
280
|
+
return {
|
|
281
|
+
DBInstance: response.DBInstance
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
async modifyDBInstance(options) {
|
|
285
|
+
const params = {
|
|
286
|
+
Action: "ModifyDBInstance",
|
|
287
|
+
Version: "2014-10-31",
|
|
288
|
+
DBInstanceIdentifier: options.DBInstanceIdentifier
|
|
289
|
+
};
|
|
290
|
+
if (options.DBInstanceClass)
|
|
291
|
+
params.DBInstanceClass = options.DBInstanceClass;
|
|
292
|
+
if (options.AllocatedStorage)
|
|
293
|
+
params.AllocatedStorage = options.AllocatedStorage;
|
|
294
|
+
if (options.MasterUserPassword)
|
|
295
|
+
params.MasterUserPassword = options.MasterUserPassword;
|
|
296
|
+
if (options.BackupRetentionPeriod !== undefined)
|
|
297
|
+
params.BackupRetentionPeriod = options.BackupRetentionPeriod;
|
|
298
|
+
if (options.PreferredBackupWindow)
|
|
299
|
+
params.PreferredBackupWindow = options.PreferredBackupWindow;
|
|
300
|
+
if (options.PreferredMaintenanceWindow)
|
|
301
|
+
params.PreferredMaintenanceWindow = options.PreferredMaintenanceWindow;
|
|
302
|
+
if (options.MultiAZ !== undefined)
|
|
303
|
+
params.MultiAZ = options.MultiAZ;
|
|
304
|
+
if (options.EngineVersion)
|
|
305
|
+
params.EngineVersion = options.EngineVersion;
|
|
306
|
+
if (options.AutoMinorVersionUpgrade !== undefined)
|
|
307
|
+
params.AutoMinorVersionUpgrade = options.AutoMinorVersionUpgrade;
|
|
308
|
+
if (options.PubliclyAccessible !== undefined)
|
|
309
|
+
params.PubliclyAccessible = options.PubliclyAccessible;
|
|
310
|
+
if (options.ApplyImmediately !== undefined)
|
|
311
|
+
params.ApplyImmediately = options.ApplyImmediately;
|
|
312
|
+
if (options.StorageType)
|
|
313
|
+
params.StorageType = options.StorageType;
|
|
314
|
+
if (options.DeletionProtection !== undefined)
|
|
315
|
+
params.DeletionProtection = options.DeletionProtection;
|
|
316
|
+
if (options.VpcSecurityGroupIds) {
|
|
317
|
+
options.VpcSecurityGroupIds.forEach((id, i) => {
|
|
318
|
+
params[`VpcSecurityGroupIds.VpcSecurityGroupId.${i + 1}`] = id;
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
const queryString = new URLSearchParams(buildQueryParams(params)).toString();
|
|
322
|
+
const result = await this.client.request({
|
|
323
|
+
service: "rds",
|
|
324
|
+
region: this.region,
|
|
325
|
+
method: "POST",
|
|
326
|
+
path: "/",
|
|
327
|
+
headers: {
|
|
328
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
329
|
+
},
|
|
330
|
+
body: queryString
|
|
331
|
+
});
|
|
332
|
+
const response = result.ModifyDBInstanceResult || result;
|
|
333
|
+
return {
|
|
334
|
+
DBInstance: response.DBInstance
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
async modifyDBCluster(options) {
|
|
338
|
+
const params = {
|
|
339
|
+
Action: "ModifyDBCluster",
|
|
340
|
+
Version: "2014-10-31",
|
|
341
|
+
DBClusterIdentifier: options.DBClusterIdentifier
|
|
342
|
+
};
|
|
343
|
+
if (options.ServerlessV2ScalingConfiguration) {
|
|
344
|
+
params["ServerlessV2ScalingConfiguration.MinCapacity"] = options.ServerlessV2ScalingConfiguration.MinCapacity;
|
|
345
|
+
params["ServerlessV2ScalingConfiguration.MaxCapacity"] = options.ServerlessV2ScalingConfiguration.MaxCapacity;
|
|
346
|
+
}
|
|
347
|
+
if (options.BackupRetentionPeriod !== undefined)
|
|
348
|
+
params.BackupRetentionPeriod = options.BackupRetentionPeriod;
|
|
349
|
+
if (options.ApplyImmediately !== undefined)
|
|
350
|
+
params.ApplyImmediately = options.ApplyImmediately;
|
|
351
|
+
const queryString = new URLSearchParams(buildQueryParams(params)).toString();
|
|
352
|
+
const result = await this.client.request({
|
|
353
|
+
service: "rds",
|
|
354
|
+
region: this.region,
|
|
355
|
+
method: "POST",
|
|
356
|
+
path: "/",
|
|
357
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
358
|
+
body: queryString
|
|
359
|
+
});
|
|
360
|
+
const response = result.ModifyDBClusterResult || result;
|
|
361
|
+
return { DBCluster: response.DBCluster };
|
|
362
|
+
}
|
|
363
|
+
async restoreDBClusterToPointInTime(options) {
|
|
364
|
+
const params = {
|
|
365
|
+
Action: "RestoreDBClusterToPointInTime",
|
|
366
|
+
Version: "2014-10-31",
|
|
367
|
+
DBClusterIdentifier: options.DBClusterIdentifier,
|
|
368
|
+
SourceDBClusterIdentifier: options.SourceDBClusterIdentifier
|
|
369
|
+
};
|
|
370
|
+
if (options.RestoreToTime)
|
|
371
|
+
params.RestoreToTime = options.RestoreToTime.toISOString();
|
|
372
|
+
if (options.UseLatestRestorableTime)
|
|
373
|
+
params.UseLatestRestorableTime = true;
|
|
374
|
+
if (options.DBSubnetGroupName)
|
|
375
|
+
params.DBSubnetGroupName = options.DBSubnetGroupName;
|
|
376
|
+
if (options.VpcSecurityGroupIds) {
|
|
377
|
+
options.VpcSecurityGroupIds.forEach((id, i) => {
|
|
378
|
+
params[`VpcSecurityGroupIds.VpcSecurityGroupId.${i + 1}`] = id;
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
const queryString = new URLSearchParams(buildQueryParams(params)).toString();
|
|
382
|
+
const result = await this.client.request({
|
|
383
|
+
service: "rds",
|
|
384
|
+
region: this.region,
|
|
385
|
+
method: "POST",
|
|
386
|
+
path: "/",
|
|
387
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
388
|
+
body: queryString
|
|
389
|
+
});
|
|
390
|
+
const response = result.RestoreDBClusterToPointInTimeResult || result;
|
|
391
|
+
return { DBCluster: response.DBCluster };
|
|
392
|
+
}
|
|
393
|
+
async startDBInstance(dbInstanceIdentifier) {
|
|
394
|
+
const params = {
|
|
395
|
+
Action: "StartDBInstance",
|
|
396
|
+
Version: "2014-10-31",
|
|
397
|
+
DBInstanceIdentifier: dbInstanceIdentifier
|
|
398
|
+
};
|
|
399
|
+
const queryString = new URLSearchParams(buildQueryParams(params)).toString();
|
|
400
|
+
const result = await this.client.request({
|
|
401
|
+
service: "rds",
|
|
402
|
+
region: this.region,
|
|
403
|
+
method: "POST",
|
|
404
|
+
path: "/",
|
|
405
|
+
headers: {
|
|
406
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
407
|
+
},
|
|
408
|
+
body: queryString
|
|
409
|
+
});
|
|
410
|
+
const response = result.StartDBInstanceResult || result;
|
|
411
|
+
return {
|
|
412
|
+
DBInstance: response.DBInstance
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
async stopDBInstance(options) {
|
|
416
|
+
const params = {
|
|
417
|
+
Action: "StopDBInstance",
|
|
418
|
+
Version: "2014-10-31",
|
|
419
|
+
DBInstanceIdentifier: options.DBInstanceIdentifier
|
|
420
|
+
};
|
|
421
|
+
if (options.DBSnapshotIdentifier) {
|
|
422
|
+
params.DBSnapshotIdentifier = options.DBSnapshotIdentifier;
|
|
423
|
+
}
|
|
424
|
+
const queryString = new URLSearchParams(buildQueryParams(params)).toString();
|
|
425
|
+
const result = await this.client.request({
|
|
426
|
+
service: "rds",
|
|
427
|
+
region: this.region,
|
|
428
|
+
method: "POST",
|
|
429
|
+
path: "/",
|
|
430
|
+
headers: {
|
|
431
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
432
|
+
},
|
|
433
|
+
body: queryString
|
|
434
|
+
});
|
|
435
|
+
const response = result.StopDBInstanceResult || result;
|
|
436
|
+
return {
|
|
437
|
+
DBInstance: response.DBInstance
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
async rebootDBInstance(options) {
|
|
441
|
+
const params = {
|
|
442
|
+
Action: "RebootDBInstance",
|
|
443
|
+
Version: "2014-10-31",
|
|
444
|
+
DBInstanceIdentifier: options.DBInstanceIdentifier
|
|
445
|
+
};
|
|
446
|
+
if (options.ForceFailover !== undefined) {
|
|
447
|
+
params.ForceFailover = options.ForceFailover;
|
|
448
|
+
}
|
|
449
|
+
const queryString = new URLSearchParams(buildQueryParams(params)).toString();
|
|
450
|
+
const result = await this.client.request({
|
|
451
|
+
service: "rds",
|
|
452
|
+
region: this.region,
|
|
453
|
+
method: "POST",
|
|
454
|
+
path: "/",
|
|
455
|
+
headers: {
|
|
456
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
457
|
+
},
|
|
458
|
+
body: queryString
|
|
459
|
+
});
|
|
460
|
+
const response = result.RebootDBInstanceResult || result;
|
|
461
|
+
return {
|
|
462
|
+
DBInstance: response.DBInstance
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
async createDBSnapshot(options) {
|
|
466
|
+
const params = {
|
|
467
|
+
Action: "CreateDBSnapshot",
|
|
468
|
+
Version: "2014-10-31",
|
|
469
|
+
DBInstanceIdentifier: options.DBInstanceIdentifier,
|
|
470
|
+
DBSnapshotIdentifier: options.DBSnapshotIdentifier
|
|
471
|
+
};
|
|
472
|
+
if (options.Tags) {
|
|
473
|
+
options.Tags.forEach((tag, i) => {
|
|
474
|
+
params[`Tags.Tag.${i + 1}.Key`] = tag.Key;
|
|
475
|
+
params[`Tags.Tag.${i + 1}.Value`] = tag.Value;
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
const queryString = new URLSearchParams(buildQueryParams(params)).toString();
|
|
479
|
+
const result = await this.client.request({
|
|
480
|
+
service: "rds",
|
|
481
|
+
region: this.region,
|
|
482
|
+
method: "POST",
|
|
483
|
+
path: "/",
|
|
484
|
+
headers: {
|
|
485
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
486
|
+
},
|
|
487
|
+
body: queryString
|
|
488
|
+
});
|
|
489
|
+
const response = result.CreateDBSnapshotResult || result;
|
|
490
|
+
return {
|
|
491
|
+
DBSnapshot: response.DBSnapshot
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
async deleteDBSnapshot(dbSnapshotIdentifier) {
|
|
495
|
+
const params = {
|
|
496
|
+
Action: "DeleteDBSnapshot",
|
|
497
|
+
Version: "2014-10-31",
|
|
498
|
+
DBSnapshotIdentifier: dbSnapshotIdentifier
|
|
499
|
+
};
|
|
500
|
+
const queryString = new URLSearchParams(buildQueryParams(params)).toString();
|
|
501
|
+
const result = await this.client.request({
|
|
502
|
+
service: "rds",
|
|
503
|
+
region: this.region,
|
|
504
|
+
method: "POST",
|
|
505
|
+
path: "/",
|
|
506
|
+
headers: {
|
|
507
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
508
|
+
},
|
|
509
|
+
body: queryString
|
|
510
|
+
});
|
|
511
|
+
const response = result.DeleteDBSnapshotResult || result;
|
|
512
|
+
return {
|
|
513
|
+
DBSnapshot: response.DBSnapshot
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
async restoreDBInstanceFromDBSnapshot(options) {
|
|
517
|
+
const params = {
|
|
518
|
+
Action: "RestoreDBInstanceFromDBSnapshot",
|
|
519
|
+
Version: "2014-10-31",
|
|
520
|
+
DBInstanceIdentifier: options.DBInstanceIdentifier,
|
|
521
|
+
DBSnapshotIdentifier: options.DBSnapshotIdentifier
|
|
522
|
+
};
|
|
523
|
+
if (options.DBInstanceClass)
|
|
524
|
+
params.DBInstanceClass = options.DBInstanceClass;
|
|
525
|
+
if (options.Port)
|
|
526
|
+
params.Port = options.Port;
|
|
527
|
+
if (options.AvailabilityZone)
|
|
528
|
+
params.AvailabilityZone = options.AvailabilityZone;
|
|
529
|
+
if (options.DBSubnetGroupName)
|
|
530
|
+
params.DBSubnetGroupName = options.DBSubnetGroupName;
|
|
531
|
+
if (options.MultiAZ !== undefined)
|
|
532
|
+
params.MultiAZ = options.MultiAZ;
|
|
533
|
+
if (options.PubliclyAccessible !== undefined)
|
|
534
|
+
params.PubliclyAccessible = options.PubliclyAccessible;
|
|
535
|
+
if (options.AutoMinorVersionUpgrade !== undefined)
|
|
536
|
+
params.AutoMinorVersionUpgrade = options.AutoMinorVersionUpgrade;
|
|
537
|
+
if (options.StorageType)
|
|
538
|
+
params.StorageType = options.StorageType;
|
|
539
|
+
if (options.DeletionProtection !== undefined)
|
|
540
|
+
params.DeletionProtection = options.DeletionProtection;
|
|
541
|
+
if (options.VpcSecurityGroupIds) {
|
|
542
|
+
options.VpcSecurityGroupIds.forEach((id, i) => {
|
|
543
|
+
params[`VpcSecurityGroupIds.VpcSecurityGroupId.${i + 1}`] = id;
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
if (options.Tags) {
|
|
547
|
+
options.Tags.forEach((tag, i) => {
|
|
548
|
+
params[`Tags.Tag.${i + 1}.Key`] = tag.Key;
|
|
549
|
+
params[`Tags.Tag.${i + 1}.Value`] = tag.Value;
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
const queryString = new URLSearchParams(buildQueryParams(params)).toString();
|
|
553
|
+
const result = await this.client.request({
|
|
554
|
+
service: "rds",
|
|
555
|
+
region: this.region,
|
|
556
|
+
method: "POST",
|
|
557
|
+
path: "/",
|
|
558
|
+
headers: {
|
|
559
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
560
|
+
},
|
|
561
|
+
body: queryString
|
|
562
|
+
});
|
|
563
|
+
const response = result.RestoreDBInstanceFromDBSnapshotResult || result;
|
|
564
|
+
return {
|
|
565
|
+
DBInstance: response.DBInstance
|
|
566
|
+
};
|
|
567
|
+
}
|
|
568
|
+
async waitForDBInstanceAvailable(dbInstanceIdentifier, maxAttempts = 60, delayMs = 30000) {
|
|
569
|
+
for (let i = 0;i < maxAttempts; i++) {
|
|
570
|
+
const instance = await this.describeDBInstance(dbInstanceIdentifier);
|
|
571
|
+
if (instance?.DBInstanceStatus === "available") {
|
|
572
|
+
return instance;
|
|
573
|
+
}
|
|
574
|
+
if (["deleted", "failed", "incompatible-restore", "incompatible-parameters"].includes(instance?.DBInstanceStatus || "")) {
|
|
575
|
+
throw new Error(`DB instance ${dbInstanceIdentifier} is in terminal state: ${instance?.DBInstanceStatus}`);
|
|
576
|
+
}
|
|
577
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
578
|
+
}
|
|
579
|
+
throw new Error(`Timeout waiting for DB instance ${dbInstanceIdentifier} to become available`);
|
|
580
|
+
}
|
|
581
|
+
async waitForDBInstanceDeleted(dbInstanceIdentifier, maxAttempts = 60, delayMs = 30000) {
|
|
582
|
+
for (let i = 0;i < maxAttempts; i++) {
|
|
583
|
+
try {
|
|
584
|
+
const instance = await this.describeDBInstance(dbInstanceIdentifier);
|
|
585
|
+
if (instance?.DBInstanceStatus === "deleting") {
|
|
586
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
587
|
+
continue;
|
|
588
|
+
}
|
|
589
|
+
throw new Error(`DB instance ${dbInstanceIdentifier} is in state: ${instance?.DBInstanceStatus}`);
|
|
590
|
+
} catch (error) {
|
|
591
|
+
if (error.code === "DBInstanceNotFound" || error.code === "DBInstanceNotFoundFault") {
|
|
592
|
+
return;
|
|
593
|
+
}
|
|
594
|
+
throw error;
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
throw new Error(`Timeout waiting for DB instance ${dbInstanceIdentifier} to be deleted`);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
export { RDSClient };
|