@nmakarov/cli-toolkit 0.32.0 → 0.33.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/README.md +17 -0
- package/dist/aws.cjs +61 -0
- package/dist/aws.cjs.map +1 -1
- package/dist/aws.js +61 -0
- package/dist/aws.js.map +1 -1
- package/dist/index.cjs +61 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +61 -0
- package/dist/index.js.map +1 -1
- package/package.json +4 -2
- package/scripts/aws/discover.js +60 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nmakarov/cli-toolkit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.33.0",
|
|
4
4
|
"description": "A comprehensive toolkit for building CLI applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -77,7 +77,8 @@
|
|
|
77
77
|
},
|
|
78
78
|
"bin": {
|
|
79
79
|
"cli-runner": "./dist/cli-runner.js",
|
|
80
|
-
"cli-deploy": "./scripts/deploy/cli.js"
|
|
80
|
+
"cli-deploy": "./scripts/deploy/cli.js",
|
|
81
|
+
"cli-aws-discover": "./scripts/aws/discover.js"
|
|
81
82
|
},
|
|
82
83
|
"scripts": {
|
|
83
84
|
"ssm:list": "node scripts/ssm/ssm-admin.js list",
|
|
@@ -156,6 +157,7 @@
|
|
|
156
157
|
"dist/",
|
|
157
158
|
"scripts/ssm/",
|
|
158
159
|
"scripts/deploy/",
|
|
160
|
+
"scripts/aws/",
|
|
159
161
|
"README.md",
|
|
160
162
|
"LICENSE"
|
|
161
163
|
],
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* cli-aws-discover — read-only peek at the AWS account behind your credentials.
|
|
4
|
+
*
|
|
5
|
+
* Once @nmakarov/cli-toolkit is installed, run it without copying anything:
|
|
6
|
+
*
|
|
7
|
+
* npx cli-aws-discover
|
|
8
|
+
* npx cli-aws-discover --awsRegion=ca-central-1
|
|
9
|
+
*
|
|
10
|
+
* Credentials/region resolve from AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY /
|
|
11
|
+
* AWS_REGION (env or .env), an AWS_PROFILE, or an instance role. If none are
|
|
12
|
+
* found — or AWS rejects them — it prints exactly how to get a key, no stack trace.
|
|
13
|
+
*
|
|
14
|
+
* Handy for finding the Route53 zone id / VPC / AMI you need for terraform.tfvars.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { init } from "../../dist/init.js";
|
|
18
|
+
import { Aws } from "../../dist/aws.js";
|
|
19
|
+
|
|
20
|
+
const flow = async (context) => {
|
|
21
|
+
const { logger } = context;
|
|
22
|
+
logger.info("cli-aws-discover — read-only peek at your AWS account");
|
|
23
|
+
|
|
24
|
+
const aws = await Aws.init(context);
|
|
25
|
+
|
|
26
|
+
const cred = await aws.checkCredentials();
|
|
27
|
+
if (!cred.ok) {
|
|
28
|
+
logger.error(Aws.credentialsHelp(aws.getRegion()));
|
|
29
|
+
process.exitCode = 1;
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
logger.info(`credentials: ${cred.source}`);
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
const me = await aws.whoAmI();
|
|
36
|
+
logger.info(`account ${me.account} region ${aws.getRegion()}`);
|
|
37
|
+
logger.info(`identity ${me.arn}`);
|
|
38
|
+
|
|
39
|
+
const zones = await aws.listHostedZones();
|
|
40
|
+
logger.info(`\nRoute53 hosted zones (${zones.length}):`);
|
|
41
|
+
for (const z of zones) logger.info(` ${z.name.padEnd(30)} ${z.id}${z.private ? " [private]" : ""}`);
|
|
42
|
+
|
|
43
|
+
const vpcs = await aws.listVpcs();
|
|
44
|
+
logger.info(`\nVPCs (${vpcs.length}):`);
|
|
45
|
+
for (const v of vpcs) logger.info(` ${v.id} ${v.cidr}${v.isDefault ? " default" : ""} ${v.name ?? ""}`);
|
|
46
|
+
|
|
47
|
+
const ami = await aws.findLatestUbuntuAmi();
|
|
48
|
+
logger.info(`\nLatest Ubuntu AMI: ${ami ? `${ami.id} ${ami.name}` : "(none)"}`);
|
|
49
|
+
} catch (err) {
|
|
50
|
+
if (Aws.isAuthError(err)) {
|
|
51
|
+
logger.error(`AWS rejected the credentials it found (${err.name}).\n`);
|
|
52
|
+
logger.error(Aws.credentialsHelp(aws.getRegion()));
|
|
53
|
+
process.exitCode = 1;
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
throw err;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
init(flow);
|