Create resource on the cloud with natural language using AI-powered Terraform generation
- Natural language-based resource creation
- Support for AWS cloud resources (S3 buckets, EC2 instances, etc.)
- Local infrastructure development using LocalStack
- Component-based infrastructure management
- Interactive chat interface for cloud resources
- Support for multiple infrastructure components
- Self-healing infrastructure creation with automatic error fixing
InfraBot provides a modern, intuitive web interface that makes infrastructure management simple and accessible:
- Natural Language Input: Simply describe your desired infrastructure in plain English
- Real-time Feedback: See your infrastructure being generated and deployed in real-time
- Interactive Chat: Get instant answers about your infrastructure through the built-in chat interface
- Component Management: Easily view, edit, and manage all your infrastructure components
- Visual Feedback: Clear status indicators and progress tracking for all operations
- Error Handling: Intuitive error messages with suggested fixes
Check out our demo video to see InfraBot in action:
- Python 3.10 or higher
- Required packages (to be installed via pip):
pip install infrabot
- Terraform installed:
brew install terraform
- AWS CLI configured:
aws configure
P.S, make sure to configure the default region as well.
- OpenAI API key:
export OPENAI_API_KEY='your_api_key_here'
- For local development:
docker pull localstack/localstack docker run -d -p 4566:4566 localstack/localstack
You can run InfraBot UI using Docker with a single command. This is the recommended way to get started quickly:
docker run -p 8000:8000 -p 5000:5000 \
-e AWS_ACCESS_KEY_ID=<your_aws_access_key> \
-e AWS_SECRET_ACCESS_KEY=<your_aws_secret_key> \
-e AWS_REGION=<your_aws_region> \
-e PERPLEXITY_API_KEY=<your_perplexity_api_key> \
-e OPENAI_API_KEY=<your_openai_api_key> \
--platform linux/amd64 alaeddineabdessalem/infrabot:latestAWS_ACCESS_KEY_ID: Your AWS access keyAWS_SECRET_ACCESS_KEY: Your AWS secret keyAWS_REGION: Your AWS region (e.g., us-east-1)PERPLEXITY_API_KEY: Your Perplexity API key (recommended for better infrastructure generation)OPENAI_API_KEY: Your OpenAI API key (required for auxiliary tasks)
8000: Main InfraBot UI5000: Additional services
- The Docker image is built for linux/amd64 platform
- It's recommended to use both Perplexity API and OpenAI API for optimal performance
- The container includes all necessary dependencies and Terraform
Initialize a new project:
infrabot init [--verbose] [--local]Create a new component:
infrabot component create --prompt "Your infrastructure description" --name component-name [--verbose] [--force] [--model MODEL_NAME] [--self-healing] [--max-attempts N] [--keep-on-failure]Delete all components:
infrabot component delete [--force]Destroy all components infrastructure:
infrabot component destroy [--force]Edit a component:
infrabot component edit component-nameChat about your infrastructure:
infrabot chat component-nameCheck InfraBot version:
infrabot version- Initialize a new project:
infrabot init- Create a web server component with self-healing:
infrabot component create --prompt "Create an EC2 instance with nginx installed" --name web-server --self-healing- Create a local S3 bucket for testing:
infrabot component create --prompt "Create an S3 bucket" --name test-bucket --local- Create a database component with custom retry attempts:
infrabot component create --prompt "Set up an RDS instance for PostgreSQL" --name database --self-healing --max-attempts 5- Chat about your infrastructure:
infrabot chat web-serverWhen you initialize a project, InfraBot creates a .infrabot directory with the following structure:
.infrabot/
└── default/
├── backend.tf
├── provider.tf
├── component1.tf
├── component2.tf
└── ...
Each component is stored as a separate Terraform file in the workspace directory.
InfraBot includes a self-healing feature that automatically fixes Terraform errors during resource creation:
- Enable with
--self-healingflag - Set maximum retry attempts with
--max-attempts N(default: 3) - Uses AI to analyze errors and fix configuration issues
- Maintains original infrastructure intent while resolving dependencies
- Shows detailed fix explanations for transparency
- Use
--keep-on-failureto preserve generated Terraform files even when errors occur (useful for debugging)
Example with self-healing:
infrabot component create \
--prompt "Create a highly available EC2 setup with auto-scaling" \
--name ha-web \
--self-healing \
--max-attempts 5 \
--keep-on-failureIf Terraform encounters errors during plan or apply:
- InfraBot analyzes the error output
- AI suggests fixes while preserving the original intent
- Retries the operation with fixed configuration
- Continues until success or max attempts reached
- If
--keep-on-failureis set, preserves the generated Terraform files for inspection even if errors occur
InfraBot supports observability and monitoring of AI interactions through Langfuse:
-
Install Langfuse:
pip install langfuse
-
Set up Langfuse credentials:
export LANGFUSE_PUBLIC_KEY='your_public_key' export LANGFUSE_SECRET_KEY='your_secret_key'
-
All AI interactions are automatically logged to your Langfuse dashboard
InfraBot supports multiple AI models for infrastructure generation through LiteLLM integration. While OpenAI is the default provider, you can use other models by setting the appropriate API key and specifying the model:
Note: Even when using alternative models, the OPENAI_API_KEY environment variable is still required for certain auxiliary tasks within InfraBot.
export GROQ_API_KEY='your_api_key'
infrabot component create \
--name eks-cluster-1 \
--prompt "create an EKS cluster named MyKubernetesCluster" \
--self-healing \
--model "groq/deepseek-r1-distill-llama-70b"export PERPLEXITY_API_KEY='your_api_key'
infrabot component create \
--name eks-cluster-1 \
--prompt "create an EKS cluster named MyKubernetesCluster" \
--self-healing \
--model "perplexity/sonar-pro"Recommendation: We recommend using the
perplexity/sonar-promodel for its enhanced factuality and accuracy in infrastructure generation.
The --model flag allows you to specify which model to use for infrastructure generation. Make sure to set the corresponding API key as an environment variable before running the command.
InfraBot supports all models available through LiteLLM (see LiteLLM Documentation), including but not limited to:
- OpenAI (default), for instance:
gpt-4o,o3-mini - Groq, for instance:
groq/deepseek-r1-distill-llama-70b - Perplexity, for instance:
perplexity/sonar-pro - Anthropic, for instance:
anthropic/claude-3-5-sonnet - Google VertexAI
- AWS Bedrock
- Azure OpenAI
- Hugging Face
- And many more
Each provider requires its own API key to be set as an environment variable. Common examples:
OPENAI_API_KEYfor OpenAI models (required for all setups)GROQ_API_KEYfor Groq modelsPERPLEXITY_API_KEYfor Perplexity modelsANTHROPIC_API_KEYfor Anthropic modelsAZURE_API_KEYfor Azure OpenAI models
Refer to the LiteLLM documentation for the complete list of supported models and their corresponding environment variables.
InfraBot is a service that allows you to create and manage infrastructure components using natural language. It leverages AI to convert your text prompts into Terraform code, which can then be used to provision cloud resources.
This documentation is specifically for frontend developers who need to integrate with the InfraBot API.
To run the InfraBot server, use the following command:
uvicorn infrabot.service:app --host 127.0.0.1 --port 8000Before running the server, ensure you have set up the required environment variables:
# Required
export OPENAI_API_KEY='your_api_key_here'
# Optional (for alternative models)
export GROQ_API_KEY='your_api_key' # If using Groq models
export PERPLEXITY_API_KEY='your_api_key' # If using Perplexity models
export ANTHROPIC_API_KEY='your_api_key' # If using Anthropic models
# Optional (for monitoring)
export LANGFUSE_PUBLIC_KEY='your_public_key'
export LANGFUSE_SECRET_KEY='your_secret_key'You can also run InfraBot as a Docker container:
docker run -p 8000:8000 \
-e OPENAI_API_KEY=your_openai_api_key \
-e AWS_ACCESS_KEY_ID=your_aws_access_key \
-e AWS_SECRET_ACCESS_KEY=your_aws_secret_key \
-e AWS_REGION=your_preferred_region \
alaeddineabdessalem/infrabotThe server will be accessible at http://localhost:8000.
The InfraBot service exposes the following RESTful API endpoints:
Initialize a new InfraBot project with Terraform configuration.
Endpoint: POST /init
Request Body:
{
"workdir": ".infrabot/default", // Working directory for the project (optional)
"verbose": false, // Show detailed initialization steps (optional)
"local": false // Use localstack for infrastructure (optional)
}Response:
{
"success": true,
"message": "Project initialized successfully",
"workdir": ".infrabot/default"
}Create a new infrastructure component based on a natural language prompt.
Endpoint: POST /component/create
Request Body:
{
"prompt": "Create an S3 bucket with versioning enabled", // Required: Natural language description
"name": "main", // Component name (optional)
"model": "gpt-4o", // AI model to use (optional)
"self_healing": false, // Auto-fix terraform errors (optional)
"max_attempts": 3, // Max healing attempts (optional)
"keep_on_failure": false, // Keep files if error occurs (optional)
"langfuse_session_id": null, // Session ID for tracking (optional)
"workdir": ".infrabot/default" // Working directory (optional)
}Response:
{
"success": true,
"error_message": "",
"component_name": "main",
"terraform_code": "resource \"aws_s3_bucket\" \"example\" { ... }",
"tfvars_code": "bucket_name = \"my-example-bucket\"",
"plan_summary": "1 resource to add, 0 to change, 0 to destroy",
"outputs": {
"bucket_name": "my-example-bucket",
"bucket_arn": "arn:aws:s3:::my-example-bucket"
},
"self_healing_attempts": 0,
"fixed_errors": []
}List all InfraBot projects in a specified directory.
Endpoint: GET /projects
Query Parameters:
parent_dir(optional): Directory to scan for InfraBot projects. Default is "."
Response:
{
"success": true,
"message": "Found 2 InfraBot projects",
"projects": [
"/path/to/project1",
"/path/to/project2"
]
}curl -X POST "http://localhost:8000/init" \
-H "Content-Type: application/json" \
-d '{
"workdir": "service_test/.infrabot/default",
"verbose": true
}'curl -X POST "http://localhost:8000/component/create" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Create an S3 bucket called demo-bucket",
"name": "demo-s3-bucket",
"model": "perplexity/sonar-pro",
"self_healing": true,
"max_attempts": 3,
"keep_on_failure": true,
"workdir": "
service_test/.infrabot/default"
}'curl -X GET "http://localhost:8000/projects?parent_dir=./"The API returns appropriate HTTP status codes and error messages:
200 OK: The request was successful400 Bad Request: The request was invalid (check the error message)500 Internal Server Error: An unexpected error occurred on the server
When an error occurs, the response will include a detailed error message explaining what went wrong.
- All API endpoints accept and return JSON data.
- For long-running operations (like component creation), consider implementing loading states and error handling in your UI.
- The component creation process may take some time, especially for complex infrastructure.
- The
terraform_codeandtfvars_codefields in the response can be displayed in a code editor for review. - The
plan_summaryfield provides a human-readable summary of what changes would be made, which is useful for displaying to users.

