← Back to all products
$29
Terraform Starter
Production-ready Terraform modules for cloud infrastructure with state management.
PythonMarkdownJSONTerraformAWS
Product Preview
Try the interactive reader and demo tools below, or get the full product with all content unlocked.
Interactive Reader (Free Preview) ⚙ Try Demo Tools Download Free SampleFile Structure 13 files
terraform-starter/
├── LICENSE
├── README.md
├── examples/
│ └── infra_spec.json
├── free-sample.zip
├── guide/
│ ├── 01_features.md
│ ├── 02_configuration-reference.md
│ └── 03_generated-files.md
├── index.html
├── interactive.html
├── src/
│ ├── __pycache__/
│ │ └── terraform_generator.cpython-312.pyc
│ └── terraform_generator.py
└── tests/
└── test_terraform_generator.py
Documentation Preview README excerpt
Terraform Starter
Part of the Deploy Kit by CodeVault
Scaffold production-ready Terraform configurations from a simple JSON infrastructure spec. Generates provider setup, VPC networking, compute instances, databases, and S3-compatible storage — all with best-practice module structure.
Features
- Generate Terraform configs for AWS-style infrastructure (provider-agnostic patterns)
- Scaffolds complete module structure:
main.tf,variables.tf,outputs.tf,terraform.tfvars - VPC/networking with public and private subnets
- Compute instances with configurable size and count
- RDS-style database resources with secure defaults
- S3-compatible storage buckets with versioning and encryption
- Environment-specific
tfvarsfiles (dev, staging, production) - Remote state backend configuration
- Validates your infrastructure spec before generating
- Python stdlib only — zero dependencies
Quick Start
# Generate Terraform configs from the example spec
python src/terraform_generator.py --config examples/infra_spec.json
# Write to a target directory
python src/terraform_generator.py --config examples/infra_spec.json --output-dir ./terraform/
# Generate only specific components
python src/terraform_generator.py --config examples/infra_spec.json --components vpc,compute
# Validate config without generating
python src/terraform_generator.py --config examples/infra_spec.json --validate-only
Configuration Reference
Create a JSON file with these fields:
| Field | Type | Required | Description |
|---|---|---|---|
project_name | string | Yes | Project name (used in resource naming) |
region | string | No | Cloud region (default: us-east-1) |
provider | string | No | Cloud provider: aws (default: aws) |
environments | array | No | Environments to generate tfvars for |
vpc | object | No | VPC config: cidr, public_subnets, private_subnets |
compute | object | No | Compute config: instance_type, count, ami |
database | object | No | DB config: engine, instance_class, allocated_storage |
storage | object | No | S3 config: bucket_name, versioning, encryption |
state_backend | object | No | Remote state: bucket, key, dynamodb_table |
tags | object | No | Default tags applied to all resources |
CLI Reference
| Flag | Description |
|---|---|
--config, -c | Path to the JSON infrastructure spec (required) |
--output-dir, -o | Directory to write Terraform files (default: stdout preview) |
--components | Comma-separated list of components to generate |
--validate-only | Only validate config, don't generate |
... continues with setup instructions, usage examples, and more.
Code Sample .py preview
src/terraform_generator.py
#!/usr/bin/env python3
"""
Terraform Config Generator — Deploy Kit by DataNest
Scaffold production-ready Terraform configurations from a JSON infrastructure
specification. Generates provider setup, VPC networking, compute instances,
databases, and S3-compatible storage with best-practice module structure.
Why this exists:
Starting a Terraform project from scratch means writing dozens of
boilerplate HCL files, remembering all the required provider arguments,
and setting up remote state. This tool scaffolds all of it from a single
JSON spec, with sensible defaults and extensive comments explaining
every resource block.
Usage:
python terraform_generator.py --config infra.json
python terraform_generator.py --config infra.json --output-dir ./terraform/
python terraform_generator.py --config infra.json --components vpc,compute
License: MIT
"""
from __future__ import annotations
import argparse
import json
import logging
import sys
from dataclasses import dataclass, field
from pathlib import Path
from typing import Any
# ---------------------------------------------------------------------------
# Constants
# ---------------------------------------------------------------------------
VALID_COMPONENTS = {"vpc", "compute", "database", "storage"}
VALID_DB_ENGINES = {"postgres", "mysql", "mariadb"}
LOG = logging.getLogger("terraform-generator")
# ---------------------------------------------------------------------------
# Data Models
# ---------------------------------------------------------------------------
@dataclass
class VpcConfig:
"""VPC/networking configuration."""
# ... 837 more lines ...