Multi-agent CLI that generates Terraform and deploys full-stack apps to AWS/GCP free tier
Project description
InfraGen
Describe your app in plain English. Get it running on the AWS or GCP free tier.
InfraGen is a multi-agent CLI that generates Terraform from natural language, audits every resource against free-tier limits before anything is created, shows you exactly what will happen, and — after you confirm — provisions the infrastructure and deploys your code onto it.
$ infragen deploy
detected: react frontend at ./frontend; fastapi backend at ./backend
free-tier eligible instance type: t3.micro
tf_write: attempt 1 generated 219 lines of HCL
guardrail: PASS, 0 warning(s)
validate: PASS
+--------------------------- review before deploy ---------------------------+
| terraform plan: 10 to add, 0 to change, 0 to destroy |
| aws_instance.backend (created) |
| aws_s3_bucket.frontend (created) ... |
| free tier: all resources within free tier limits |
| deploy steps: |
| 1. build frontend (react) |
| 2. upload frontend to s3://... |
| 3. copy backend code to ubuntu@... |
| 4. install dependencies and start fastapi on port 8000 |
| estimated monthly cost: $0.00 (free tier) |
+----------------------------------------------------------------------------+
Deploy this? [y/N]: y
...
deployment complete
frontend_website_url = http://my-app.s3-website-us-east-1.amazonaws.com
backend_public_ip = 54.12.34.56
Why InfraGen?
Free-tier users get surprise bills from two things: resources that were never free (NAT gateways, oversized instances) and forgotten resources left running. InfraGen guards both ends:
- A deterministic free-tier auditor checks every generated resource against hardcoded limit tables. An LLM can overlook a paid instance type; a dict lookup cannot. Ask for a
db.r5.xlargeand you get adb.t3.microwith a comment explaining the substitution. infragen destroytears down everything it created from tracked state, in one command.- The review gate is backed by real
terraform planoutput — never by an AI's summary of what it intended to do.
1. Installation
pip install infragen
# or, isolated (recommended for CLI tools):
pipx install infragen
Requirements — bring your own accounts, InfraGen ships no credentials:
| Requirement | Where to get it |
|---|---|
| Python 3.11+ | https://python.org |
| Terraform CLI | https://developer.hashicorp.com/terraform/install |
| Groq API key (free, no credit card) | https://console.groq.com/keys |
AWS account + CLI (aws configure), or GCP account + CLI (gcloud auth login) |
https://aws.amazon.com/free / https://cloud.google.com/free |
Set your Groq key — either per project or globally:
# per project: a .env file in your project folder
echo GROQ_API_KEY=gsk_your_key_here > .env
# or globally, once:
echo GROQ_API_KEY=gsk_your_key_here > ~/.infragen.env
Keep the key private. Never commit
.envto git.
Then verify everything is ready:
infragen doctor
This checks terraform, your Groq key, AWS/GCP authentication, and (optionally) tflint, and tells you how to fix anything missing.
2. Deploy an app
From your project root:
infragen deploy # scan, generate, review, confirm, deploy
infragen deploy --dry-run # everything except apply - inspect first, great for CI
infragen deploy --provider gcp # target Google Cloud instead of AWS
infragen deploy --regenerate # force fresh Terraform (default reuses .infragen/main.tf)
What it does, step by step:
- Scans your codebase — detects React/Vue/Next/static frontends (via
package.json), FastAPI/Flask/Django backends (viarequirements.txtand entry-point detection), build commands, ports, and Dockerfiles. - Checks your account — queries which instance types are actually free-tier eligible for your AWS account (eligibility varies by account age since AWS's 2025 free-tier change).
- Generates Terraform — an LLM agent writes HCL; a deterministic guardrail audits it;
terraform validatechecks it. Failures loop back to the writer with the errors (max 3 attempts). - Shows the review panel — the real
terraform plandiff, free-tier status per resource, the exact deploy steps, and the cost ($0.00 or it doesn't pass). - On your "y" — applies the Terraform, then deploys code: builds and syncs the frontend to S3/GCS, copies the backend to the instance over ssh, installs dependencies in a venv, starts the server, and verifies it responds before reporting success.
- Writes docs — a README in
.infragen/describing what's deployed, its URLs, and how to clean up.
Supported app shapes (any combination):
| Your app | AWS | GCP |
|---|---|---|
| Static frontend (React/Vue/Next/plain HTML) | S3 static website | Cloud Storage website |
| Python backend (FastAPI/Flask/Django) | EC2 (free-tier instance) | Compute Engine e2-micro |
Everything generated lives in .infragen/ inside your project — Terraform, state, deploy steps, docs. Re-running infragen deploy updates the same stack (it will not duplicate resources), so deploying a code change is just: edit code, run infragen deploy, confirm.
3. Tear it down
infragen destroy # lists every resource, asks for confirmation
infragen destroy --yes # skip the prompt
Empties S3/GCS buckets first (a non-empty bucket would otherwise block deletion), then destroys everything in state. Free-tier hours are finite — never leave a test instance running.
4. Other commands
infragen # interactive REPL: describe infra, get audited Terraform
infragen explain ./main.tf # plain-English explanation of any Terraform file/dir
infragen translate ./ --to gcp # convert AWS Terraform to GCP (or --to aws), audited
infragen validate ./ # terraform validate + free-tier audit + tflint
infragen doctor # check prerequisites
The REPL is for infrastructure without a codebase — describe what you want and get validated, free-tier-audited HCL saved to .infragen/:
infragen> create an S3 bucket with versioning for app assets
infragen> a lambda function behind API gateway with a dynamodb table
infragen> exit
Try asking for something expensive — create a db.r5.xlarge postgres RDS — and watch it substitute the free-tier equivalent instead of refusing or obeying.
5. Troubleshooting
| Symptom | Fix |
|---|---|
infragen is not recognized as a command |
pip's scripts folder isn't on PATH. Use python -m infragen instead, or install with pipx install infragen (puts CLIs on PATH reliably), or add the folder printed by python -c "import sysconfig; print(sysconfig.get_path('scripts'))" to your PATH |
| Red "setup required" panel | Follow its instructions — missing Groq key or cloud CLI auth |
| ssh/scp step fails right after first deploy | The instance may still be booting (~90s). Re-run infragen deploy — it's idempotent |
BACKEND_FAILED + log tail in the start step |
Your app crashed on the server; the tail of app.log is printed — fix and redeploy |
| Deploy succeeded but app changed since | Just run infragen deploy again — infra stays, code re-deploys |
| Want to start over completely | infragen destroy, delete .infragen/, then infragen deploy --regenerate |
How it works (for the curious)
A LangGraph state machine drives generation, running on Groq's free LLM tier (openai/gpt-oss-120b, with live model-availability checks since Groq rotates models). The design rule throughout: anything safety- or correctness-critical is deterministic code — LLMs only generate and explain. The free-tier auditor is an HCL parser plus rule tables. The deployment steps are built from your scanned app spec plus real terraform outputs. The review panel parses actual terraform plan text. The server-start step curls the app from inside the instance and refuses to report success if it doesn't answer.
Development
git clone https://github.com/adityapanyala/infragen.git
cd infragen
pip install -e ".[dev]"
python -m pytest tests/ -q # 30 tests, no API key or network needed
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file infragen-0.1.1.tar.gz.
File metadata
- Download URL: infragen-0.1.1.tar.gz
- Upload date:
- Size: 40.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b82d72c0dd9be45f5244ff15401278b41b420ec123cb2e5ae531ddc03ab9bbb
|
|
| MD5 |
4b6418f24ae3949f425d9c248dcff101
|
|
| BLAKE2b-256 |
c2548731786ac23fd3c39a6ef7ce1f2580644f5ca79c9cd2158dd37c4addce6f
|
File details
Details for the file infragen-0.1.1-py3-none-any.whl.
File metadata
- Download URL: infragen-0.1.1-py3-none-any.whl
- Upload date:
- Size: 40.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ffb0f8cb6f53f3268419fee58bb6343812aef5bb9b203634167102afd0e2df3d
|
|
| MD5 |
6e811d7fed85c57884b1d8a5d1ded866
|
|
| BLAKE2b-256 |
64e683b2cd9c6d2e5c036a0bd3cdcc55589846d9e794a13101aa80e4aae64a41
|