@fishawack/lab-env 5.9.0-beta.2 → 5.9.0-beta.4

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  ## Changelog
2
2
 
3
+ ### 5.9.0-beta.4 (2026-10-08)
4
+
5
+ #### Bug Fixes
6
+
7
+ * server-status now resolves from config with branch as fallback ([c3a7c75](https://bitbucket.org/fishawackdigital/lab-env/commits/c3a7c75841f36a7a6c0b3eccce202618c40fa599))
8
+
9
+ ### 5.9.0-beta.3 (2026-09-25)
10
+
11
+ #### Features
12
+
13
+ * server-status command ([791b39e](https://bitbucket.org/fishawackdigital/lab-env/commits/791b39e3b1a6e525d6e8a45769f5313702797ca8))
14
+
3
15
  ### 5.9.0-beta.2 (2026-09-10)
4
16
 
5
17
  #### Bug Fixes
package/cli.js CHANGED
@@ -173,6 +173,7 @@ const args = hideBin(process.argv);
173
173
  "rekey",
174
174
  "prune",
175
175
  "sync-secrets",
176
+ "server-status",
176
177
  ].forEach((d) =>
177
178
  cli.command(...require(`./commands/create/cmds/${d}.js`)),
178
179
  );
@@ -0,0 +1,681 @@
1
+ const { execSync } = require("child_process");
2
+ const _ = require("../../../globals.js");
3
+ const inquirer = require("inquirer");
4
+ const aws = require("../services/aws/index.js");
5
+ const { setAWSClientDefaults } = require("../services/aws/misc.js");
6
+ const { colorize, Spinner } = require("../libs/utilities");
7
+ const { client, region } = require("../libs/prompts.js");
8
+ const {
9
+ RDSClient,
10
+ DescribeDBInstancesCommand,
11
+ } = require("@aws-sdk/client-rds");
12
+ const {
13
+ OpenSearchClient,
14
+ DescribeDomainCommand,
15
+ } = require("@aws-sdk/client-opensearch");
16
+ const {
17
+ ElastiCacheClient,
18
+ DescribeReplicationGroupsCommand,
19
+ } = require("@aws-sdk/client-elasticache");
20
+ const { IAMClient } = require("@aws-sdk/client-iam");
21
+ const { fromIni } = require("@aws-sdk/credential-providers");
22
+
23
+ const REGIONS = region.choices;
24
+
25
+ // SES mail credentials always live in the fishawack account, regardless of client (see provisionMail)
26
+ const mailIamClient = new IAMClient({
27
+ region: "us-east-1",
28
+ credentials: fromIni({ profile: "fishawack" }),
29
+ });
30
+
31
+ function listGitBranches() {
32
+ let output;
33
+
34
+ try {
35
+ output = execSync('git branch -a --format="%(refname:short)"', {
36
+ encoding: "utf8",
37
+ });
38
+ } catch {
39
+ return [];
40
+ }
41
+
42
+ const branches = new Set();
43
+
44
+ output
45
+ .split("\n")
46
+ .map((line) => line.trim())
47
+ .filter(Boolean)
48
+ .forEach((line) => {
49
+ // Skip the symbolic remote HEAD pointer, e.g. "origin/HEAD -> origin/main"
50
+ if (line === "origin/HEAD" || line.includes("HEAD ->")) return;
51
+ branches.add(line.replace(/^origin\//, ""));
52
+ });
53
+
54
+ return [...branches].sort();
55
+ }
56
+
57
+ // Deploy targets explicitly configured in config can point at an EB environment that
58
+ // was provisioned under a different (possibly now-deleted) branch name, e.g. after a
59
+ // blue/green swap — these won't be found by recomputing the slug from the branch name alone
60
+ function getDynamicTargets() {
61
+ const targets = _.coreConfig?.attributes?.targets || {};
62
+
63
+ return Object.entries(targets).map(([name, cfg]) => ({
64
+ branch: name,
65
+ awsEb: cfg?.deploy?.["aws-eb"] || null,
66
+ }));
67
+ }
68
+
69
+ async function resolveClients(argv) {
70
+ if (argv.all) return client.choices;
71
+ if (argv.client) return [argv.client];
72
+
73
+ const { check } = await inquirer.prompt([
74
+ {
75
+ type: "confirm",
76
+ name: "check",
77
+ message: "Check status for all clients?",
78
+ default: true,
79
+ },
80
+ ]);
81
+
82
+ if (check) return client.choices;
83
+
84
+ const { selected } = await inquirer.prompt([
85
+ {
86
+ type: "checkbox",
87
+ name: "selected",
88
+ message: "Which clients would you like to check?",
89
+ choices: client.choices,
90
+ validate: (input) =>
91
+ input.length > 0 || "Select at least one client",
92
+ },
93
+ ]);
94
+
95
+ return selected;
96
+ }
97
+
98
+ async function resolveRegions(argv) {
99
+ if (argv.all) return REGIONS;
100
+ if (argv.region) return [argv.region];
101
+
102
+ const { check } = await inquirer.prompt([
103
+ {
104
+ type: "confirm",
105
+ name: "check",
106
+ message: "Check status for all regions?",
107
+ default: true,
108
+ },
109
+ ]);
110
+
111
+ if (check) return REGIONS;
112
+
113
+ const { selected } = await inquirer.prompt([
114
+ {
115
+ type: "checkbox",
116
+ name: "selected",
117
+ message: "Which regions would you like to check?",
118
+ choices: REGIONS,
119
+ validate: (input) =>
120
+ input.length > 0 || "Select at least one region",
121
+ },
122
+ ]);
123
+
124
+ return selected;
125
+ }
126
+
127
+ async function resolveBranches(argv) {
128
+ if (argv.branch) return [{ branch: argv.branch, awsEb: null }];
129
+
130
+ const dynamicTargets = getDynamicTargets();
131
+ const dynamicByBranch = new Map(dynamicTargets.map((t) => [t.branch, t]));
132
+
133
+ if (argv.all) {
134
+ const merged = listGitBranches().map(
135
+ (b) => dynamicByBranch.get(b) || { branch: b, awsEb: null },
136
+ );
137
+ const missing = dynamicTargets.filter(
138
+ (t) => !merged.some((m) => m.branch === t.branch),
139
+ );
140
+ return [...merged, ...missing];
141
+ }
142
+
143
+ if (dynamicTargets.length) {
144
+ const { useTargets } = await inquirer.prompt([
145
+ {
146
+ type: "confirm",
147
+ name: "useTargets",
148
+ message: `Found deploy targets in config (${dynamicTargets.map((t) => t.branch).join(", ")}) — check just these?`,
149
+ default: true,
150
+ },
151
+ ]);
152
+
153
+ if (useTargets) return dynamicTargets;
154
+ }
155
+
156
+ const gitBranches = listGitBranches().filter(
157
+ (b) => !dynamicByBranch.has(b),
158
+ );
159
+
160
+ const choices = [
161
+ ...dynamicTargets.map((t) => ({
162
+ name: `${t.branch} (config target)`,
163
+ value: t.branch,
164
+ checked: true,
165
+ })),
166
+ ...gitBranches.map((b) => ({ name: b, value: b })),
167
+ ];
168
+
169
+ const { selected } = await inquirer.prompt([
170
+ {
171
+ type: "checkbox",
172
+ name: "selected",
173
+ message: "Which branches would you like to check?",
174
+ choices,
175
+ validate: (input) =>
176
+ input.length > 0 || "Select at least one branch",
177
+ },
178
+ ]);
179
+
180
+ return selected.map(
181
+ (b) => dynamicByBranch.get(b) || { branch: b, awsEb: null },
182
+ );
183
+ }
184
+
185
+ // S3/CloudFront are account-wide, not per-region, so fetch once per client and reuse
186
+ async function getS3Buckets(cache, clientName) {
187
+ if (!cache.has(clientName)) {
188
+ const { Buckets } = await aws.s3.listS3Buckets();
189
+ cache.set(clientName, Buckets || []);
190
+ }
191
+
192
+ return cache.get(clientName);
193
+ }
194
+
195
+ async function getDistributions(cache, clientName) {
196
+ if (!cache.has(clientName)) {
197
+ cache.set(clientName, await aws.cloudfront.listDistributions());
198
+ }
199
+
200
+ return cache.get(clientName);
201
+ }
202
+
203
+ function findDistribution(distributions, s3Slug) {
204
+ return distributions.find((d) => {
205
+ const origin = d.Origins?.Items?.[0]?.DomainName || "";
206
+ return origin.split(".s3.")[0] === s3Slug;
207
+ });
208
+ }
209
+
210
+ // EB/RDS/OpenSearch/ElastiCache are the only truly regional checks; S3/CloudFront/IAM/SES
211
+ // are account-wide, so they're only worth fetching once per branch (on the primary region)
212
+ async function checkBranch(
213
+ caches,
214
+ clientName,
215
+ branch,
216
+ isPrimaryRegion,
217
+ awsEbOverride,
218
+ ) {
219
+ const guessedEbSlug = aws.slug(_.repoSafe, clientName, branch, "eb");
220
+
221
+ const result = {};
222
+
223
+ let environment = null;
224
+ let environmentName = guessedEbSlug;
225
+ let resolution = null; // "fw-json" | "branch-fallback" | null
226
+
227
+ // Config state is authoritative when available, so check it before guessing
228
+ if (awsEbOverride) {
229
+ try {
230
+ const { Environments } =
231
+ await aws.elasticbeanstalk.describeEnvironment(awsEbOverride);
232
+ environment =
233
+ (Environments || []).find((e) => e.Status !== "Terminated") ||
234
+ null;
235
+ if (environment) {
236
+ environmentName = awsEbOverride;
237
+ resolution = "fw-json";
238
+ }
239
+ } catch {
240
+ /* config-registered env not found, fall back to computing from the branch name */
241
+ }
242
+ }
243
+
244
+ if (!environment) {
245
+ try {
246
+ const { Environments } =
247
+ await aws.elasticbeanstalk.describeEnvironment(guessedEbSlug);
248
+ environment =
249
+ (Environments || []).find((e) => e.Status !== "Terminated") ||
250
+ null;
251
+ if (environment) {
252
+ environmentName = guessedEbSlug;
253
+ resolution = awsEbOverride ? "branch-fallback" : null;
254
+ }
255
+ } catch {
256
+ /* not found via the computed slug either */
257
+ }
258
+ }
259
+
260
+ result.elasticbeanstalk = environment
261
+ ? {
262
+ found: true,
263
+ name: environmentName,
264
+ status: environment.Status,
265
+ health: environment.Health,
266
+ domain: environment.CNAME,
267
+ }
268
+ : { found: false };
269
+
270
+ // Recover the true provisioning-time branch name from tags so the rest of this
271
+ // family's resources can be located — only meaningful when we trusted config's
272
+ // config state over our own guess. The "branch" tag is relatively new; older
273
+ // environments only carry an "environment" tag whose value was the branch name.
274
+ let effectiveBranch = branch;
275
+
276
+ if (resolution === "fw-json") {
277
+ try {
278
+ const tags = await aws.elasticbeanstalk.getEnvironmentTags(
279
+ environment.EnvironmentArn,
280
+ );
281
+ const branchTag = tags.find((t) => t.Key === "branch");
282
+ const environmentTag = tags.find((t) => t.Key === "environment");
283
+ const recovered = branchTag?.Value || environmentTag?.Value;
284
+ if (recovered) effectiveBranch = recovered;
285
+ } catch {
286
+ /* keep the target name as the branch to derive sibling slugs from */
287
+ }
288
+ }
289
+
290
+ result.resolution = resolution;
291
+ result.resolvedBranch =
292
+ resolution === "fw-json" && effectiveBranch !== branch
293
+ ? effectiveBranch
294
+ : null;
295
+
296
+ const s3Slug = aws.slug(_.repoSafe, clientName, effectiveBranch, "s3");
297
+ const rdsSlug = aws.slug(_.repoSafe, clientName, effectiveBranch, "rds");
298
+ const osSlug = aws.slug(_.repoSafe, clientName, effectiveBranch, "os");
299
+ const cacheSlug = aws.slug(
300
+ _.repoSafe,
301
+ clientName,
302
+ effectiveBranch,
303
+ "cache",
304
+ );
305
+ const responseFnSlug = aws.slug(
306
+ `${_.repoSafe}-response`,
307
+ clientName,
308
+ effectiveBranch,
309
+ );
310
+
311
+ result.slug = s3Slug;
312
+
313
+ if (isPrimaryRegion) {
314
+ const buckets = await getS3Buckets(caches.s3, clientName);
315
+ const bucket = buckets.find((b) => b.Name === s3Slug);
316
+ result.s3 = bucket ? { found: true, name: s3Slug } : { found: false };
317
+ } else {
318
+ result.s3 = { found: false };
319
+ }
320
+
321
+ try {
322
+ const { DBInstances } = await new RDSClient({}).send(
323
+ new DescribeDBInstancesCommand({ DBInstanceIdentifier: rdsSlug }),
324
+ );
325
+ const instance = DBInstances?.[0];
326
+ result.rds =
327
+ instance && instance.DBInstanceStatus !== "deleting"
328
+ ? {
329
+ found: true,
330
+ name: rdsSlug,
331
+ status: instance.DBInstanceStatus,
332
+ endpoint: instance.Endpoint?.Address,
333
+ }
334
+ : { found: false };
335
+ } catch {
336
+ result.rds = { found: false };
337
+ }
338
+
339
+ try {
340
+ const { DomainStatus } = await new OpenSearchClient({}).send(
341
+ new DescribeDomainCommand({ DomainName: osSlug }),
342
+ );
343
+ result.opensearch =
344
+ DomainStatus && !DomainStatus.Deleted
345
+ ? {
346
+ found: true,
347
+ name: osSlug,
348
+ status: DomainStatus.Processing
349
+ ? "processing"
350
+ : "available",
351
+ endpoint:
352
+ DomainStatus.Endpoint || DomainStatus.Endpoints?.vpc,
353
+ }
354
+ : { found: false };
355
+ } catch {
356
+ result.opensearch = { found: false };
357
+ }
358
+
359
+ try {
360
+ const { ReplicationGroups } = await new ElastiCacheClient({}).send(
361
+ new DescribeReplicationGroupsCommand({
362
+ ReplicationGroupId: cacheSlug,
363
+ }),
364
+ );
365
+ const group = ReplicationGroups?.[0];
366
+ result.elasticache =
367
+ group && group.Status !== "deleting"
368
+ ? {
369
+ found: true,
370
+ name: cacheSlug,
371
+ status: group.Status,
372
+ endpoint: group.NodeGroups?.[0]?.PrimaryEndpoint?.Address,
373
+ }
374
+ : { found: false };
375
+ } catch {
376
+ result.elasticache = { found: false };
377
+ }
378
+
379
+ if (isPrimaryRegion) {
380
+ const distributions = await getDistributions(
381
+ caches.cloudfront,
382
+ clientName,
383
+ );
384
+ const distribution = findDistribution(distributions, s3Slug);
385
+ result.cloudfront = distribution
386
+ ? {
387
+ found: true,
388
+ name: distribution.Id,
389
+ status: distribution.Status,
390
+ domain: distribution.DomainName,
391
+ }
392
+ : { found: false };
393
+
394
+ const [requestFn, responseFn] = await Promise.all([
395
+ aws.cloudfront.getCloudFrontFunction(s3Slug),
396
+ aws.cloudfront.getCloudFrontFunction(responseFnSlug),
397
+ ]);
398
+
399
+ result.cloudfrontFunctions = {
400
+ request: requestFn
401
+ ? { found: true, name: s3Slug }
402
+ : { found: false },
403
+ response: responseFn
404
+ ? { found: true, name: responseFnSlug }
405
+ : { found: false },
406
+ };
407
+
408
+ if (distribution) {
409
+ const oaiPath =
410
+ distribution.Origins?.Items?.[0]?.S3OriginConfig
411
+ ?.OriginAccessIdentity || "";
412
+ const oaiId = oaiPath.split(
413
+ "origin-access-identity/cloudfront/",
414
+ )[1];
415
+ const oai = oaiId
416
+ ? await aws.cloudfront.getCloudFrontOriginAccessIdentity(oaiId)
417
+ : null;
418
+ result.cloudfrontIdentity = oai
419
+ ? { found: true, name: oaiId }
420
+ : { found: false };
421
+ } else {
422
+ result.cloudfrontIdentity = { found: false };
423
+ }
424
+
425
+ // Non-Laravel fullstack apps get a dedicated storage IAM user (same name as the bucket)
426
+ const storageUser = await aws.iam.getIAMUser(s3Slug);
427
+ result.iamStorageUser = storageUser
428
+ ? { found: true, name: s3Slug }
429
+ : { found: false };
430
+
431
+ // Laravel fullstack apps instead grant service access via a per-environment IAM role/instance profile
432
+ const roleName = `${environmentName}-role`;
433
+ const instanceRole = await aws.iam.getIAMRole(roleName);
434
+ result.iamInstanceRole = instanceRole
435
+ ? { found: true, name: roleName }
436
+ : { found: false };
437
+
438
+ const sesUserName = `${environmentName}-ses`;
439
+ const mailUser = await aws.iam.getIAMUser(sesUserName, mailIamClient);
440
+ result.sesMail = mailUser
441
+ ? { found: true, name: sesUserName }
442
+ : { found: false };
443
+ } else {
444
+ result.cloudfront = { found: false };
445
+ result.cloudfrontFunctions = {
446
+ request: { found: false },
447
+ response: { found: false },
448
+ };
449
+ result.cloudfrontIdentity = { found: false };
450
+ result.iamStorageUser = { found: false };
451
+ result.iamInstanceRole = { found: false };
452
+ result.sesMail = { found: false };
453
+ }
454
+
455
+ return result;
456
+ }
457
+
458
+ function printServiceLine(label, entry, indent = " ") {
459
+ if (!entry || !entry.found) {
460
+ console.log(`${indent}${colorize("✕", "error")} ${label}`);
461
+ return;
462
+ }
463
+
464
+ const details = [entry.status, entry.name].filter(Boolean).join(" · ");
465
+
466
+ console.log(
467
+ `${indent}${colorize("✓", "success")} ${label}${details ? ` ${colorize(`(${details})`, "info")}` : ""}`,
468
+ );
469
+ }
470
+
471
+ function buildGroups(result, isPrimaryRegion) {
472
+ // ElasticBeanstalk/IAM storage user/IAM instance role/SES are exclusively fullstack
473
+ // signals, so use them to decide which group the shared S3 slug belongs to
474
+ const isFullstack =
475
+ result.elasticbeanstalk.found ||
476
+ result.iamStorageUser.found ||
477
+ result.iamInstanceRole.found ||
478
+ result.sesMail.found;
479
+
480
+ // Non-regional (S3/CloudFront/IAM/SES) checks only apply once per branch, not per region
481
+ const staticEntries = isPrimaryRegion
482
+ ? [
483
+ ["S3", isFullstack ? null : result.s3],
484
+ ["CloudFront", result.cloudfront],
485
+ [
486
+ "CloudFront Function (request)",
487
+ result.cloudfrontFunctions.request,
488
+ ],
489
+ [
490
+ "CloudFront Function (response)",
491
+ result.cloudfrontFunctions.response,
492
+ ],
493
+ ["CloudFront Identity (OAI)", result.cloudfrontIdentity],
494
+ ].filter(([, entry]) => entry !== null)
495
+ : [];
496
+
497
+ const fullstackEntries = [
498
+ ["ElasticBeanstalk", result.elasticbeanstalk],
499
+ ["RDS", result.rds],
500
+ ["OpenSearch", result.opensearch],
501
+ ["ElastiCache (Valkey)", result.elasticache],
502
+ ...(isPrimaryRegion
503
+ ? [
504
+ ["S3 (storage)", isFullstack ? result.s3 : null],
505
+ // Legacy pattern being phased out — only worth showing when actually present
506
+ [
507
+ "IAM Storage User (legacy)",
508
+ result.iamStorageUser.found
509
+ ? result.iamStorageUser
510
+ : null,
511
+ ],
512
+ ["IAM Instance Role", result.iamInstanceRole],
513
+ ["SES Mail Credentials", result.sesMail],
514
+ ]
515
+ : []),
516
+ ].filter(([, entry]) => entry !== null);
517
+
518
+ return {
519
+ staticEntries,
520
+ fullstackEntries,
521
+ staticFound: staticEntries.some(([, entry]) => entry.found),
522
+ fullstackFound: fullstackEntries.some(([, entry]) => entry.found),
523
+ };
524
+ }
525
+
526
+ function printStatusReport(results) {
527
+ const empty = [];
528
+ const withResources = [];
529
+
530
+ for (const entry of results) {
531
+ const groups = buildGroups(entry.result, entry.isPrimaryRegion);
532
+
533
+ if (groups.staticFound || groups.fullstackFound) {
534
+ withResources.push({ ...entry, groups });
535
+ } else {
536
+ empty.push(entry);
537
+ }
538
+ }
539
+
540
+ if (empty.length) {
541
+ console.log(` ${colorize("No resources found", "title")}\n`);
542
+
543
+ empty.forEach(({ client: clientName, region: regionName, branch }) => {
544
+ console.log(
545
+ ` ${colorize("✕", "error")} ${clientName} / ${regionName} / ${branch}`,
546
+ );
547
+ });
548
+
549
+ console.log("");
550
+ }
551
+
552
+ for (const {
553
+ client: clientName,
554
+ region: regionName,
555
+ branch,
556
+ result,
557
+ groups: {
558
+ staticEntries,
559
+ fullstackEntries,
560
+ staticFound,
561
+ fullstackFound,
562
+ },
563
+ } of withResources) {
564
+ console.log(
565
+ ` ${colorize(`${clientName} / ${regionName} / ${branch}`, "divider")}`,
566
+ );
567
+ console.log(` ${colorize(result.slug, "info")}`);
568
+
569
+ if (result.resolution === "fw-json") {
570
+ const detail = result.resolvedBranch
571
+ ? ` (originally provisioned as "${result.resolvedBranch}")`
572
+ : "";
573
+ console.log(
574
+ ` ${colorize(`resolved via config${detail}`, "warning")}`,
575
+ );
576
+ } else if (result.resolution === "branch-fallback") {
577
+ console.log(
578
+ ` ${colorize("config target not found on AWS — resolved from branch name instead", "warning")}`,
579
+ );
580
+ }
581
+
582
+ console.log("");
583
+
584
+ if (fullstackFound) {
585
+ fullstackEntries.forEach(([label, entry]) =>
586
+ printServiceLine(label, entry),
587
+ );
588
+ }
589
+
590
+ if (fullstackFound && staticFound) {
591
+ console.log("");
592
+ }
593
+
594
+ if (staticFound) {
595
+ staticEntries.forEach(([label, entry]) =>
596
+ printServiceLine(label, entry),
597
+ );
598
+ }
599
+
600
+ console.log("");
601
+ }
602
+ }
603
+
604
+ module.exports = [
605
+ "server-status",
606
+ _.config.preset === "devops"
607
+ ? "Report AWS resource status for a branch across services"
608
+ : false,
609
+ (yargs) => {
610
+ yargs.option("all", {
611
+ alias: "a",
612
+ describe:
613
+ "Check all clients, regions and branches (inferred from git branch -a)",
614
+ type: "boolean",
615
+ default: false,
616
+ });
617
+ yargs.option("branch", {
618
+ alias: "b",
619
+ describe: "Branch to check",
620
+ type: "string",
621
+ });
622
+ yargs.option("client", {
623
+ alias: "c",
624
+ describe: "AWS account to use",
625
+ type: "string",
626
+ });
627
+ yargs.option("region", {
628
+ alias: "r",
629
+ describe: "AWS region to use",
630
+ type: "string",
631
+ });
632
+ },
633
+ async (argv) => {
634
+ const clients = await resolveClients(argv);
635
+ const regions = await resolveRegions(argv);
636
+ const branches = await resolveBranches(argv);
637
+
638
+ if (!branches.length) {
639
+ console.log(
640
+ `\n ${colorize("No branches to check.", "warning")}\n`,
641
+ );
642
+ return;
643
+ }
644
+
645
+ // Cached per-client since S3/CloudFront are account-wide, not per-region
646
+ const caches = { s3: new Map(), cloudfront: new Map() };
647
+ const results = [];
648
+ const [primaryRegion] = regions;
649
+
650
+ for (const c of clients) {
651
+ for (const r of regions) {
652
+ setAWSClientDefaults(c, r);
653
+
654
+ const isPrimaryRegion = r === primaryRegion;
655
+ const spinner = new Spinner(`Checking ${c} / ${r}`, true);
656
+
657
+ for (const target of branches) {
658
+ spinner.ora.text = `Checking ${c} / ${r} - ${target.branch}`;
659
+ const result = await checkBranch(
660
+ caches,
661
+ c,
662
+ target.branch,
663
+ isPrimaryRegion,
664
+ target.awsEb,
665
+ );
666
+ results.push({
667
+ client: c,
668
+ region: r,
669
+ branch: target.branch,
670
+ result,
671
+ isPrimaryRegion,
672
+ });
673
+ }
674
+
675
+ spinner.ora.stop();
676
+ }
677
+ }
678
+
679
+ printStatusReport(results);
680
+ },
681
+ ];
@@ -440,3 +440,23 @@ module.exports.getLatestInvalidationDate = async (distributionId) => {
440
440
 
441
441
  return items[0].CreateTime;
442
442
  };
443
+
444
+ // Read-only lookup, unlike removeCloudFrontFunction this never deletes
445
+ module.exports.getCloudFrontFunction = async (name) => {
446
+ try {
447
+ return await getClient().send(new GetFunctionCommand({ Name: name }));
448
+ } catch {
449
+ return null;
450
+ }
451
+ };
452
+
453
+ // Read-only lookup, unlike removeCloudFrontDistribution this never deletes
454
+ module.exports.getCloudFrontOriginAccessIdentity = async (id) => {
455
+ try {
456
+ return await getClient().send(
457
+ new GetCloudFrontOriginAccessIdentityCommand({ Id: id }),
458
+ );
459
+ } catch {
460
+ return null;
461
+ }
462
+ };
@@ -80,6 +80,26 @@ module.exports.addUserToGroup = async (UserName, GroupName, iamClient) => {
80
80
  );
81
81
  };
82
82
 
83
+ // Read-only lookup, unlike removeIAMUser this never deletes
84
+ module.exports.getIAMUser = async (UserName, iamClient) => {
85
+ try {
86
+ return await (iamClient || getClient()).send(
87
+ new GetUserCommand({ UserName }),
88
+ );
89
+ } catch {
90
+ return null;
91
+ }
92
+ };
93
+
94
+ // Read-only lookup, doesn't throw when the role doesn't exist like getRole does
95
+ module.exports.getIAMRole = async (RoleName) => {
96
+ try {
97
+ return await getClient().send(new GetRoleCommand({ RoleName }));
98
+ } catch {
99
+ return null;
100
+ }
101
+ };
102
+
83
103
  module.exports.removeIAMUser = async (UserName) => {
84
104
  let res;
85
105
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fishawack/lab-env",
3
- "version": "5.9.0-beta.2",
3
+ "version": "5.9.0-beta.4",
4
4
  "description": "Docker manager for FW",
5
5
  "main": "cli.js",
6
6
  "scripts": {
@@ -15,6 +15,9 @@ COPY ./policy.xml /etc/ImageMagick-6/policy.xml
15
15
  # Add php user
16
16
  RUN useradd -m -G www-data -s /bin/bash php
17
17
 
18
+ # Set safe directory to remove intel errors when running git rev-parse
19
+ RUN su php -c "git config --global --add safe.directory /app"
20
+
18
21
  # Change composer home dir
19
22
  ENV COMPOSER_HOME=/home/php/.composer
20
23