AdvancedDevOpsFree prompt

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 — no account or payment needed.

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

PROJECT NAMEAWS/HETZNER/GCPEC2/ECS/HETZNER CLOUDNUMBERRDS POSTGRESQL/HETZNER + DOCKERELASTICACHE REDIS/SELF-HOSTEDS3/HETZNER STORAGE BOXCLOUDFRONT/CLOUDFLARE

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].

**Target Architecture:**
- Compute: [EC2/ECS/HETZNER CLOUD] — [NUMBER] instances
- Database: [RDS POSTGRESQL/HETZNER + DOCKER]
- Cache: [ELASTICACHE REDIS/SELF-HOSTED]
- Storage: [S3/HETZNER STORAGE BOX]
- CDN: [CLOUDFRONT/CLOUDFLARE]
- DNS: [ROUTE53/CLOUDFLARE]
- Network: VPC with public and private subnets

**1) Terraform Project Structure:**
```
terraform/
├── environments/
│   ├── staging/
│   │   ├── main.tf
│   │   ├── variables.tf
│   │   └── terraform.tfvars
│   └── production/
├── modules/
│   ├── networking/
│   ├── compute/
│   ├── database/
│   ├── cache/
│   └── monitoring/
└── global/
    ├── iam/
    └── dns/
```

**2) Reusable Modules:**
For each module, define: variables, resources, outputs, README

- **networking**: VPC, subnets (public/private), NAT Gateway, security groups
- **compute**: instances/containers, auto-scaling, load balancer, target groups
- **database**: RDS/PostgreSQL with read replica, automated backups, parameter group
- **cache**: Redis cluster with failover
- **monitoring**: CloudWatch alarms, SNS topics, dashboards

**3) State Management:**
- Remote state in S3 + DynamoDB lock (AWS) or Terraform Cloud
- State per environment (staging/production)
- Import existing resources (`terraform import`)
- Safe state manipulation (move, remove)

**4) Security:**
- IAM roles with least privilege
- Restrictive security groups
- Encryption at rest (KMS)
- Secrets in AWS Secrets Manager (not in terraform.tfvars)
- VPC endpoints for AWS services

**5) CI/CD for Terraform:**
- GitHub Action: `plan` on PR, `apply` on merge to main
- Validation: `terraform fmt`, `terraform validate`, `tflint`
- Cost estimation with Infracost
- Manual approval before apply in production

**6) Cost Estimate:**
- Monthly cost per resource
- Optimizations: Reserved Instances, Spot for workers, S3 lifecycle
- Comparison: AWS vs. Hetzner for this workload

Provide complete `.tf` files for the [PRODUCTION/STAGING] environment.

Open directly in an AI — the text is pre-filled:

How to use this prompt

  1. 1Replace the key placeholders first: PROJECT NAME, AWS/HETZNER/GCP, EC2/ECS/HETZNER CLOUD, NUMBER.
  2. 2Replace any bracketed placeholders like [this] with your own context.
  3. 3Add extra background information when you want more tailored results.
  4. 4Combine multiple prompts in one conversation when you need a richer output.
  5. 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 all

Explore other prompt categories

Move sideways into adjacent libraries when the current category is not the full answer.

Every prompt here is free. The course teaches the thinking behind them.

Copy as many prompts as you like. When you want to move from single prompts to a repeatable AI workflow, Learn AI in 30 Days walks through it, one day at a time.

Get the courseSee the 30-day curriculum first

Buy the course once ($15/$20 by length), or go all-access for $10/mo with a verifiable certificate.