iac-gen-cli
v1.0.0
Published
Generate Terraform and Ansible from natural language using AI
Downloads
147
Maintainers
Readme
iac-gen-cli
Generate Terraform HCL and Ansible playbooks from natural language using AI.
A CLI companion to the IaC Generator web app, powered by Groq's llama-3.3-70b-versatile model.
Installation
npm install -g iac-gen-cliOr run without installing:
npx iac-gen-cli "create an S3 bucket with versioning"Setup
Get a free API key from console.groq.com, then export it:
export GROQ_API_KEY=your_key_hereAdd it to your shell profile (~/.bashrc, ~/.zshrc) to persist it.
Usage
iac-gen <description> [options]
Arguments:
description Natural language description of the infrastructure to generate
Options:
-c, --cloud <cloud> Target cloud provider: aws, gcp, azure (default: "aws")
-o, --output <file> Write output to a file instead of stdout
-f, --format <format> Output format: terraform, ansible (default: "terraform")
-v, --version Print the current version
-h, --help Display helpExamples
Generate Terraform for AWS
iac-gen "create an S3 bucket with versioning enabled" --cloud awsWrite output to a file
iac-gen "deploy a GKE cluster with 3 nodes" --cloud gcp --output cluster.tfGenerate for Azure
iac-gen "create a virtual network with two subnets" --cloud azure --output network.tfGenerate an Ansible playbook
iac-gen "install and configure nginx with SSL" --format ansible --output nginx.ymlCombine flags
iac-gen "nginx on EC2 behind an ALB" --cloud aws --format terraform --output ec2-alb.tfEnvironment Variables
| Variable | Description |
|---|---|
| GROQ_API_KEY | Groq API key (preferred) |
| IAC_GEN_API_KEY | Alternative env var name |
Output behavior
- Without
--output: prints generated code to stdout (pipe-friendly) - With
--output <file>: writes to the specified file, confirms path on stderr - Spinner and status messages always go to stderr so stdout stays clean
Pipe-friendly usage
Since all status output goes to stderr, you can safely pipe stdout:
iac-gen "RDS PostgreSQL instance" --cloud aws > database.tfLicense
MIT — see LICENSE
