Infrastructure as Code with Terraform for AWS/Hetzner
Automated cloud infrastructure provisioning with Terraform, reusable modules, and state management.
Automate provisioning of all infrastructure required for a production application, ensuring reproducibility, version control, and compliance.
At a glance
Access
Free prompt
Open to copy without upgrading.
Prompt objective
Automate provisioning of all infrastructure required for a production application, ensuring reproducibility, version control, and compliance.
Real use case
A fintech company provisions servers manually through the AWS console. After a key infrastructure engineer departed, the team lacks visibility into what is actually running. They have [NUMBER] EC2 instances, [NUMBER] RDS databases, [NUMBER] S3 buckets, and [NUMBER] VPCs all configured manually. They need to document and automate everything.
Customize these fields first
Replace the placeholders with your own context before you run the prompt. That usually improves the first output more than adding more instructions later.
Prompt
Create infrastructure as code with Terraform for [PROJECT NAME], deployed on [AWS/HETZNER/GCP].\\\\\\\\n\\\\\\\\n**Target Architecture:**\\\\\\\\n- Compute: [EC2/ECS/HETZNER CLOUD] — [NUMBER] instances\\\\\\\\n- Database: [RDS POSTGRESQL/HETZNER + DOCKER]\\\\\\\\n- Cache: [ELASTICACHE REDIS/SELF-HOSTED]\\\\\\\\n- Storage: [S3/HETZNER STORAGE BOX]\\\\\\\\n- CDN: [CLOUDFRONT/CLOUDFLARE]\\\\\\\\n- DNS: [ROUTE53/CLOUDFLARE]\\\\\\\\n- Network: VPC with public and private subnets\\\\\\\\n\\\\\\\\n**1) Terraform Project Structure:**\\\\\\\\n\\\\\\\\\\\\\\\\\\\\\\\`\\\\\\\\\\\\\\\\\\\\\\\`\\\\\\\\\\\\\\\\\\\\\\\`\\\\\\\\nterraform/\\\\\\\\n├── environments/\\\\\\\\n│ ├── staging/\\\\\\\\n│ │ ├── main.tf\\\\\\\\n│ │ ├── variables.tf\\\\\\\\n│ │ └── terraform.tfvars\\\\\\\\n│ └── production/\\\\\\\\n├── modules/\\\\\\\\n│ ├── networking/\\\\\\\\n│ ├── compute/\\\\\\\\n│ ├── database/\\\\\\\\n│ ├── cache/\\\\\\\\n│ └── monitoring/\\\\\\\\n└── global/\\\\\\\\n ├── iam/\\\\\\\\n └── dns/\\\\\\\\n\\\\\\\\\\\\\\\\\\\\\\\`\\\\\\\\\\\\\\\\\\\\\\\`\\\\\\\\\\\\\\\\\\\\\\\`\\\\\\\\n\\\\\\\\n**2) Reusable Modules:**\\\\\\\\nFor each module, define: variables, resources, outputs, README\\\\\\\\n\\\\\\\\n- **networking**: VPC, subnets (public/private), NAT Gateway, security groups\\\\\\\\n- **compute**: instances/containers, auto-scaling, load balancer, target groups\\\\\\\\n- **database**: RDS/PostgreSQL with read replica, automated backups, parameter group\\\\\\\\n- **cache**: Redis cluster with failover\\\\\\\\n- **monitoring**: CloudWatch alarms, SNS topics, dashboards\\\\\\\\n\\\\\\\\n**3) State Management:**\\\\\\\\n- Remote state in S3 + DynamoDB lock (AWS) or Terraform Cloud\\\\\\\\n- State per environment (staging/production)\\\\\\\\n- Import existing resources (\\\\\\\\\\\\\\\\\\\\\\\`terraform import\\\\\\\\\\\\\\\\\\\\\\\`)\\\\\\\\n- Safe state manipulation (move, remove)\\\\\\\\n\\\\\\\\n**4) Security:**\\\\\\\\n- IAM roles with least privilege\\\\\\\\n- Restrictive security groups\\\\\\\\n- Encryption at rest (KMS)\\\\\\\\n- Secrets in AWS Secrets Manager (not in terraform.tfvars)\\\\\\\\n- VPC endpoints for AWS services\\\\\\\\n\\\\\\\\n**5) CI/CD for Terraform:**\\\\\\\\n- GitHub Action: \\\\\\\\\\\\\\\\\\\\\\\`plan\\\\\\\\\\\\\\\\\\\\\\\` on PR, \\\\\\\\\\\\\\\\\\\\\\\`apply\\\\\\\\\\\\\\\\\\\\\\\` on merge to main\\\\\\\\n- Validation: \\\\\\\\\\\\\\\\\\\\\\\`terraform fmt\\\\\\\\\\\\\\\\\\\\\\\`, \\\\\\\\\\\\\\\\\\\\\\\`terraform validate\\\\\\\\\\\\\\\\\\\\\\\`, \\\\\\\\\\\\\\\\\\\\\\\`tflint\\\\\\\\\\\\\\\\\\\\\\\`\\\\\\\\n- Cost estimation with Infracost\\\\\\\\n- Manual approval before apply in production\\\\\\\\n\\\\\\\\n**6) Cost Estimate:**\\\\\\\\n- Monthly cost per resource\\\\\\\\n- Optimizations: Reserved Instances, Spot for workers, S3 lifecycle\\\\\\\\n- Comparison: AWS vs. Hetzner for this workload\\\\\\\\n\\\\\\\\nProvide complete \\\\\\\\\\\\\\\\\\\\\\\`.tf\\\\\\\\\\\\\\\\\\\\\\\` files for the [PRODUCTION/STAGING] environment.
Open directly in an AI — the text is pre-filled:
How to use this prompt
- 1Replace the key placeholders first: PROJECT NAME, AWS/HETZNER/GCP, EC2/ECS/HETZNER CLOUD, NUMBER.
- 2Replace any bracketed placeholders like [this] with your own context.
- 3Add extra background information when you want more tailored results.
- 4Combine multiple prompts in one conversation when you need a richer output.
- 5Save your best-performing prompts so they are easy to reuse later.
Next best step
Open the guide first, then branch only if you still need more.
A guide for technical builders choosing between prompts, coding workflows, and agent-based implementation.
If this prompt is close but not quite right, generate variants next. If the job is recurring, move into the course library after the guide.
Related prompts
View allComplete CI/CD Pipeline with GitHub Actions for Next.js Applications
Automated pipeline configuration with tests, build, preview deploys, and production deployment.
Best for
Automate the entire software delivery lifecycle with GitHub Actions, from push to production deployment, including tests, code analysis, and preview environments.
Docker Containerization and Docker Compose Orchestration for Production
Optimized Dockerfiles and docker-compose for development and production environments.
Best for
Create a containerized environment that ensures parity between development and production, with optimized builds, multi-stage builds, and security configurations.
Monitoring and Observability Setup with Grafana, Prometheus, and Alerts
Complete monitoring stack setup with metrics, logs, and alerts for production applications.
Best for
Implement full observability that detects issues before users notice them, with actionable dashboards and intelligent alerting.
Incident Response Playbook for Engineering Teams
Structured process for detection, response, communication, and postmortem for production incidents.
Best for
Establish a clear incident response process that minimizes detection and resolution time (MTTR), protects user experience, and generates learnings for the team.
Explore other prompt categories
Move sideways into adjacent libraries when the current category is not the full answer.
Free browsing stays open. Premium prompts unlock the reusable workflow layer.
Use the guides and role paths to validate the job first. Upgrade when you want the full prompt text, editable premium prompts, and the surrounding course paths in one place.
Free access
- Browse guides, role paths, and category pages.
- Preview prompts before you decide to upgrade.
- Find the right starting point without friction.
Membership access
- Unlock premium prompts and the full copy text.
- See more workflow paths and course connections.
- Keep the reusable templates in one place.