korinfra 0.1.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/LICENSE +191 -0
- package/README.md +361 -0
- package/bin/korinfra.js +2 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +1954 -0
- package/dist/storage/migrations/001_initial.sql +145 -0
- package/dist/storage/migrations/002_add_indexes.sql +4 -0
- package/dist/storage/migrations/003_add_cascade_deletes.sql +90 -0
- package/package.json +144 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding any notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
Copyright 2026 Vladimir Mocanu
|
|
180
|
+
|
|
181
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
182
|
+
you may not use this file except in compliance with the License.
|
|
183
|
+
You may obtain a copy of the License at
|
|
184
|
+
|
|
185
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
186
|
+
|
|
187
|
+
Unless required by applicable law or agreed to in writing, software
|
|
188
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
189
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
190
|
+
See the License for the specific language governing permissions and
|
|
191
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
<img src=".github/logo_korinfra.png" alt="KorInfra" width="460">
|
|
4
|
+
|
|
5
|
+
### Your AWS bill has waste. KorInfra finds it in minutes
|
|
6
|
+
|
|
7
|
+
<p>
|
|
8
|
+
9 AWS services · 66 cost rules + 46 security rules · Terraform-aware auto-fixes · AI explanations · zero telemetry
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
[](https://github.com/korinfra/korinfra/actions/workflows/ci.yml)
|
|
12
|
+
[](https://www.npmjs.com/package/korinfra)
|
|
13
|
+
[](https://www.npmjs.com/package/korinfra)
|
|
14
|
+
[](LICENSE)
|
|
15
|
+
[](https://nodejs.org)
|
|
16
|
+
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
Stopped EC2 instances still billing. Oversized RDS nobody connects to. Lambda functions with zero invocations. EBS volumes attached to nothing.
|
|
22
|
+
|
|
23
|
+
KorInfra scans your live AWS account, runs 112 rules locally in seconds, and tells you exactly what to kill, resize, or fix — with AI-generated explanations and optional Terraform patches.
|
|
24
|
+
|
|
25
|
+
**No cloud. No dashboard. Your data stays on your machine.**
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install -g korinfra
|
|
29
|
+
korinfra # launch interactive TUI (menu-driven, fully keyboard-driven)
|
|
30
|
+
korinfra init # first-time setup: AWS profile + AI key (60 seconds)
|
|
31
|
+
korinfra scan # full cost + security scan
|
|
32
|
+
|
|
33
|
+
# or try without installing:
|
|
34
|
+
npx korinfra
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**Requirements:** Node.js ≥ 22 · [AWS credentials configured](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html)
|
|
38
|
+
|
|
39
|
+
First time? → [Getting started guide](docs/getting-started.md) (5 min walkthrough)
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## What KorInfra does
|
|
44
|
+
|
|
45
|
+
**Works without AI.** All 66 cost rules and 46 security rules run locally — no API key, no AI calls, $0 cost. Add an AI provider key to unlock natural language explanations and Terraform patch generation.
|
|
46
|
+
|
|
47
|
+
**Terraform-aware.** 4-pass matcher (ARN → ID → name tag → fuzzy) links every live AWS resource to its `.tf` definition. When a fix is available, KorInfra edits the right file and opens a PR, no manual hunting.
|
|
48
|
+
|
|
49
|
+
**CI/CD ready.** `korinfra scan --json --fail-on critical` exits 1 on critical findings. Pipe it into any pipeline. Zero AI cost in CI.
|
|
50
|
+
|
|
51
|
+
**Your data stays local.** Everything in a SQLite database. The only data that ever leaves your machine is redacted findings sent to the AI provider you choose. Credentials, ARNs, IPs, and emails are stripped automatically.
|
|
52
|
+
|
|
53
|
+
**MCP server included.** `korinfra mcp` registers a server in Claude Code or Cursor. Ask your editor "which EC2 instances are idle?" — KorInfra runs the analysis and returns results inline.
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Commands
|
|
58
|
+
|
|
59
|
+
Run `korinfra` for the interactive TUI, or `korinfra <command>` to run directly:
|
|
60
|
+
|
|
61
|
+
| Command | What it does | Needs AI? |
|
|
62
|
+
|---|---|---|
|
|
63
|
+
| *(no args)* | Launch interactive TUI — menu-driven, fully keyboard-driven | No |
|
|
64
|
+
| `scan` | Full cost + security scan | No |
|
|
65
|
+
| `costs` | Cost Explorer breakdown. `--days N`, `--group-by service\|region\|account\|tag` | No |
|
|
66
|
+
| `resources` | Browse and filter all scanned resources | No |
|
|
67
|
+
| `changes` | Audit recent AWS API activity (CloudTrail). Filter by user, resource type, time window (24h/48h/7d) | No |
|
|
68
|
+
| `recommend` | Review saved recommendations. `--refresh` re-runs analysis | `--refresh` only |
|
|
69
|
+
| `fix` | AI reads your Terraform, generates a patch, opens a GitHub PR | **Yes** |
|
|
70
|
+
| `report` | Export to JSON, CSV, or HTML (with inline SVG charts) | No |
|
|
71
|
+
| `history` | Browse past scans, diff between them | No |
|
|
72
|
+
| `security` | 46 Terraform security rules. `--dir <path>` | No |
|
|
73
|
+
| `tags` | Audit required tags. `suggest` mode uses AI. Apply AI-suggested tags directly with confirmation (`a` key) | `suggest/apply` only |
|
|
74
|
+
| `pricing` | Inspect or refresh the local AWS pricing cache | No |
|
|
75
|
+
| `init` | Setup wizard — AWS profile, AI provider, API key | No |
|
|
76
|
+
| `doctor` | Verify credentials, config, storage, and AI provider | No |
|
|
77
|
+
| `config` | View or edit config values at runtime | No |
|
|
78
|
+
| `mcp` | Install MCP server into Claude Code or Cursor | No |
|
|
79
|
+
| `serve` | Start MCP server — `stdio` (default) or `--http --port N` | No |
|
|
80
|
+
|
|
81
|
+
Press `/` from the main menu to ask your AI assistant anything about your infrastructure.
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## What it catches
|
|
86
|
+
|
|
87
|
+
**66 cost rules** across EC2, RDS, EBS, S3, Lambda, ECS, ELB, ElastiCache, DynamoDB, and NAT Gateway — plus **46 security rules** on your Terraform config.
|
|
88
|
+
|
|
89
|
+
**Idle resource detection** using multi-signal CloudWatch heuristics: CPU + network I/O for EC2, database connections for RDS, attachment status for EBS volumes, and Reserved Instance coverage gaps.
|
|
90
|
+
|
|
91
|
+
| Rule | Finding | Typical saving |
|
|
92
|
+
|---|---|---|
|
|
93
|
+
| EC2-001 | Instance with <5% CPU for 7+ days | $50–400/mo |
|
|
94
|
+
| EC2-003 | m4/c4/r4 family — faster current-gen is cheaper | $20–200/mo |
|
|
95
|
+
| RDS-007 | Multi-AZ on dev/staging (disable and halve the cost) | $100–3000/mo |
|
|
96
|
+
| EBS-001 | Unattached volumes still billing | $5–50/mo each |
|
|
97
|
+
| EBS-003 | gp2 → gp3 migration (20% cheaper, same performance) | $10–100/mo |
|
|
98
|
+
| LAM-001 | Lambda with zero invocations | < $5/mo |
|
|
99
|
+
| S3-004 | Bucket without server-side encryption (SSE-S3 is free) | — |
|
|
100
|
+
| RDS-005 | Publicly accessible RDS instance | — |
|
|
101
|
+
|
|
102
|
+
Plus: cost anomaly detection (z-score) and 30-day trend forecasting.
|
|
103
|
+
|
|
104
|
+
[Full rule list →](docs/rules.md) · [Running costs →](docs/running-costs.md)
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## Applying fixes
|
|
109
|
+
|
|
110
|
+
Run `korinfra fix`, select a recommendation, and the AI agent:
|
|
111
|
+
|
|
112
|
+
1. Reads your Terraform files to locate the resource
|
|
113
|
+
2. Generates a minimal, targeted patch
|
|
114
|
+
3. Runs `terraform validate` to verify the change
|
|
115
|
+
4. Shows exactly what will change before applying
|
|
116
|
+
5. Optionally creates a GitHub PR
|
|
117
|
+
|
|
118
|
+
You stay in control — every change is shown for review before anything is written. No AWS API calls are made. Rollback is as simple as reverting the file.
|
|
119
|
+
|
|
120
|
+
> **AI required** — `fix` uses the AI provider you configured in `korinfra init`.
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## Interactive TUI
|
|
125
|
+
|
|
126
|
+
Run `korinfra` with no arguments to launch the full interactive menu. KorInfra is fully keyboard-driven, built with Ink 6 + React 19 — the same stack as Claude Code and Gemini CLI.
|
|
127
|
+
|
|
128
|
+
- **Navigate** with `↑↓`, drill into any recommendation with `Enter`, go back with `Esc`
|
|
129
|
+
- **After a scan** — a follow-up panel stays open so you can ask questions in the same session ("why is this expensive?", "explain the RDS finding")
|
|
130
|
+
- **`/` from the main menu** — free-form AI questions about your infrastructure
|
|
131
|
+
- **`f` on any recommendation** — jump straight to `fix` and generate a Terraform patch
|
|
132
|
+
- **`p`** — export a report without leaving the screen
|
|
133
|
+
- Headless when needed: `--json`, `--no-tui`, or `CI=true` auto-detected
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## MCP Server
|
|
138
|
+
|
|
139
|
+
KorInfra exposes all its capabilities as an [MCP server](https://modelcontextprotocol.io). Add it to your AI editor with one command:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
korinfra mcp # auto-installs into Claude Code or Cursor
|
|
143
|
+
korinfra serve # start manually (stdio transport)
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Then ask your editor: *"which EC2 instances have been idle for 2 weeks?"* — KorInfra collects live AWS data and returns structured results without switching to the terminal.
|
|
147
|
+
|
|
148
|
+
**20 tools · 3 resources · 3 prompts.** [Full MCP docs →](docs/mcp.md)
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## CI/CD
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
# Works without a TTY — auto-detected in CI
|
|
156
|
+
korinfra scan --json | jq '.summary'
|
|
157
|
+
korinfra security --json --dir ./terraform --fail-on critical # exits 1 on critical
|
|
158
|
+
CI=true korinfra scan --json > scan.json
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
All commands support `--json` (machine-readable) and `--no-tui` (plain text). AI streaming works without a TTY. Zero AI cost in headless mode.
|
|
162
|
+
|
|
163
|
+
[Full reference + GitHub Actions example →](docs/usage.md)
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## KorInfra vs. alternatives
|
|
168
|
+
|
|
169
|
+
| | KorInfra | AWS Trusted Advisor | Infracost | Checkov |
|
|
170
|
+
|---|---|---|---|---|
|
|
171
|
+
| AI reasoning (not just rules) | ✓ | — | — | — |
|
|
172
|
+
| Cost optimization (live infra) | 66 rules | Limited (free tier) | Pricing only | — |
|
|
173
|
+
| Security scanning | 46 rules | ✓ | — | 1000+ rules |
|
|
174
|
+
| Cost anomaly detection | ✓ | — | — | — |
|
|
175
|
+
| MCP server for AI editors | ✓ | — | — | — |
|
|
176
|
+
| Ask anything in natural language | ✓ | — | — | — |
|
|
177
|
+
| Data stays local | ✓ | — (AWS console) | Partial | ✓ |
|
|
178
|
+
| Generates Terraform fixes + PRs | ✓ | — | — | — |
|
|
179
|
+
|
|
180
|
+
Checkov catches misconfigs at build time. Trusted Advisor checks running infra. KorInfra sits between them: live AWS state, AI-driven analysis, and automated Terraform fix generation in one tool.
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## AWS Permissions
|
|
185
|
+
|
|
186
|
+
<details>
|
|
187
|
+
<summary><strong>Minimal IAM policy — read-only (click to expand)</strong></summary>
|
|
188
|
+
|
|
189
|
+
```json
|
|
190
|
+
{
|
|
191
|
+
"Version": "2012-10-17",
|
|
192
|
+
"Statement": [
|
|
193
|
+
{
|
|
194
|
+
"Sid": "korinfraReadOnly",
|
|
195
|
+
"Effect": "Allow",
|
|
196
|
+
"Action": [
|
|
197
|
+
"ec2:DescribeInstances",
|
|
198
|
+
"ec2:DescribeVolumes",
|
|
199
|
+
"ec2:DescribeSnapshots",
|
|
200
|
+
"ec2:DescribeAddresses",
|
|
201
|
+
"ec2:DescribeNatGateways",
|
|
202
|
+
"rds:DescribeDBInstances",
|
|
203
|
+
"s3:ListAllMyBuckets",
|
|
204
|
+
"s3:GetBucketLocation",
|
|
205
|
+
"s3:GetBucketVersioning",
|
|
206
|
+
"s3:GetBucketEncryption",
|
|
207
|
+
"s3:GetBucketLifecycleConfiguration",
|
|
208
|
+
"s3:ListBucketIntelligentTieringConfigurations",
|
|
209
|
+
"s3:GetBucketTagging",
|
|
210
|
+
"lambda:ListFunctions",
|
|
211
|
+
"tag:GetResources",
|
|
212
|
+
"ecs:ListClusters",
|
|
213
|
+
"ecs:ListServices",
|
|
214
|
+
"ecs:DescribeServices",
|
|
215
|
+
"ecs:DescribeClusters",
|
|
216
|
+
"elasticloadbalancing:DescribeLoadBalancers",
|
|
217
|
+
"elasticloadbalancing:DescribeTargetGroups",
|
|
218
|
+
"elasticloadbalancing:DescribeTargetHealth",
|
|
219
|
+
"elasticloadbalancing:DescribeTags",
|
|
220
|
+
"elasticache:DescribeCacheClusters",
|
|
221
|
+
"elasticache:ListTagsForResource",
|
|
222
|
+
"dynamodb:ListTables",
|
|
223
|
+
"dynamodb:DescribeTable",
|
|
224
|
+
"dynamodb:ListTagsOfResource",
|
|
225
|
+
"cloudwatch:GetMetricStatistics",
|
|
226
|
+
"cloudwatch:GetMetricData",
|
|
227
|
+
"ce:GetCostAndUsage",
|
|
228
|
+
"sts:GetCallerIdentity",
|
|
229
|
+
"pricing:GetProducts"
|
|
230
|
+
],
|
|
231
|
+
"Resource": "*"
|
|
232
|
+
}
|
|
233
|
+
]
|
|
234
|
+
}
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
KorInfra never modifies AWS resources. `fix` edits your local Terraform files only — it does not call AWS APIs to make changes.
|
|
238
|
+
|
|
239
|
+
</details>
|
|
240
|
+
|
|
241
|
+
---
|
|
242
|
+
|
|
243
|
+
## Reference
|
|
244
|
+
|
|
245
|
+
<details>
|
|
246
|
+
<summary><strong>Configuration</strong></summary>
|
|
247
|
+
|
|
248
|
+
`korinfra init` creates config automatically. To customize:
|
|
249
|
+
|
|
250
|
+
```yaml
|
|
251
|
+
# .korinfra/config.yaml
|
|
252
|
+
aws:
|
|
253
|
+
default_profile: production
|
|
254
|
+
default_region: us-east-1
|
|
255
|
+
|
|
256
|
+
ai:
|
|
257
|
+
provider: claude # "none" for rules-only mode
|
|
258
|
+
model: claude-haiku-4-5-20251001 # or claude-sonnet-4-6 for deeper analysis
|
|
259
|
+
|
|
260
|
+
scan:
|
|
261
|
+
lookback_days: 30
|
|
262
|
+
idle_cpu_threshold: 5 # % CPU below this = idle
|
|
263
|
+
required_tags: [Environment, Team, Project]
|
|
264
|
+
|
|
265
|
+
anomaly:
|
|
266
|
+
z_score_threshold: 2.0
|
|
267
|
+
rolling_window_days: 14
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
[Full reference →](docs/configuration.md)
|
|
271
|
+
|
|
272
|
+
</details>
|
|
273
|
+
|
|
274
|
+
<details>
|
|
275
|
+
<summary><strong>Privacy & redaction</strong></summary>
|
|
276
|
+
|
|
277
|
+
Before anything is sent to the AI provider, KorInfra strips sensitive data automatically:
|
|
278
|
+
|
|
279
|
+
| Level | What is removed |
|
|
280
|
+
|---|---|
|
|
281
|
+
| `minimal` | AWS access keys, AI provider API keys, GitHub tokens, JWTs, DSN credentials, PEM private keys |
|
|
282
|
+
| **`moderate`** (default) | + ARN account IDs, public IPv4/IPv6, email addresses |
|
|
283
|
+
| `strict` | + private IPs, external domain names |
|
|
284
|
+
|
|
285
|
+
- No telemetry of any kind
|
|
286
|
+
- All scan data in a local SQLite database only
|
|
287
|
+
- MCP HTTP server binds to localhost only
|
|
288
|
+
- API keys stored with `chmod 600`, auto-added to `.gitignore`
|
|
289
|
+
|
|
290
|
+
</details>
|
|
291
|
+
|
|
292
|
+
<details>
|
|
293
|
+
<summary><strong>Architecture</strong></summary>
|
|
294
|
+
|
|
295
|
+
Three layers in sequence:
|
|
296
|
+
|
|
297
|
+
1. **Collect** — AWS SDK v3 pulls live state from 9 services in parallel. CloudWatch adds utilization metrics; Cost Explorer adds spending data. Every API call is rate-limited and logged.
|
|
298
|
+
2. **Analyze** — 66 cost + 46 security rules run locally (no AI, no network). 4-pass Terraform matcher compares live resources against `.tf` files. Z-score anomaly detection flags spending spikes.
|
|
299
|
+
3. **Output** — Data is redacted, then the AI agent loop produces natural language summaries and generates fixes. Final output goes to the TUI, file export (JSON/CSV/HTML), or an MCP client.
|
|
300
|
+
|
|
301
|
+
Built with TypeScript 6 · Ink 6 + React 19 · Claude Agent SDK · AWS SDK v3 · better-sqlite3 · Zod 4
|
|
302
|
+
|
|
303
|
+
[Full architecture →](docs/architecture.md)
|
|
304
|
+
|
|
305
|
+
</details>
|
|
306
|
+
|
|
307
|
+
---
|
|
308
|
+
|
|
309
|
+
## Contributing
|
|
310
|
+
|
|
311
|
+
Contributions welcome — from fixing a typo to adding a new AWS collector.
|
|
312
|
+
|
|
313
|
+
- [CONTRIBUTING.md](CONTRIBUTING.md) — setup, conventions, good first issues
|
|
314
|
+
- [Open an issue](https://github.com/korinfra/korinfra/issues) — bugs, ideas, questions
|
|
315
|
+
|
|
316
|
+
<details>
|
|
317
|
+
<summary><strong>Development setup</strong></summary>
|
|
318
|
+
|
|
319
|
+
```bash
|
|
320
|
+
git clone https://github.com/korinfra/korinfra
|
|
321
|
+
cd korinfra && npm install
|
|
322
|
+
npm run dev # interactive TUI (no build)
|
|
323
|
+
npm run dev -- scan # run a specific command
|
|
324
|
+
npm run check # typecheck + lint + test (no build)
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
</details>
|
|
328
|
+
|
|
329
|
+
---
|
|
330
|
+
|
|
331
|
+
## FAQ
|
|
332
|
+
|
|
333
|
+
**Do I need an AI provider key?**
|
|
334
|
+
No. All 66 cost rules and 46 security rules run locally — no API key, no AI calls, $0. Add a key to unlock AI-powered analysis, `/` chat, and `fix`.
|
|
335
|
+
|
|
336
|
+
**Does KorInfra modify my AWS resources?**
|
|
337
|
+
Never. KorInfra is strictly read-only against AWS. `fix` edits your local Terraform files only.
|
|
338
|
+
|
|
339
|
+
**Is my data sent to the AI provider?**
|
|
340
|
+
Only redacted findings. Account IDs, ARNs, IPs, and emails are stripped before anything leaves your machine. See [Privacy & redaction](#reference).
|
|
341
|
+
|
|
342
|
+
**Do I need Terraform?**
|
|
343
|
+
No. Terraform features activate automatically when KorInfra finds `.tf` files. Cost rules and security scanning work without Terraform.
|
|
344
|
+
|
|
345
|
+
**Does it work with multiple AWS accounts?**
|
|
346
|
+
Not yet — v0.1.0 scans one account at a time. Multi-account aggregation is planned; [follow progress on GitHub](https://github.com/korinfra/korinfra/issues).
|
|
347
|
+
|
|
348
|
+
**What does it cost to run?**
|
|
349
|
+
~$0.02/scan (AWS Cost Explorer) + ~$0.01–0.02 AI with the default Haiku model. Rules-only: $0.00. [Full breakdown →](docs/running-costs.md)
|
|
350
|
+
|
|
351
|
+
**Does it work on Windows?**
|
|
352
|
+
Yes. Node.js ≥ 22 on Windows, macOS, or Linux.
|
|
353
|
+
|
|
354
|
+
**Which AI providers are supported?**
|
|
355
|
+
Claude (Anthropic API) in v0.1.0. OpenAI and Amazon Bedrock support is planned; [follow progress on GitHub](https://github.com/korinfra/korinfra/issues).
|
|
356
|
+
|
|
357
|
+
---
|
|
358
|
+
|
|
359
|
+
## License
|
|
360
|
+
|
|
361
|
+
Apache 2.0 — see [LICENSE](LICENSE).
|
package/bin/korinfra.js
ADDED
package/dist/index.d.mts
ADDED