infra-cost 1.3.0 → 1.5.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 +168 -23
- package/dist/cli/index.js +1503 -130
- package/dist/index.js +1503 -130
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -309,6 +309,83 @@ infra-cost history --format json > cost-history.json
|
|
|
309
309
|
|
|
310
310
|
---
|
|
311
311
|
|
|
312
|
+
#### `infra-cost terraform` - Terraform Cost Preview (NEW in v1.4.0)
|
|
313
|
+
|
|
314
|
+
**Estimate infrastructure costs BEFORE deploying - shift-left cost management!**
|
|
315
|
+
|
|
316
|
+
```bash
|
|
317
|
+
# Generate terraform plan and estimate costs
|
|
318
|
+
terraform plan -out=tfplan
|
|
319
|
+
infra-cost terraform --plan tfplan
|
|
320
|
+
|
|
321
|
+
# Output:
|
|
322
|
+
# ╭─────────────────────────────────────────────────────────────╮
|
|
323
|
+
# │ Terraform Cost Estimate │
|
|
324
|
+
# ├─────────────────────────────────────────────────────────────┤
|
|
325
|
+
# │ Resources to CREATE: │
|
|
326
|
+
# │ ───────────────────────────────────────────────────────────│
|
|
327
|
+
# │ + aws_instance.web_server (t3.xlarge) │
|
|
328
|
+
# │ └── Monthly: $121.47 | Hourly: $0.1664 │
|
|
329
|
+
# │ + aws_db_instance.primary (db.r5.large, 100GB gp2) │
|
|
330
|
+
# │ └── Monthly: $182.80 | Hourly: $0.25 │
|
|
331
|
+
# ├─────────────────────────────────────────────────────────────┤
|
|
332
|
+
# │ Resources to MODIFY: │
|
|
333
|
+
# │ ───────────────────────────────────────────────────────────│
|
|
334
|
+
# │ ~ aws_instance.api_server │
|
|
335
|
+
# │ └── t3.medium → t3.large: +$30.37/month │
|
|
336
|
+
# ├─────────────────────────────────────────────────────────────┤
|
|
337
|
+
# │ Resources to DESTROY: │
|
|
338
|
+
# │ ───────────────────────────────────────────────────────────│
|
|
339
|
+
# │ - aws_instance.old_server │
|
|
340
|
+
# │ └── Savings: -$60.74/month │
|
|
341
|
+
# ├─────────────────────────────────────────────────────────────┤
|
|
342
|
+
# │ SUMMARY │
|
|
343
|
+
# │ ───────────────────────────────────────────────────────────│
|
|
344
|
+
# │ Current Monthly Cost: $1,240.50 │
|
|
345
|
+
# │ Estimated New Cost: $1,520.83 │
|
|
346
|
+
# │ Difference: +$280.33/month (+22.6%) │
|
|
347
|
+
# │ │
|
|
348
|
+
# │ ⚠️ Cost increase exceeds 20% threshold! │
|
|
349
|
+
# ╰─────────────────────────────────────────────────────────────╯
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
**Usage Examples:**
|
|
353
|
+
|
|
354
|
+
```bash
|
|
355
|
+
# Basic cost estimate
|
|
356
|
+
terraform plan -out=tfplan
|
|
357
|
+
infra-cost terraform --plan tfplan
|
|
358
|
+
|
|
359
|
+
# With cost threshold (fail if > 20% change)
|
|
360
|
+
infra-cost terraform --plan tfplan --threshold 20
|
|
361
|
+
|
|
362
|
+
# JSON format for automation
|
|
363
|
+
infra-cost terraform --plan tfplan --output json
|
|
364
|
+
|
|
365
|
+
# From JSON plan
|
|
366
|
+
terraform show -json tfplan > tfplan.json
|
|
367
|
+
infra-cost terraform --plan tfplan.json
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
**Supported Resources:**
|
|
371
|
+
- ✅ EC2 instances (all types)
|
|
372
|
+
- ✅ RDS instances with storage
|
|
373
|
+
- ✅ EBS volumes (gp2, gp3, io1, io2, st1, sc1)
|
|
374
|
+
- ✅ Load Balancers (ALB, NLB, CLB)
|
|
375
|
+
- ✅ NAT Gateways
|
|
376
|
+
- ✅ ElastiCache clusters
|
|
377
|
+
- ✅ S3 buckets (estimated)
|
|
378
|
+
- ✅ Lambda functions (estimated)
|
|
379
|
+
|
|
380
|
+
**Perfect for:**
|
|
381
|
+
- CI/CD cost gates
|
|
382
|
+
- Preventing expensive deployments
|
|
383
|
+
- Cost-aware infrastructure changes
|
|
384
|
+
- Shift-left FinOps culture
|
|
385
|
+
- Pre-deployment cost reviews
|
|
386
|
+
|
|
387
|
+
---
|
|
388
|
+
|
|
312
389
|
### Command Migration Table
|
|
313
390
|
|
|
314
391
|
| Command Usage | Old Command (v0.x) | New Command (v1.0) |
|
|
@@ -719,48 +796,71 @@ jobs:
|
|
|
719
796
|
--slack-channel ${{ secrets.SLACK_CHANNEL }}
|
|
720
797
|
```
|
|
721
798
|
|
|
722
|
-
## 🤖 GitHub Actions Integration
|
|
799
|
+
## 🤖 GitHub Actions Integration (v1.4.0+)
|
|
723
800
|
|
|
724
|
-
**infra-cost** is available as a GitHub Action
|
|
801
|
+
**infra-cost** is available as a GitHub Action, making it easy to integrate cost analysis into your CI/CD workflows with cost gates and automated PR comments.
|
|
725
802
|
|
|
726
|
-
###
|
|
803
|
+
### Quick Cost Check
|
|
727
804
|
```yaml
|
|
728
805
|
name: Cost Analysis
|
|
729
|
-
on: [
|
|
806
|
+
on: [pull_request]
|
|
730
807
|
|
|
731
808
|
jobs:
|
|
732
|
-
|
|
809
|
+
cost-check:
|
|
733
810
|
runs-on: ubuntu-latest
|
|
734
811
|
steps:
|
|
735
|
-
- uses:
|
|
812
|
+
- uses: actions/checkout@v4
|
|
813
|
+
- uses: codecollab-co/infra-cost@v1.4.0
|
|
736
814
|
with:
|
|
737
815
|
provider: aws
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
816
|
+
command: now
|
|
817
|
+
comment-on-pr: true
|
|
818
|
+
env:
|
|
819
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
741
820
|
```
|
|
742
821
|
|
|
743
|
-
###
|
|
822
|
+
### Cost Gate - Fail on Increase
|
|
744
823
|
```yaml
|
|
745
|
-
name:
|
|
746
|
-
on:
|
|
747
|
-
pull_request:
|
|
748
|
-
branches: [main]
|
|
824
|
+
name: Cost Gate
|
|
825
|
+
on: pull_request
|
|
749
826
|
|
|
750
827
|
jobs:
|
|
751
|
-
cost-
|
|
828
|
+
cost-gate:
|
|
752
829
|
runs-on: ubuntu-latest
|
|
753
|
-
permissions:
|
|
754
|
-
pull-requests: write
|
|
755
830
|
steps:
|
|
756
|
-
- uses:
|
|
831
|
+
- uses: actions/checkout@v4
|
|
832
|
+
- uses: codecollab-co/infra-cost@v1.4.0
|
|
757
833
|
with:
|
|
758
834
|
provider: aws
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
835
|
+
command: now
|
|
836
|
+
fail-on-increase: true # Fail if ANY cost increase
|
|
837
|
+
cost-threshold: 1000 # Fail if monthly cost exceeds $1000
|
|
838
|
+
comment-on-pr: true
|
|
839
|
+
env:
|
|
840
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
841
|
+
```
|
|
842
|
+
|
|
843
|
+
### Terraform Cost Preview (Shift-Left)
|
|
844
|
+
```yaml
|
|
845
|
+
name: Terraform Cost Check
|
|
846
|
+
on: pull_request
|
|
847
|
+
|
|
848
|
+
jobs:
|
|
849
|
+
terraform-cost:
|
|
850
|
+
runs-on: ubuntu-latest
|
|
851
|
+
steps:
|
|
852
|
+
- uses: actions/checkout@v4
|
|
853
|
+
|
|
854
|
+
- name: Terraform Plan
|
|
855
|
+
run: terraform plan -out=tfplan
|
|
856
|
+
|
|
857
|
+
- name: Cost Estimate
|
|
858
|
+
uses: codecollab-co/infra-cost@v1.4.0
|
|
859
|
+
with:
|
|
860
|
+
command: terraform
|
|
861
|
+
additional-args: '--plan tfplan --threshold 20'
|
|
862
|
+
env:
|
|
863
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
764
864
|
```
|
|
765
865
|
|
|
766
866
|
### Daily Cost Report to Slack
|
|
@@ -1063,6 +1163,51 @@ src/
|
|
|
1063
1163
|
- **Note:** VS Code extension will be a separate repository
|
|
1064
1164
|
- Integration points with CLI for cost data
|
|
1065
1165
|
|
|
1166
|
+
### Q2 2026 (v1.4.0 - Phase 3: CI/CD & Shift-Left)
|
|
1167
|
+
|
|
1168
|
+
**Priority: CI/CD Integration & Shift-Left Cost Management**
|
|
1169
|
+
- ✅ **GitHub Actions Integration** (Issue #46)
|
|
1170
|
+
- Native GitHub Action for cost analysis in PRs
|
|
1171
|
+
- Cost gates with fail-on-increase and threshold checks
|
|
1172
|
+
- Enhanced PR comments with cost breakdown
|
|
1173
|
+
- Multiple output variables for downstream jobs
|
|
1174
|
+
- Slack notification support
|
|
1175
|
+
- ✅ **Terraform Cost Preview** (Issue #47)
|
|
1176
|
+
- Parse terraform plan files (binary and JSON)
|
|
1177
|
+
- Estimate costs before deployment
|
|
1178
|
+
- Show create/modify/destroy breakdown
|
|
1179
|
+
- Cost threshold gates for CI/CD
|
|
1180
|
+
- Support for EC2, RDS, EBS, Load Balancers, and more
|
|
1181
|
+
- Monthly and hourly cost estimates
|
|
1182
|
+
- Shift-left cost management
|
|
1183
|
+
|
|
1184
|
+
### Q2 2026 (v1.5.0 - Phase 4: Communication & Collaboration)
|
|
1185
|
+
|
|
1186
|
+
**Priority: Communication & Collaboration**
|
|
1187
|
+
- ✅ **Scheduled Reports with Daemon Mode** (Issue #42)
|
|
1188
|
+
- Built-in scheduler daemon for automated reports
|
|
1189
|
+
- Cron-based scheduling with timezone support
|
|
1190
|
+
- Multiple schedules per instance
|
|
1191
|
+
- Systemd service file generation
|
|
1192
|
+
- Execution logs and status monitoring
|
|
1193
|
+
- ✅ **Microsoft Teams Integration** (Issue #45)
|
|
1194
|
+
- Incoming webhook support with Adaptive Cards
|
|
1195
|
+
- Multiple card styles (compact, detailed, executive)
|
|
1196
|
+
- Cost summaries and alert integration
|
|
1197
|
+
- Chargeback reports for Teams
|
|
1198
|
+
- ✅ **PagerDuty & OpsGenie Integration** (Issue #48)
|
|
1199
|
+
- PagerDuty Events API v2 support
|
|
1200
|
+
- OpsGenie Alert API integration
|
|
1201
|
+
- Severity/priority mapping
|
|
1202
|
+
- Auto-resolve functionality
|
|
1203
|
+
- Deduplication to prevent spam
|
|
1204
|
+
- ✅ **Email Report Scheduling** (Issue #58)
|
|
1205
|
+
- SendGrid and Mailgun support
|
|
1206
|
+
- Beautiful HTML email templates
|
|
1207
|
+
- Multiple recipient support
|
|
1208
|
+
- Scheduler integration for automated emails
|
|
1209
|
+
- Plain text fallback
|
|
1210
|
+
|
|
1066
1211
|
### Q3 2026 (Planned)
|
|
1067
1212
|
|
|
1068
1213
|
**Priority: Enterprise Features**
|