Skip to content

suresh-subramanian2013/Cloud-Terraform-Generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 

Repository files navigation

☁️ Cloud Terraform Generator

AI-Powered Infrastructure-as-Code Generator using Google Gemini API

Generate production-ready Terraform code for AWS, Azure, and GCP in seconds! This tool leverages Google's Gemini AI to create complete, well-structured Terraform configurations based on your requirements.

Version License HTML JavaScript

🌟 Features

  • 🎯 Multi-Cloud Support: Generate Terraform code for AWS, Azure, and GCP
  • πŸ€– AI-Powered: Uses Google Gemini API for intelligent code generation
  • πŸ“¦ Complete Structure: Generates all necessary Terraform files
  • ✨ Best Practices: Follows Terraform and cloud provider best practices
  • πŸ”’ Security-First: Includes security considerations and recommendations
  • πŸ“± Single File: Entire application in one HTML file - no installation needed
  • πŸ’Ύ Export Ready: Copy individual files or download complete bundle
  • 🎨 Modern UI: Beautiful, responsive interface with cloud-themed design

πŸ“‹ Generated Files

The tool generates a complete Terraform project structure:

terraform-project/
β”œβ”€β”€ provider.tf              # Cloud provider configuration
β”œβ”€β”€ variables.tf             # Input variables with descriptions
β”œβ”€β”€ main.tf                  # Main resource definitions
β”œβ”€β”€ outputs.tf               # Output values
β”œβ”€β”€ terraform.tfvars.example # Example variable values
└── README.md                # Project documentation

πŸš€ Quick Start

Prerequisites

  1. Gemini API Key (Free)

    • Visit Google AI Studio
    • Sign in with your Google account
    • Click "Create API Key"
    • Copy the generated key
  2. Web Browser

    • Any modern browser (Chrome, Firefox, Safari, Edge)

Usage

  1. Open the Tool

    # Simply open the HTML file in your browser
    open terraform-generator.html
    # or double-click the file
  2. Enter Your API Key

    • Paste your Gemini API key in the first field
  3. Select Cloud Provider

    • Click on AWS, Azure, or GCP card
  4. Specify Services

    Examples:
    AWS:   ec2, rds, s3, vpc, lambda
    Azure: vm, sql-database, storage-account, vnet
    GCP:   compute-instance, cloud-sql, storage-bucket, vpc
    
  5. Add Requirements (Optional)

    Examples:
    - Use t3.micro for EC2 instances
    - Enable encryption at rest
    - Deploy in us-east-1 region
    - Add tags for production environment
    - Use multi-AZ for RDS
    
  6. Generate Code

    • Click "πŸš€ Generate Terraform Code"
    • Wait for AI to generate your infrastructure code
    • Review, copy, or download the generated files

πŸ’‘ Example Use Cases

Example 1: Basic AWS Infrastructure

Input:

  • Cloud: AWS
  • Services: ec2, vpc, security-group
  • Requirements: t3.micro instance, allow SSH from my IP

Output: Complete Terraform code with VPC, subnet, security group, and EC2 instance

Example 2: Azure Web Application

Input:

  • Cloud: Azure
  • Services: app-service, sql-database, storage-account
  • Requirements: Standard tier, West Europe region, backup enabled

Output: Full Azure infrastructure for web app with database and storage

Example 3: GCP Data Pipeline

Input:

  • Cloud: GCP
  • Services: compute-instance, cloud-sql, storage-bucket, pubsub
  • Requirements: n1-standard-2, PostgreSQL 14, us-central1

Output: Complete GCP data infrastructure with compute, database, and messaging

🎯 Supported Services

AWS

  • Compute: EC2, Lambda, ECS, EKS, Auto Scaling
  • Storage: S3, EBS, EFS
  • Database: RDS, DynamoDB, ElastiCache, Redshift
  • Networking: VPC, Route53, CloudFront, API Gateway
  • Security: IAM, KMS, Secrets Manager, WAF

Azure

  • Compute: Virtual Machines, App Service, AKS, Functions
  • Storage: Storage Account, Blob Storage, File Storage
  • Database: SQL Database, Cosmos DB, MySQL, PostgreSQL
  • Networking: Virtual Network, Load Balancer, Application Gateway
  • Security: Key Vault, Active Directory, Security Center

