@fishawack/lab-env 5.7.0-beta.1 → 5.7.0-beta.3
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/CHANGELOG.md +58 -0
- package/_Test/provision.js +4 -9
- package/_Test/prune.js +8 -5
- package/bitbucket-pipelines.yml +2 -2
- package/cli.js +1 -0
- package/commands/create/cmds/dekey.js +13 -9
- package/commands/create/cmds/deprovision.js +36 -0
- package/commands/create/cmds/key.js +60 -41
- package/commands/create/cmds/provision.js +573 -69
- package/commands/create/cmds/rekey.js +218 -0
- package/commands/create/cmds/sync-secrets.js +2 -1
- package/commands/create/libs/output-credentials.js +59 -0
- package/commands/create/libs/parallel-runner.js +204 -0
- package/commands/create/libs/resolve-operator.js +59 -0
- package/commands/create/libs/utilities.js +73 -8
- package/commands/create/libs/vars.js +120 -136
- package/commands/create/services/aws/acm.js +61 -0
- package/commands/create/services/aws/cloudfront.js +51 -45
- package/commands/create/services/aws/ec2.js +675 -48
- package/commands/create/services/aws/elasticache.js +159 -0
- package/commands/create/services/aws/elasticbeanstalk.js +154 -57
- package/commands/create/services/aws/iam.js +402 -82
- package/commands/create/services/aws/index.js +1398 -260
- package/commands/create/services/aws/opensearch.js +155 -0
- package/commands/create/services/aws/rds.js +57 -31
- package/commands/create/services/aws/s3.js +52 -31
- package/commands/create/services/aws/secretsmanager.js +21 -12
- package/commands/create/services/aws/ses.js +195 -0
- package/commands/create/templates/elasticbeanstalk/.ebextensions/laravel/cron.config +45 -0
- package/commands/create/templates/elasticbeanstalk/.ebextensions/laravel/queue-worker.config +29 -0
- package/commands/create/templates/elasticbeanstalk/.ebextensions/laravel/software.config +12 -0
- package/commands/create/templates/elasticbeanstalk/.ebextensions/misc/setvars.config +2 -16
- package/commands/create/templates/elasticbeanstalk/.platform/confighooks/postdeploy/rewrite-flush.sh +1 -1
- package/commands/create/templates/elasticbeanstalk/.platform/confighooks/postdeploy/setvars.sh +19 -0
- package/commands/create/templates/elasticbeanstalk/.platform/hooks/postdeploy/restart_queue.sh +4 -0
- package/commands/create/templates/elasticbeanstalk/.platform/hooks/prebuild/setvars.sh +19 -0
- package/package.json +7 -2
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const dns = require("dns").promises;
|
|
1
2
|
const {
|
|
2
3
|
CloudFrontClient,
|
|
3
4
|
CreateDistributionWithTagsCommand,
|
|
@@ -20,7 +21,9 @@ const {
|
|
|
20
21
|
const fs = require("fs");
|
|
21
22
|
const { merge } = require("lodash");
|
|
22
23
|
const { Spinner, poll } = require("../../libs/utilities");
|
|
23
|
-
const { cloudfront } = require("../../libs/vars");
|
|
24
|
+
const { cloudfront, awsClientConfig } = require("../../libs/vars");
|
|
25
|
+
|
|
26
|
+
const getClient = () => new CloudFrontClient(awsClientConfig);
|
|
24
27
|
|
|
25
28
|
module.exports.createCloudFrontDistribution = async (
|
|
26
29
|
name,
|
|
@@ -29,10 +32,8 @@ module.exports.createCloudFrontDistribution = async (
|
|
|
29
32
|
FunctionARNResponse = null,
|
|
30
33
|
region = "us-east-1",
|
|
31
34
|
) => {
|
|
32
|
-
const client = new CloudFrontClient({});
|
|
33
|
-
|
|
34
35
|
let OAI = await Spinner.prototype.simple(`Creating CloudFront OAI`, () => {
|
|
35
|
-
return
|
|
36
|
+
return getClient().send(
|
|
36
37
|
new CreateCloudFrontOriginAccessIdentityCommand({
|
|
37
38
|
CloudFrontOriginAccessIdentityConfig: {
|
|
38
39
|
CallerReference: name,
|
|
@@ -48,7 +49,7 @@ module.exports.createCloudFrontDistribution = async (
|
|
|
48
49
|
res = await Spinner.prototype.simple(
|
|
49
50
|
`Creating CloudFront distribution with CloudFront OAI and tags`,
|
|
50
51
|
() => {
|
|
51
|
-
return
|
|
52
|
+
return getClient().send(
|
|
52
53
|
new CreateDistributionWithTagsCommand({
|
|
53
54
|
DistributionConfigWithTags: {
|
|
54
55
|
...cloudfront(
|
|
@@ -80,20 +81,29 @@ module.exports.createCloudFrontDistribution = async (
|
|
|
80
81
|
);
|
|
81
82
|
},
|
|
82
83
|
);
|
|
84
|
+
|
|
85
|
+
await Spinner.prototype.simple(
|
|
86
|
+
`Waiting for CloudFront DNS to propagate`,
|
|
87
|
+
() => {
|
|
88
|
+
return module.exports.waitForCloudFrontDNS(
|
|
89
|
+
res.Distribution.DomainName,
|
|
90
|
+
);
|
|
91
|
+
},
|
|
92
|
+
);
|
|
83
93
|
} catch (e) {
|
|
84
94
|
let Id = e.message.split(" ")[e.message.split(" ").length - 1];
|
|
85
95
|
|
|
86
96
|
res = await Spinner.prototype.simple(
|
|
87
97
|
`Retrieving the already existing CloudFront distribution`,
|
|
88
98
|
() => {
|
|
89
|
-
return
|
|
99
|
+
return getClient().send(new GetDistributionCommand({ Id }));
|
|
90
100
|
},
|
|
91
101
|
);
|
|
92
102
|
|
|
93
103
|
res = await Spinner.prototype.simple(
|
|
94
104
|
`Ensuring CloudFront functions are applied to CloudFront distribution`,
|
|
95
105
|
() => {
|
|
96
|
-
return
|
|
106
|
+
return getClient().send(
|
|
97
107
|
new UpdateDistributionCommand({
|
|
98
108
|
...merge(
|
|
99
109
|
res.Distribution,
|
|
@@ -116,12 +126,10 @@ module.exports.createCloudFrontDistribution = async (
|
|
|
116
126
|
};
|
|
117
127
|
|
|
118
128
|
module.exports.removeCloudFrontDistribution = async (Id) => {
|
|
119
|
-
const client = new CloudFrontClient({});
|
|
120
|
-
|
|
121
129
|
let res = await Spinner.prototype.simple(
|
|
122
130
|
`Retrieving the CloudFront distribution ${Id}`,
|
|
123
131
|
() => {
|
|
124
|
-
return
|
|
132
|
+
return getClient().send(new GetDistributionCommand({ Id }));
|
|
125
133
|
},
|
|
126
134
|
);
|
|
127
135
|
|
|
@@ -135,7 +143,7 @@ module.exports.removeCloudFrontDistribution = async (Id) => {
|
|
|
135
143
|
res = await Spinner.prototype.simple(
|
|
136
144
|
`Disabling the CloudFront distribution`,
|
|
137
145
|
() => {
|
|
138
|
-
return
|
|
146
|
+
return getClient().send(
|
|
139
147
|
new UpdateDistributionCommand({
|
|
140
148
|
DistributionConfig: res.Distribution.DistributionConfig,
|
|
141
149
|
Id,
|
|
@@ -157,7 +165,7 @@ module.exports.removeCloudFrontDistribution = async (Id) => {
|
|
|
157
165
|
res = await Spinner.prototype.simple(
|
|
158
166
|
`Deleting the CloudFront distribution`,
|
|
159
167
|
() => {
|
|
160
|
-
return
|
|
168
|
+
return getClient().send(
|
|
161
169
|
new DeleteDistributionCommand({ Id, IfMatch: res.ETag }),
|
|
162
170
|
);
|
|
163
171
|
},
|
|
@@ -166,14 +174,14 @@ module.exports.removeCloudFrontDistribution = async (Id) => {
|
|
|
166
174
|
res = await Spinner.prototype.simple(
|
|
167
175
|
`Retrieving the CloudFront OAI`,
|
|
168
176
|
() => {
|
|
169
|
-
return
|
|
177
|
+
return getClient().send(
|
|
170
178
|
new GetCloudFrontOriginAccessIdentityCommand({ Id: OAI }),
|
|
171
179
|
);
|
|
172
180
|
},
|
|
173
181
|
);
|
|
174
182
|
|
|
175
183
|
res = await Spinner.prototype.simple(`Deleting the CloudFront OAI`, () => {
|
|
176
|
-
return
|
|
184
|
+
return getClient().send(
|
|
177
185
|
new DeleteCloudFrontOriginAccessIdentityCommand({
|
|
178
186
|
Id: OAI,
|
|
179
187
|
IfMatch: res.ETag,
|
|
@@ -183,17 +191,27 @@ module.exports.removeCloudFrontDistribution = async (Id) => {
|
|
|
183
191
|
};
|
|
184
192
|
|
|
185
193
|
module.exports.waitForCloudFrontDistribution = async (Id) => {
|
|
186
|
-
const client = new CloudFrontClient({});
|
|
187
|
-
|
|
188
194
|
await poll(
|
|
189
|
-
async () => await
|
|
195
|
+
async () => await getClient().send(new GetDistributionCommand({ Id })),
|
|
190
196
|
(res) => res.Distribution.Status !== "Deployed",
|
|
191
197
|
);
|
|
192
198
|
};
|
|
193
199
|
|
|
194
|
-
module.exports.
|
|
195
|
-
|
|
200
|
+
module.exports.waitForCloudFrontDNS = async (domain) => {
|
|
201
|
+
await poll(
|
|
202
|
+
async () => {
|
|
203
|
+
try {
|
|
204
|
+
await dns.resolve(domain);
|
|
205
|
+
return true;
|
|
206
|
+
} catch {
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
(resolved) => !resolved,
|
|
211
|
+
);
|
|
212
|
+
};
|
|
196
213
|
|
|
214
|
+
module.exports.createCloudFrontFunction = async (name, fn, config) => {
|
|
197
215
|
let FunctionConfig = {
|
|
198
216
|
Comment: `${name} - ${fn}.js`,
|
|
199
217
|
Runtime: `cloudfront-js-1.0`,
|
|
@@ -205,7 +223,7 @@ module.exports.createCloudFrontFunction = async (name, fn, config) => {
|
|
|
205
223
|
res = await Spinner.prototype.simple(
|
|
206
224
|
`Creating CloudFront function`,
|
|
207
225
|
() => {
|
|
208
|
-
return
|
|
226
|
+
return getClient().send(
|
|
209
227
|
new CreateFunctionCommand({
|
|
210
228
|
Name: name,
|
|
211
229
|
FunctionCode: new TextEncoder().encode(" "),
|
|
@@ -218,7 +236,7 @@ module.exports.createCloudFrontFunction = async (name, fn, config) => {
|
|
|
218
236
|
res = await Spinner.prototype.simple(
|
|
219
237
|
`Retrieving the already existing CloudFront function`,
|
|
220
238
|
() => {
|
|
221
|
-
return
|
|
239
|
+
return getClient().send(
|
|
222
240
|
new GetFunctionCommand({
|
|
223
241
|
Name: name,
|
|
224
242
|
}),
|
|
@@ -237,7 +255,7 @@ module.exports.createCloudFrontFunction = async (name, fn, config) => {
|
|
|
237
255
|
res = await Spinner.prototype.simple(
|
|
238
256
|
`Updating CloudFront function with ${fn}.js code`,
|
|
239
257
|
() => {
|
|
240
|
-
return
|
|
258
|
+
return getClient().send(
|
|
241
259
|
new UpdateFunctionCommand({
|
|
242
260
|
Name: name,
|
|
243
261
|
FunctionCode: new TextEncoder().encode(processedFn),
|
|
@@ -251,7 +269,7 @@ module.exports.createCloudFrontFunction = async (name, fn, config) => {
|
|
|
251
269
|
res = await Spinner.prototype.simple(
|
|
252
270
|
`Publishing CloudFront function`,
|
|
253
271
|
() => {
|
|
254
|
-
return
|
|
272
|
+
return getClient().send(
|
|
255
273
|
new PublishFunctionCommand({
|
|
256
274
|
Name: name,
|
|
257
275
|
IfMatch: res.ETag,
|
|
@@ -264,12 +282,10 @@ module.exports.createCloudFrontFunction = async (name, fn, config) => {
|
|
|
264
282
|
};
|
|
265
283
|
|
|
266
284
|
module.exports.removeCloudFrontFunction = async (name) => {
|
|
267
|
-
const client = new CloudFrontClient({});
|
|
268
|
-
|
|
269
285
|
let res = await Spinner.prototype.simple(
|
|
270
286
|
`Retrieving CloudFront function`,
|
|
271
287
|
() => {
|
|
272
|
-
return
|
|
288
|
+
return getClient().send(
|
|
273
289
|
new GetFunctionCommand({
|
|
274
290
|
Name: name,
|
|
275
291
|
}),
|
|
@@ -278,7 +294,7 @@ module.exports.removeCloudFrontFunction = async (name) => {
|
|
|
278
294
|
);
|
|
279
295
|
|
|
280
296
|
res = await Spinner.prototype.simple(`Deleting CloudFront function`, () => {
|
|
281
|
-
return
|
|
297
|
+
return getClient().send(
|
|
282
298
|
new DeleteFunctionCommand({
|
|
283
299
|
Name: name,
|
|
284
300
|
IfMatch: res.ETag,
|
|
@@ -290,12 +306,10 @@ module.exports.removeCloudFrontFunction = async (name) => {
|
|
|
290
306
|
};
|
|
291
307
|
|
|
292
308
|
module.exports.setCloudFrontFunctionAssociation = async (Id) => {
|
|
293
|
-
const client = new CloudFrontClient({});
|
|
294
|
-
|
|
295
309
|
let res = await Spinner.prototype.simple(
|
|
296
310
|
`Retrieving CloudFront distribution`,
|
|
297
311
|
() => {
|
|
298
|
-
return
|
|
312
|
+
return getClient().send(new GetDistributionCommand({ Id }));
|
|
299
313
|
},
|
|
300
314
|
);
|
|
301
315
|
|
|
@@ -304,7 +318,7 @@ module.exports.setCloudFrontFunctionAssociation = async (Id) => {
|
|
|
304
318
|
FunctionMetadata: { FunctionARN },
|
|
305
319
|
},
|
|
306
320
|
} = await Spinner.prototype.simple(`Retrieving CloudFront function`, () => {
|
|
307
|
-
return
|
|
321
|
+
return getClient().send(
|
|
308
322
|
new DescribeFunctionCommand({
|
|
309
323
|
Name: res.Distribution.DistributionConfig.CallerReference,
|
|
310
324
|
Stage: "LIVE",
|
|
@@ -326,7 +340,7 @@ module.exports.setCloudFrontFunctionAssociation = async (Id) => {
|
|
|
326
340
|
res = await Spinner.prototype.simple(
|
|
327
341
|
`Adding CloudFront function to CloudFront distribution`,
|
|
328
342
|
() => {
|
|
329
|
-
return
|
|
343
|
+
return getClient().send(
|
|
330
344
|
new UpdateDistributionCommand({
|
|
331
345
|
DistributionConfig: res.Distribution.DistributionConfig,
|
|
332
346
|
Id,
|
|
@@ -347,12 +361,10 @@ module.exports.setCloudFrontFunctionAssociation = async (Id) => {
|
|
|
347
361
|
};
|
|
348
362
|
|
|
349
363
|
module.exports.removeCloudFrontFunctionAssociation = async (Id) => {
|
|
350
|
-
const client = new CloudFrontClient({});
|
|
351
|
-
|
|
352
364
|
let res = await Spinner.prototype.simple(
|
|
353
365
|
`Retrieving CloudFront distribution`,
|
|
354
366
|
() => {
|
|
355
|
-
return
|
|
367
|
+
return getClient().send(new GetDistributionCommand({ Id }));
|
|
356
368
|
},
|
|
357
369
|
);
|
|
358
370
|
|
|
@@ -365,7 +377,7 @@ module.exports.removeCloudFrontFunctionAssociation = async (Id) => {
|
|
|
365
377
|
res = await Spinner.prototype.simple(
|
|
366
378
|
`Removing CloudFront function from CloudFront distribution`,
|
|
367
379
|
() => {
|
|
368
|
-
return
|
|
380
|
+
return getClient().send(
|
|
369
381
|
new UpdateDistributionCommand({
|
|
370
382
|
DistributionConfig: res.Distribution.DistributionConfig,
|
|
371
383
|
Id,
|
|
@@ -386,13 +398,11 @@ module.exports.removeCloudFrontFunctionAssociation = async (Id) => {
|
|
|
386
398
|
};
|
|
387
399
|
|
|
388
400
|
module.exports.listDistributions = async () => {
|
|
389
|
-
const client = new CloudFrontClient({});
|
|
390
|
-
|
|
391
401
|
let distributions = [];
|
|
392
402
|
let marker;
|
|
393
403
|
|
|
394
404
|
do {
|
|
395
|
-
const res = await
|
|
405
|
+
const res = await getClient().send(
|
|
396
406
|
new ListDistributionsCommand({
|
|
397
407
|
...(marker ? { Marker: marker } : {}),
|
|
398
408
|
}),
|
|
@@ -409,9 +419,7 @@ module.exports.listDistributions = async () => {
|
|
|
409
419
|
};
|
|
410
420
|
|
|
411
421
|
module.exports.getDistributionTags = async (arn) => {
|
|
412
|
-
const
|
|
413
|
-
|
|
414
|
-
const res = await client.send(
|
|
422
|
+
const res = await getClient().send(
|
|
415
423
|
new ListTagsForResourceCommand({ Resource: arn }),
|
|
416
424
|
);
|
|
417
425
|
|
|
@@ -419,9 +427,7 @@ module.exports.getDistributionTags = async (arn) => {
|
|
|
419
427
|
};
|
|
420
428
|
|
|
421
429
|
module.exports.getLatestInvalidationDate = async (distributionId) => {
|
|
422
|
-
const
|
|
423
|
-
|
|
424
|
-
const res = await client.send(
|
|
430
|
+
const res = await getClient().send(
|
|
425
431
|
new ListInvalidationsCommand({
|
|
426
432
|
DistributionId: distributionId,
|
|
427
433
|
MaxItems: 1,
|