Docs/Tools/Terraform
IaC

terraform_gen.py

Copies the correct cloud template to the output directory, substitutes variables, generates a terraform.tfvars file, then runs terraform fmt and terraform validate automatically.

What it does

Selects the right template directory from templates/terraform/<cloud>/, substitutes placeholder tokens throughout all .tf files, and writes 7 split files to the output directory.

Template variables substituted: {{SERVICE_NAME}}, {{REGION}}, {{ENVIRONMENT}}, {{CLUSTER_NAME}}.

CLI Usage
bash
python3 tools/terraform_gen.py \
  --cloud aws \
  --service payment-api \
  --use-case web_app \
  --region us-east-1 \
  --env dev
Cloud Options
--cloudResources provisioned
awsEKS + ECR + RDS + VPC
azureAKS + ACR + PostgreSQL Flexible Server
gcpGKE Autopilot + Artifact Registry + Cloud SQL
Use Case Options
web_appmicroservicebatch_jobdata_pipelinescheduled_task
Generated Files
versions.tfRequired provider version constraints
providers.tfProvider configuration blocks
variables.tfInput variable declarations
locals.tfComputed local values and name prefixes
backend.tfRemote state backend (commented — see bootstrap note)
main.tfCore resource definitions
outputs.tfOutput values exposed after apply
Remote State Backends
awsS3 + DynamoDB lock table
azureAzure Storage Account + container
gcpGCS bucket

backend.tf is generated with the remote state block commented out. Bootstrap the state bucket/container first, then uncomment and run terraform init.

Post-generation (automatic)

After writing all .tf files, the tool runs terraform fmt to normalise formatting, then terraform validate -backend=false to catch syntax and type errors without requiring real cloud credentials.

Next step: Helm →