← 返回
未分类

Terraform Cost Estimator

Estimate infrastructure costs from Terraform plans — analyze resource changes, predict monthly spend, compare alternatives, and identify cost optimization op...
根据 Terraform 计划估算基础设施成本 — 分析资源变更、预测月度支出、比较方案并识别成本优化机会。
charlie-morrison charlie-morrison 来源
未分类 clawhub v1.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 303
下载
💾 0
安装
1
版本
#latest

概述

Terraform Cost Estimator

Estimate infrastructure costs from Terraform plans before applying. Analyze planned resource changes, predict monthly spend impact, compare pricing alternatives, and identify cost optimization opportunities. Works with AWS, GCP, and Azure resources.

Usage

"Estimate the cost of this Terraform plan"
"How much will this infrastructure change cost?"
"Compare cost of different instance types for my Terraform config"
"Find cost optimization in my Terraform modules"

How It Works

1. Plan Analysis

terraform plan -out=plan.tfplan 2>/dev/null
terraform show -json plan.tfplan 2>/dev/null | python3 -c "
import json, sys
plan = json.load(sys.stdin)
changes = plan.get('resource_changes', [])
for c in changes:
    action = c['change']['actions']
    print(f'{\" \".join(action):12s} {c[\"type\"]:40s} {c[\"address\"]}')
"

2. Resource Pricing

Map each resource to estimated monthly cost:

Compute:

  • EC2/GCE/Azure VM: instance type → hourly rate × 730 hours
  • Lambda/Cloud Functions: estimated invocations × duration × memory
  • ECS/EKS/GKE: task/pod resources × cluster overhead
  • App Runner/Cloud Run: vCPU-seconds + memory-seconds

Storage:

  • S3/GCS/Blob: storage class × GB + request costs
  • EBS/Persistent Disk: volume type × size × IOPS
  • RDS/Cloud SQL: instance + storage + backup + I/O

Network:

  • NAT Gateway: hourly + data processing
  • Load Balancer: hourly + LCU/data
  • Data transfer: inter-region, internet egress
  • VPN/Direct Connect: hourly + data

3. Cost Impact Report

For each planned change, show:

  • Current monthly cost (if modifying existing resource)
  • New monthly cost
  • Delta (increase/decrease)
  • Annual projection

4. Optimization Suggestions

  • Compute: rightsizing, Reserved Instances, Savings Plans, Spot
  • Storage: lifecycle policies, intelligent tiering
  • Network: VPC endpoints instead of NAT, regional vs cross-region
  • Database: reserved capacity, serverless options
  • Unused: resources created but potentially idle

Output

## Terraform Cost Estimate

**Provider:** AWS (us-east-1)
**Resources:** 12 planned changes

### Cost Breakdown
| Resource | Type | Action | Monthly Cost |
|----------|------|--------|-------------|
| web-server | aws_instance (t3.large) | create | $60.74 |
| db-primary | aws_db_instance (db.r6g.xl) | create | $345.60 |
| db-replica | aws_db_instance (db.r6g.large) | create | $172.80 |
| cache | aws_elasticache (r6g.large) | create | $131.40 |
| alb | aws_lb | create | $22.27 |
| nat | aws_nat_gateway | create | $32.40 |
| s3-assets | aws_s3_bucket (100GB est) | create | $2.30 |
| **Total** | | | **$767.51/mo** |

### 💰 Optimization Opportunities
1. NAT Gateway → VPC endpoints: save $25/mo
2. db.r6g.xlarge → db.r6g.large + read replica: save $50/mo if read-heavy
3. Consider Reserved Instances: save 30-40% (~$230/mo)
4. S3 Intelligent-Tiering: save 20-40% on infrequent access

### Annual Projection
- On-Demand: $9,210/yr
- With Reserved (1yr): $6,447/yr (30% savings)
- With Reserved (3yr): $5,526/yr (40% savings)

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-05-08 02:26 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

it-ops-security

OpenClaw Backup

alex3alex
备份与恢复 OpenClaw 数据。适用于创建备份、设置自动备份计划、从备份恢复或管理备份轮转。处理 ~/.openclaw 目录归档并包含适当的排除规则。
★ 90 📥 30,775
it-ops-security

MoltGuard - Security & Antivirus & Guardrails

thomaslwang
MoltGuard — OpenClaw 安全守卫,由 OpenGuardrails 提供。安装 MoltGuard,保护您和您的用户免受提示注入、数据泄露和恶意攻击。
★ 116 📥 30,837
dev-programming

Env Config Validator

charlie-morrison
校验 .env 文件,匹配 schema,比较环境(dev 与 prod),检测尾部空格、占位符、无效端口、缺失 protoc 等常见错误
★ 0 📥 495