Skip to content

feat: infracost v2 support — deployml estimate and deployml costs#64

Draft
andrewtclim wants to merge 1 commit into
mainfrom
andrew/infracost-estimate
Draft

feat: infracost v2 support — deployml estimate and deployml costs#64
andrewtclim wants to merge 1 commit into
mainfrom
andrew/infracost-estimate

Conversation

@andrewtclim

Copy link
Copy Markdown

Summary

  • Rewrites infracost.py for infracost v2 (infracost scan / infracost inspect --json — the old infracost breakdown command no longer exists in v2 and was silently failing)
  • Adds deployml estimate: pre-deploy cost prediction from config.yaml, no GCP credentials or infra needed
  • Adds deployml costs: cost check against an existing deployed Terraform workspace
  • Adds deployml doctor auth check (infracost v2 requires an account + infracost auth login)
  • Fixes copy_modules_to_workspace to always include cloud_sql_postgres module when mlflow uses postgresql backend (was silently returning $0)
  • 14 unit tests for infracost.py
  • Simplified docs in costs.md and the Cloud Run tutorial

What the student experience looks like

# Before deploying — no GCP credentials needed
deployml estimate
# → Monthly Cost: $34.55 USD | Cloud SQL: $34.55

# Inline during deploy, before confirmation
# → Deploy stack? Monthly cost: ~$34.55 USD [y/N]:

# After deploying — reads real deployed workspace
deployml costs
# → Monthly Cost: $34.55 USD | Cloud SQL: $34.55

Limitations / future work

deployml estimate and deployml costs read Terraform configs via infracost — accurate for always-on resources (Cloud SQL, VMs) but show $0 for usage-based services (BigQuery, GCS, Cloud Run). A future deployml billing command could query the GCP Cloud Billing API for actual accrued charges.

Test plan

  • pytest tests/test_infracost.py — 14 tests, all passing
  • deployml doctor — shows Infracost installed + authenticated
  • deployml estimate — shows cost from config.yaml without deploying
  • deployml deploy — cost shown inline before confirmation prompt
  • deployml costs — shows cost of running deployment
  • deployml costs with no deployment — helpful error message

🤖 Generated with Claude Code

…sts commands

- Rewrites infracost.py for v2 CLI (scan + inspect --json, dropped deprecated breakdown command)
- Adds deployml estimate: pre-deploy cost prediction from config, no GCP credentials needed
- Adds deployml costs: cost check against live deployed Terraform workspace
- Adds check_infracost_authenticated() with macOS + Linux credential path support
- Fixes copy_modules_to_workspace to include cloud_sql_postgres when mlflow uses postgresql
- Updates deployml doctor to show infracost install + auth status
- Adds 14 unit tests for infracost.py
- Updates docs/features/costs.md and tutorial with estimate/costs commands
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant