@fishawack/lab-env 5.9.0-beta.1 → 5.9.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
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
## Changelog
|
|
2
2
|
|
|
3
|
+
### 5.9.0-beta.3 (2026-09-25)
|
|
4
|
+
|
|
5
|
+
#### Features
|
|
6
|
+
|
|
7
|
+
* server-status command ([791b39e](https://bitbucket.org/fishawackdigital/lab-env/commits/791b39e3b1a6e525d6e8a45769f5313702797ca8))
|
|
8
|
+
|
|
9
|
+
### 5.9.0-beta.2 (2026-09-10)
|
|
10
|
+
|
|
11
|
+
#### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* updating johnsonjohnson name ([4222697](https://bitbucket.org/fishawackdigital/lab-env/commits/4222697cb3189c470c9dbdf5ba0b2d1de97fa161))
|
|
14
|
+
|
|
3
15
|
### 5.9.0-beta.1 (2026-09-10)
|
|
4
16
|
|
|
5
17
|
#### Features
|
package/cli.js
CHANGED
|
@@ -0,0 +1,556 @@
|
|
|
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
|
+
async function resolveClients(argv) {
|
|
58
|
+
if (argv.all) return client.choices;
|
|
59
|
+
if (argv.client) return [argv.client];
|
|
60
|
+
|
|
61
|
+
const { check } = await inquirer.prompt([
|
|
62
|
+
{
|
|
63
|
+
type: "confirm",
|
|
64
|
+
name: "check",
|
|
65
|
+
message: "Check status for all clients?",
|
|
66
|
+
default: true,
|
|
67
|
+
},
|
|
68
|
+
]);
|
|
69
|
+
|
|
70
|
+
if (check) return client.choices;
|
|
71
|
+
|
|
72
|
+
const { selected } = await inquirer.prompt([
|
|
73
|
+
{
|
|
74
|
+
type: "checkbox",
|
|
75
|
+
name: "selected",
|
|
76
|
+
message: "Which clients would you like to check?",
|
|
77
|
+
choices: client.choices,
|
|
78
|
+
validate: (input) =>
|
|
79
|
+
input.length > 0 || "Select at least one client",
|
|
80
|
+
},
|
|
81
|
+
]);
|
|
82
|
+
|
|
83
|
+
return selected;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async function resolveRegions(argv) {
|
|
87
|
+
if (argv.all) return REGIONS;
|
|
88
|
+
if (argv.region) return [argv.region];
|
|
89
|
+
|
|
90
|
+
const { check } = await inquirer.prompt([
|
|
91
|
+
{
|
|
92
|
+
type: "confirm",
|
|
93
|
+
name: "check",
|
|
94
|
+
message: "Check status for all regions?",
|
|
95
|
+
default: true,
|
|
96
|
+
},
|
|
97
|
+
]);
|
|
98
|
+
|
|
99
|
+
if (check) return REGIONS;
|
|
100
|
+
|
|
101
|
+
const { selected } = await inquirer.prompt([
|
|
102
|
+
{
|
|
103
|
+
type: "checkbox",
|
|
104
|
+
name: "selected",
|
|
105
|
+
message: "Which regions would you like to check?",
|
|
106
|
+
choices: REGIONS,
|
|
107
|
+
validate: (input) =>
|
|
108
|
+
input.length > 0 || "Select at least one region",
|
|
109
|
+
},
|
|
110
|
+
]);
|
|
111
|
+
|
|
112
|
+
return selected;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
async function resolveBranches(argv) {
|
|
116
|
+
if (argv.all) return listGitBranches();
|
|
117
|
+
if (argv.branch) return [argv.branch];
|
|
118
|
+
|
|
119
|
+
const { check } = await inquirer.prompt([
|
|
120
|
+
{
|
|
121
|
+
type: "confirm",
|
|
122
|
+
name: "check",
|
|
123
|
+
message: `Check status for the current branch (${colorize(_.branch, "success")})?`,
|
|
124
|
+
default: true,
|
|
125
|
+
},
|
|
126
|
+
]);
|
|
127
|
+
|
|
128
|
+
if (check) return [_.branch];
|
|
129
|
+
|
|
130
|
+
const { selected } = await inquirer.prompt([
|
|
131
|
+
{
|
|
132
|
+
type: "checkbox",
|
|
133
|
+
name: "selected",
|
|
134
|
+
message: "Which branches would you like to check?",
|
|
135
|
+
choices: listGitBranches(),
|
|
136
|
+
validate: (input) =>
|
|
137
|
+
input.length > 0 || "Select at least one branch",
|
|
138
|
+
},
|
|
139
|
+
]);
|
|
140
|
+
|
|
141
|
+
return selected;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// S3/CloudFront are account-wide, not per-region, so fetch once per client and reuse
|
|
145
|
+
async function getS3Buckets(cache, clientName) {
|
|
146
|
+
if (!cache.has(clientName)) {
|
|
147
|
+
const { Buckets } = await aws.s3.listS3Buckets();
|
|
148
|
+
cache.set(clientName, Buckets || []);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return cache.get(clientName);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
async function getDistributions(cache, clientName) {
|
|
155
|
+
if (!cache.has(clientName)) {
|
|
156
|
+
cache.set(clientName, await aws.cloudfront.listDistributions());
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return cache.get(clientName);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function findDistribution(distributions, s3Slug) {
|
|
163
|
+
return distributions.find((d) => {
|
|
164
|
+
const origin = d.Origins?.Items?.[0]?.DomainName || "";
|
|
165
|
+
return origin.split(".s3.")[0] === s3Slug;
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// EB/RDS/OpenSearch/ElastiCache are the only truly regional checks; S3/CloudFront/IAM/SES
|
|
170
|
+
// are account-wide, so they're only worth fetching once per branch (on the primary region)
|
|
171
|
+
async function checkBranch(caches, clientName, branch, isPrimaryRegion) {
|
|
172
|
+
const s3Slug = aws.slug(_.repoSafe, clientName, branch, "s3");
|
|
173
|
+
const ebSlug = aws.slug(_.repoSafe, clientName, branch, "eb");
|
|
174
|
+
const rdsSlug = aws.slug(_.repoSafe, clientName, branch, "rds");
|
|
175
|
+
const osSlug = aws.slug(_.repoSafe, clientName, branch, "os");
|
|
176
|
+
const cacheSlug = aws.slug(_.repoSafe, clientName, branch, "cache");
|
|
177
|
+
const responseFnSlug = aws.slug(
|
|
178
|
+
`${_.repoSafe}-response`,
|
|
179
|
+
clientName,
|
|
180
|
+
branch,
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
const result = { slug: s3Slug };
|
|
184
|
+
|
|
185
|
+
try {
|
|
186
|
+
const { Environments } =
|
|
187
|
+
await aws.elasticbeanstalk.describeEnvironment(ebSlug);
|
|
188
|
+
const active = (Environments || []).find(
|
|
189
|
+
(e) => e.Status !== "Terminated",
|
|
190
|
+
);
|
|
191
|
+
result.elasticbeanstalk = active
|
|
192
|
+
? {
|
|
193
|
+
found: true,
|
|
194
|
+
name: ebSlug,
|
|
195
|
+
status: active.Status,
|
|
196
|
+
health: active.Health,
|
|
197
|
+
domain: active.CNAME,
|
|
198
|
+
}
|
|
199
|
+
: { found: false };
|
|
200
|
+
} catch {
|
|
201
|
+
result.elasticbeanstalk = { found: false };
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if (isPrimaryRegion) {
|
|
205
|
+
const buckets = await getS3Buckets(caches.s3, clientName);
|
|
206
|
+
const bucket = buckets.find((b) => b.Name === s3Slug);
|
|
207
|
+
result.s3 = bucket ? { found: true, name: s3Slug } : { found: false };
|
|
208
|
+
} else {
|
|
209
|
+
result.s3 = { found: false };
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
try {
|
|
213
|
+
const { DBInstances } = await new RDSClient({}).send(
|
|
214
|
+
new DescribeDBInstancesCommand({ DBInstanceIdentifier: rdsSlug }),
|
|
215
|
+
);
|
|
216
|
+
const instance = DBInstances?.[0];
|
|
217
|
+
result.rds =
|
|
218
|
+
instance && instance.DBInstanceStatus !== "deleting"
|
|
219
|
+
? {
|
|
220
|
+
found: true,
|
|
221
|
+
name: rdsSlug,
|
|
222
|
+
status: instance.DBInstanceStatus,
|
|
223
|
+
endpoint: instance.Endpoint?.Address,
|
|
224
|
+
}
|
|
225
|
+
: { found: false };
|
|
226
|
+
} catch {
|
|
227
|
+
result.rds = { found: false };
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
try {
|
|
231
|
+
const { DomainStatus } = await new OpenSearchClient({}).send(
|
|
232
|
+
new DescribeDomainCommand({ DomainName: osSlug }),
|
|
233
|
+
);
|
|
234
|
+
result.opensearch =
|
|
235
|
+
DomainStatus && !DomainStatus.Deleted
|
|
236
|
+
? {
|
|
237
|
+
found: true,
|
|
238
|
+
name: osSlug,
|
|
239
|
+
status: DomainStatus.Processing
|
|
240
|
+
? "processing"
|
|
241
|
+
: "available",
|
|
242
|
+
endpoint:
|
|
243
|
+
DomainStatus.Endpoint || DomainStatus.Endpoints?.vpc,
|
|
244
|
+
}
|
|
245
|
+
: { found: false };
|
|
246
|
+
} catch {
|
|
247
|
+
result.opensearch = { found: false };
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
try {
|
|
251
|
+
const { ReplicationGroups } = await new ElastiCacheClient({}).send(
|
|
252
|
+
new DescribeReplicationGroupsCommand({
|
|
253
|
+
ReplicationGroupId: cacheSlug,
|
|
254
|
+
}),
|
|
255
|
+
);
|
|
256
|
+
const group = ReplicationGroups?.[0];
|
|
257
|
+
result.elasticache =
|
|
258
|
+
group && group.Status !== "deleting"
|
|
259
|
+
? {
|
|
260
|
+
found: true,
|
|
261
|
+
name: cacheSlug,
|
|
262
|
+
status: group.Status,
|
|
263
|
+
endpoint: group.NodeGroups?.[0]?.PrimaryEndpoint?.Address,
|
|
264
|
+
}
|
|
265
|
+
: { found: false };
|
|
266
|
+
} catch {
|
|
267
|
+
result.elasticache = { found: false };
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
if (isPrimaryRegion) {
|
|
271
|
+
const distributions = await getDistributions(
|
|
272
|
+
caches.cloudfront,
|
|
273
|
+
clientName,
|
|
274
|
+
);
|
|
275
|
+
const distribution = findDistribution(distributions, s3Slug);
|
|
276
|
+
result.cloudfront = distribution
|
|
277
|
+
? {
|
|
278
|
+
found: true,
|
|
279
|
+
name: distribution.Id,
|
|
280
|
+
status: distribution.Status,
|
|
281
|
+
domain: distribution.DomainName,
|
|
282
|
+
}
|
|
283
|
+
: { found: false };
|
|
284
|
+
|
|
285
|
+
const [requestFn, responseFn] = await Promise.all([
|
|
286
|
+
aws.cloudfront.getCloudFrontFunction(s3Slug),
|
|
287
|
+
aws.cloudfront.getCloudFrontFunction(responseFnSlug),
|
|
288
|
+
]);
|
|
289
|
+
|
|
290
|
+
result.cloudfrontFunctions = {
|
|
291
|
+
request: requestFn
|
|
292
|
+
? { found: true, name: s3Slug }
|
|
293
|
+
: { found: false },
|
|
294
|
+
response: responseFn
|
|
295
|
+
? { found: true, name: responseFnSlug }
|
|
296
|
+
: { found: false },
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
if (distribution) {
|
|
300
|
+
const oaiPath =
|
|
301
|
+
distribution.Origins?.Items?.[0]?.S3OriginConfig
|
|
302
|
+
?.OriginAccessIdentity || "";
|
|
303
|
+
const oaiId = oaiPath.split(
|
|
304
|
+
"origin-access-identity/cloudfront/",
|
|
305
|
+
)[1];
|
|
306
|
+
const oai = oaiId
|
|
307
|
+
? await aws.cloudfront.getCloudFrontOriginAccessIdentity(oaiId)
|
|
308
|
+
: null;
|
|
309
|
+
result.cloudfrontIdentity = oai
|
|
310
|
+
? { found: true, name: oaiId }
|
|
311
|
+
: { found: false };
|
|
312
|
+
} else {
|
|
313
|
+
result.cloudfrontIdentity = { found: false };
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// Non-Laravel fullstack apps get a dedicated storage IAM user (same name as the bucket)
|
|
317
|
+
const storageUser = await aws.iam.getIAMUser(s3Slug);
|
|
318
|
+
result.iamStorageUser = storageUser
|
|
319
|
+
? { found: true, name: s3Slug }
|
|
320
|
+
: { found: false };
|
|
321
|
+
|
|
322
|
+
// Laravel fullstack apps instead grant service access via a per-environment IAM role/instance profile
|
|
323
|
+
const roleName = `${ebSlug}-role`;
|
|
324
|
+
const instanceRole = await aws.iam.getIAMRole(roleName);
|
|
325
|
+
result.iamInstanceRole = instanceRole
|
|
326
|
+
? { found: true, name: roleName }
|
|
327
|
+
: { found: false };
|
|
328
|
+
|
|
329
|
+
const sesUserName = `${ebSlug}-ses`;
|
|
330
|
+
const mailUser = await aws.iam.getIAMUser(sesUserName, mailIamClient);
|
|
331
|
+
result.sesMail = mailUser
|
|
332
|
+
? { found: true, name: sesUserName }
|
|
333
|
+
: { found: false };
|
|
334
|
+
} else {
|
|
335
|
+
result.cloudfront = { found: false };
|
|
336
|
+
result.cloudfrontFunctions = {
|
|
337
|
+
request: { found: false },
|
|
338
|
+
response: { found: false },
|
|
339
|
+
};
|
|
340
|
+
result.cloudfrontIdentity = { found: false };
|
|
341
|
+
result.iamStorageUser = { found: false };
|
|
342
|
+
result.iamInstanceRole = { found: false };
|
|
343
|
+
result.sesMail = { found: false };
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
return result;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
function printServiceLine(label, entry, indent = " ") {
|
|
350
|
+
if (!entry || !entry.found) {
|
|
351
|
+
console.log(`${indent}${colorize("✕", "error")} ${label}`);
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
const details = [entry.status, entry.name].filter(Boolean).join(" · ");
|
|
356
|
+
|
|
357
|
+
console.log(
|
|
358
|
+
`${indent}${colorize("✓", "success")} ${label}${details ? ` ${colorize(`(${details})`, "info")}` : ""}`,
|
|
359
|
+
);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
function buildGroups(result, isPrimaryRegion) {
|
|
363
|
+
// ElasticBeanstalk/IAM storage user/IAM instance role/SES are exclusively fullstack
|
|
364
|
+
// signals, so use them to decide which group the shared S3 slug belongs to
|
|
365
|
+
const isFullstack =
|
|
366
|
+
result.elasticbeanstalk.found ||
|
|
367
|
+
result.iamStorageUser.found ||
|
|
368
|
+
result.iamInstanceRole.found ||
|
|
369
|
+
result.sesMail.found;
|
|
370
|
+
|
|
371
|
+
// Non-regional (S3/CloudFront/IAM/SES) checks only apply once per branch, not per region
|
|
372
|
+
const staticEntries = isPrimaryRegion
|
|
373
|
+
? [
|
|
374
|
+
["S3", isFullstack ? null : result.s3],
|
|
375
|
+
["CloudFront", result.cloudfront],
|
|
376
|
+
[
|
|
377
|
+
"CloudFront Function (request)",
|
|
378
|
+
result.cloudfrontFunctions.request,
|
|
379
|
+
],
|
|
380
|
+
[
|
|
381
|
+
"CloudFront Function (response)",
|
|
382
|
+
result.cloudfrontFunctions.response,
|
|
383
|
+
],
|
|
384
|
+
["CloudFront Identity (OAI)", result.cloudfrontIdentity],
|
|
385
|
+
].filter(([, entry]) => entry !== null)
|
|
386
|
+
: [];
|
|
387
|
+
|
|
388
|
+
const fullstackEntries = [
|
|
389
|
+
["ElasticBeanstalk", result.elasticbeanstalk],
|
|
390
|
+
["RDS", result.rds],
|
|
391
|
+
["OpenSearch", result.opensearch],
|
|
392
|
+
["ElastiCache (Valkey)", result.elasticache],
|
|
393
|
+
...(isPrimaryRegion
|
|
394
|
+
? [
|
|
395
|
+
["S3 (storage)", isFullstack ? result.s3 : null],
|
|
396
|
+
// Legacy pattern being phased out — only worth showing when actually present
|
|
397
|
+
[
|
|
398
|
+
"IAM Storage User (legacy)",
|
|
399
|
+
result.iamStorageUser.found
|
|
400
|
+
? result.iamStorageUser
|
|
401
|
+
: null,
|
|
402
|
+
],
|
|
403
|
+
["IAM Instance Role", result.iamInstanceRole],
|
|
404
|
+
["SES Mail Credentials", result.sesMail],
|
|
405
|
+
]
|
|
406
|
+
: []),
|
|
407
|
+
].filter(([, entry]) => entry !== null);
|
|
408
|
+
|
|
409
|
+
return {
|
|
410
|
+
staticEntries,
|
|
411
|
+
fullstackEntries,
|
|
412
|
+
staticFound: staticEntries.some(([, entry]) => entry.found),
|
|
413
|
+
fullstackFound: fullstackEntries.some(([, entry]) => entry.found),
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
function printStatusReport(results) {
|
|
418
|
+
const empty = [];
|
|
419
|
+
const withResources = [];
|
|
420
|
+
|
|
421
|
+
for (const entry of results) {
|
|
422
|
+
const groups = buildGroups(entry.result, entry.isPrimaryRegion);
|
|
423
|
+
|
|
424
|
+
if (groups.staticFound || groups.fullstackFound) {
|
|
425
|
+
withResources.push({ ...entry, groups });
|
|
426
|
+
} else {
|
|
427
|
+
empty.push(entry);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
if (empty.length) {
|
|
432
|
+
console.log(` ${colorize("No resources found", "title")}\n`);
|
|
433
|
+
|
|
434
|
+
empty.forEach(({ client: clientName, region: regionName, branch }) => {
|
|
435
|
+
console.log(
|
|
436
|
+
` ${colorize("✕", "error")} ${clientName} / ${regionName} / ${branch}`,
|
|
437
|
+
);
|
|
438
|
+
});
|
|
439
|
+
|
|
440
|
+
console.log("");
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
for (const {
|
|
444
|
+
client: clientName,
|
|
445
|
+
region: regionName,
|
|
446
|
+
branch,
|
|
447
|
+
result,
|
|
448
|
+
groups: {
|
|
449
|
+
staticEntries,
|
|
450
|
+
fullstackEntries,
|
|
451
|
+
staticFound,
|
|
452
|
+
fullstackFound,
|
|
453
|
+
},
|
|
454
|
+
} of withResources) {
|
|
455
|
+
console.log(
|
|
456
|
+
` ${colorize(`${clientName} / ${regionName} / ${branch}`, "divider")}`,
|
|
457
|
+
);
|
|
458
|
+
console.log(` ${colorize(result.slug, "info")}\n`);
|
|
459
|
+
|
|
460
|
+
if (fullstackFound) {
|
|
461
|
+
fullstackEntries.forEach(([label, entry]) =>
|
|
462
|
+
printServiceLine(label, entry),
|
|
463
|
+
);
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
if (fullstackFound && staticFound) {
|
|
467
|
+
console.log("");
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
if (staticFound) {
|
|
471
|
+
staticEntries.forEach(([label, entry]) =>
|
|
472
|
+
printServiceLine(label, entry),
|
|
473
|
+
);
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
console.log("");
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
module.exports = [
|
|
481
|
+
"server-status",
|
|
482
|
+
_.config.preset === "devops"
|
|
483
|
+
? "Report AWS resource status for a branch across services"
|
|
484
|
+
: false,
|
|
485
|
+
(yargs) => {
|
|
486
|
+
yargs.option("all", {
|
|
487
|
+
alias: "a",
|
|
488
|
+
describe:
|
|
489
|
+
"Check all clients, regions and branches (inferred from git branch -a)",
|
|
490
|
+
type: "boolean",
|
|
491
|
+
default: false,
|
|
492
|
+
});
|
|
493
|
+
yargs.option("branch", {
|
|
494
|
+
alias: "b",
|
|
495
|
+
describe: "Branch to check",
|
|
496
|
+
type: "string",
|
|
497
|
+
});
|
|
498
|
+
yargs.option("client", {
|
|
499
|
+
alias: "c",
|
|
500
|
+
describe: "AWS account to use",
|
|
501
|
+
type: "string",
|
|
502
|
+
});
|
|
503
|
+
yargs.option("region", {
|
|
504
|
+
alias: "r",
|
|
505
|
+
describe: "AWS region to use",
|
|
506
|
+
type: "string",
|
|
507
|
+
});
|
|
508
|
+
},
|
|
509
|
+
async (argv) => {
|
|
510
|
+
const clients = await resolveClients(argv);
|
|
511
|
+
const regions = await resolveRegions(argv);
|
|
512
|
+
const branches = await resolveBranches(argv);
|
|
513
|
+
|
|
514
|
+
if (!branches.length) {
|
|
515
|
+
console.log(
|
|
516
|
+
`\n ${colorize("No branches to check.", "warning")}\n`,
|
|
517
|
+
);
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
// Cached per-client since S3/CloudFront are account-wide, not per-region
|
|
522
|
+
const caches = { s3: new Map(), cloudfront: new Map() };
|
|
523
|
+
const results = [];
|
|
524
|
+
const [primaryRegion] = regions;
|
|
525
|
+
|
|
526
|
+
for (const c of clients) {
|
|
527
|
+
for (const r of regions) {
|
|
528
|
+
setAWSClientDefaults(c, r);
|
|
529
|
+
|
|
530
|
+
const isPrimaryRegion = r === primaryRegion;
|
|
531
|
+
const spinner = new Spinner(`Checking ${c} / ${r}`, true);
|
|
532
|
+
|
|
533
|
+
for (const branch of branches) {
|
|
534
|
+
spinner.ora.text = `Checking ${c} / ${r} - ${branch}`;
|
|
535
|
+
const result = await checkBranch(
|
|
536
|
+
caches,
|
|
537
|
+
c,
|
|
538
|
+
branch,
|
|
539
|
+
isPrimaryRegion,
|
|
540
|
+
);
|
|
541
|
+
results.push({
|
|
542
|
+
client: c,
|
|
543
|
+
region: r,
|
|
544
|
+
branch,
|
|
545
|
+
result,
|
|
546
|
+
isPrimaryRegion,
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
spinner.ora.stop();
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
printStatusReport(results);
|
|
555
|
+
},
|
|
556
|
+
];
|
|
@@ -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
|
|