@infrascan/cli 0.2.1 → 0.2.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/README.md CHANGED
@@ -2,3 +2,47 @@
2
2
 
3
3
  The Infrascan CLI is a thin wrapper around the Infrascan SDK which outputs its state to the local file system.
4
4
 
5
+ The Infrascan CLI exposes two commands: scan and graph. A scan will read in all of the information that it can from your AWS account, and write it to your local file system. You can then run the graph command to take that scan output and convert it into an infrastructure diagram.
6
+
7
+ ## Prerequisite
8
+
9
+ Infrascan requires read access to your AWS account to generate its graphs. Read access can be given by specifying a profile in your [AWS credentials file](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html), or by using the [default credential provider chain](https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/setting-credentials-node.html) and providing a role to assume.
10
+
11
+ ## Quickstart
12
+
13
+ ### Scan
14
+
15
+ To run a scan command, we first need to create the config file. The config file will tell the CLI which regions to scan, and how to authenticate with AWS. The config file format is:
16
+
17
+ ```json
18
+ [
19
+ {
20
+ "regions": ["eu-west-1", "us-east-1"],
21
+ "profile": "infrascan-read-access-staging"
22
+ },
23
+ {
24
+ "regions": ["eu-west-1"],
25
+ "roleToAssume": "arn:aws:iam::000000000000:role/InfrascanReadOnlyRolePreProd"
26
+ }
27
+ ]
28
+ ```
29
+
30
+ The scan command takes our config file and an output directory as arguments. The output directory is where all of the state generated during the scan will be written. This will be used by our graph command to produce an infrastructure diagram.
31
+
32
+ ```sh
33
+ infrascan scan -c config.json -o ./state
34
+ ```
35
+
36
+ The state directory should contain JSON files in the format of: `<AccountID>-<Region>-<Service>-<FunctionCalled>.json`.
37
+
38
+ ### Graph
39
+
40
+ To convert the scan output into a graph, we run the graph command passing the scan output directory as our input:
41
+
42
+ ```sh
43
+ infrascan graph --input ./state
44
+ ```
45
+
46
+ The graph output will be saved to a `graph.json` file in the state directory. The graph file contains an array of JSON objects representing the Nodes and Edges of the graph. This is formatted to be used with [cytoscape](https://js.cytoscape.org/), however it can be translated into any graphing library (Note: the graphs usually require on being able to create parent-child relationships)
47
+
48
+ You can view your graph by pasting the contents of your `graph.json` file into: [render.infrascan.io](https://render.infrascan.io).
package/dist/index.mjs CHANGED
@@ -36,10 +36,10 @@ var GraphCmd = class extends CommandLineAction {
36
36
  }
37
37
  onDefineParameters() {
38
38
  this._outputDirectory = this.defineStringParameter({
39
- parameterLongName: "--output",
40
- parameterShortName: "-o",
41
- argumentName: "PATH_TO_STATE_OUTPUT",
42
- description: "Location to read scan output from. This should be the same as the directory given to the scan command.",
39
+ parameterLongName: "--input",
40
+ parameterShortName: "-i",
41
+ argumentName: "PATH_TO_STATE",
42
+ description: "Location to read scan state from. This should be the same as the directory given to the scan command.",
43
43
  defaultValue: "./state"
44
44
  });
45
45
  }
@@ -104,7 +104,9 @@ function resolveCredentials(profile, roleToAssume) {
104
104
  }
105
105
  });
106
106
  }
107
- throw new Error();
107
+ throw new Error(
108
+ "An error occurred while resolving credentials for Infrascan \u2014 no profile or role given."
109
+ );
108
110
  }
109
111
  var ScanCmd = class extends CommandLineAction2 {
110
112
  constructor(infrascanClient) {
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@infrascan/cli",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Thin command line wrapper around the infrascan sdk",
5
- "main": "dist/index.js",
5
+ "main": "dist/index.mjs",
6
6
  "scripts": {
7
7
  "build": "rm -rf dist ; tsup",
8
8
  "lint": "tsc --noEmit ; eslint .",
@@ -20,26 +20,32 @@
20
20
  "target": "node18"
21
21
  },
22
22
  "bin": {
23
- "infrascan": "dist/index.js"
23
+ "infrascan": "./dist/index.mjs"
24
24
  },
25
25
  "files": [
26
26
  "dist"
27
27
  ],
28
28
  "types": "dist/index.d.ts",
29
- "keywords": [],
29
+ "keywords": [
30
+ "AWS",
31
+ "Infrastructure Diagram",
32
+ "Infrastructure Graph",
33
+ "Cloud Infrastructure",
34
+ "CLI"
35
+ ],
30
36
  "author": "Liam Farrelly <liam@l3f7.dev> (https://whoisli.am/)",
31
37
  "license": "MPL-2.0",
32
38
  "dependencies": {
33
39
  "@aws-sdk/credential-providers": "3.428.0",
34
- "@infrascan/aws": "^0.2.0",
35
- "@infrascan/fs-connector": "^0.2.0",
36
- "@infrascan/sdk": "^0.2.0",
40
+ "@infrascan/aws": "^0.3.0",
41
+ "@infrascan/fs-connector": "^0.2.2",
42
+ "@infrascan/sdk": "^0.2.2",
37
43
  "@rushstack/ts-command-line": "^4.15.2",
38
44
  "minimatch": "^6.1.6"
39
45
  },
40
46
  "devDependencies": {
41
47
  "@aws-sdk/types": "3.428.0",
42
- "@infrascan/shared-types": "^0.2.0",
48
+ "@infrascan/shared-types": "^0.2.2",
43
49
  "ts-node": "^10.9.1",
44
50
  "typescript": "^5.1.3"
45
51
  }