GCP

  • Compute: Compute Engine, GKE, Cloud Functions, Cloud Run
  • Storage: Cloud Storage, Persistent Disk
  • Database: Cloud SQL, Firestore, Bigtable, Spanner
  • Networking: VPC, Cloud Load Balancing, Cloud CDN
  • Security: IAM, KMS, Secret Manager

πŸ› οΈ Technical Details

Architecture

User Input β†’ Gemini API β†’ AI Processing β†’ Terraform Code Generation β†’ Structured Output

Technology Stack

  • Frontend: HTML5, CSS3, Vanilla JavaScript (ES6+)
  • AI Model: Google Gemini (2.0-flash, 1.5-flash, 1.5-pro)
  • Fonts: Inter (UI), JetBrains Mono (Code)
  • API: Google Generative AI SDK

Model Fallback Strategy

The tool attempts multiple Gemini models in order:

  1. gemini-2.0-flash-exp (Latest experimental)
  2. gemini-2.0-flash (Latest stable)
  3. gemini-1.5-flash (Fast and efficient)
  4. gemini-1.5-pro (Most capable)

If one model fails, it automatically tries the next one.

πŸ“– Best Practices

Input Tips

  1. Be Specific: Include instance types, regions, and sizing requirements
  2. Use Standard Names: Stick to official service names (e.g., "ec2" not "virtual machine" for AWS)
  3. Add Context: Mention environment (dev/staging/prod) for appropriate configurations
  4. Security First: Request encryption, IAM roles, and security groups explicitly

Output Usage

  1. Review Generated Code: Always review before applying
  2. Customize Variables: Adjust terraform.tfvars.example for your environment
  3. Test in Dev First: Deploy to development environment before production
  4. Version Control: Commit generated code to Git
  5. State Management: Configure remote state (S3, Azure Storage, GCS)

πŸ”’ Security Considerations

  • API Key: Your Gemini API key is used only in your browser, never stored
  • Generated Code: Review security groups, IAM policies, and encryption settings
  • Secrets: Never commit terraform.tfvars with real credentials to Git
  • State Files: Use remote state with encryption and access controls

πŸ› Troubleshooting

Common Issues

Issue: "All models failed" error

  • Solution: Check your API key is valid and has quota remaining
  • Visit Google AI Studio to verify

Issue: Generated code has syntax errors

  • Solution: Try regenerating with more specific requirements
  • Simplify your service list and add requirements one at a time

Issue: Missing services in output

  • Solution: Use official service names (check supported services list)
  • Be explicit about all required resources

Issue: Code doesn't match cloud provider

  • Solution: Ensure you selected the correct cloud provider card
  • Verify service names are appropriate for that provider

πŸ“š Learning Resources

Terraform

Cloud Providers

Gemini API

🀝 Contributing

Contributions are welcome! Here are some ideas:

  • Add support for more cloud providers (Oracle Cloud, DigitalOcean)
  • Implement Terraform module generation
  • Add syntax highlighting for code blocks
  • Create preset templates for common architectures
  • Add validation for generated code
  • Implement direct GitHub export

πŸ“ License

MIT License - feel free to use this tool for personal or commercial projects.

πŸ™ Acknowledgments

  • Google Gemini: For providing the AI capabilities
  • HashiCorp: For creating Terraform
  • Cloud Providers: AWS, Azure, and GCP for their excellent documentation

πŸ“ž Support

  • Issues: Found a bug? Open an issue on GitHub
  • Questions: Need help? Check the troubleshooting section
  • Feature Requests: Have an idea? Submit a feature request

πŸ—ΊοΈ Roadmap

  • Add Terraform Cloud integration
  • Support for Terragrunt configurations
  • Multi-region deployments
  • Cost estimation integration
  • Terraform plan preview
  • Export to GitHub repository
  • Template library for common patterns
  • Kubernetes manifest generation
  • Ansible playbook generation

πŸ“Š Version History

v1.0 (Current)

  • Initial release
  • Multi-cloud support (AWS, Azure, GCP)
  • Complete Terraform file generation
  • Modern UI with copy/download features
  • Model fallback strategy
  • Production-ready code generation

Built with ❀️ for the DevOps community

Making Infrastructure-as-Code accessible to everyone!

About

AI-Powered Infrastructure as Code Generator

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages