Generate production-ready Terraform configurations for cloud infrastructure with modules, variables, and best practices.
Copy & paste the prompt below into your preferred LLM. Unless a specific AI model is mentioned, you can use whichever you prefer.
You are a cloud infrastructure architect. Generate Terraform configurations for my infrastructure needs. My setup: - Cloud provider: [AWS / GCP / AZURE / MULTI-CLOUD] - What I need: [DESCRIBE THE INFRASTRUCTURE — web app, database, networking, etc.] - Environment: [DEV / STAGING / PRODUCTION / ALL] - Existing infrastructure: [DESCRIBE WHAT EXISTS ALREADY, OR "GREENFIELD"] - Team experience: [NEW TO TERRAFORM / INTERMEDIATE / ADVANCED] - State management: [LOCAL / S3 / TERRAFORM CLOUD / OTHER] Deliver: 1. **Architecture Diagram:** ASCII diagram of the infrastructure being provisioned 2. **File Structure:** Recommended directory layout (modules, environments, shared) 3. **Main Configuration Files:** - main.tf: Core resources with proper naming and tagging - variables.tf: All variables with types, descriptions, defaults, and validation - outputs.tf: Useful outputs for other modules or human reference - providers.tf: Provider configuration with version constraints - backend.tf: Remote state configuration - terraform.tfvars.example: Example variable values 4. **Modules:** Reusable modules for repeated patterns (networking, compute, database, security) 5. **Security Best Practices:** IAM roles (least privilege), security groups, encryption at rest and in transit, secrets management 6. **Cost Optimization:** Right-sizing recommendations, spot instances, reserved capacity notes 7. **CI/CD Pipeline:** GitHub Actions or GitLab CI config for terraform plan/apply workflow 8. **Import Guide:** If migrating existing resources, how to import them into state Infrastructure as code means your infrastructure is reviewable, versionable, and reproducible. Treat it like production code.
The effectiveness of "Terraform Infrastructure Generator" comes from its well-structured structure. By incorporating sequential task breakdown and negative constraints and few-shot examples, it channels the AI's capabilities toward producing exactly what you need. The output you receive will be production-quality code that handles edge cases and follows your stack conventions, ready to use with minimal editing.
These coding tips will help you get stronger results when using "Terraform Infrastructure Generator" and similar prompts in this category.
"Terraform Infrastructure Generator" is particularly useful in these situations. If any of these scenarios sound familiar, this prompt will save you significant time.
When you use "Terraform Infrastructure Generator" with ChatGPT, Claude, or Gemini, here is what to expect in the AI output.
Adapt "Terraform Infrastructure Generator" to your specific situation by modifying these key areas. The more context you add, the better the results.