Skip to main content

Self-Service Infrastructure Templating Engine for Terraform & Terragrunt

Project description

๐Ÿ”จ Stack Forge

CI Python 3.12+ License: MIT Code style: ruff

Self-Service Infrastructure Templating Engine for Terraform & Terragrunt

A CLI tool that generates production-ready Terraform and Terragrunt configurations from reusable templates. Stop writing boilerplate infrastructure code and start deploying in minutes.

โšก 30-Second Quick Start

git clone https://github.com/pt1691/stack-forge.git && cd stack-forge
python3 -m venv .venv && source .venv/bin/activate
pip install -e .
forge list-templates  # See available templates!

That's it! Now create your first infrastructure:

mkdir my-infra && cd my-infra
forge init --name my-app --org mycompany
forge add-stack --name network --env dev
forge add-resource --stack network --name main-vpc --type vpc
forge generate  # Creates Terraform files!

โœจ Features

  • ๐Ÿš€ Quick Setup - Generate complete infrastructure stacks with a few commands
  • ๐Ÿ“ฆ Pre-built Templates - VPC, EKS, S3, RDS, Lambda, and more
  • ๐Ÿ”ง Terragrunt Support - DRY configurations with Terragrunt integration
  • ๐Ÿท๏ธ Consistent Tagging - Automatic resource tagging across all resources
  • ๐Ÿ”’ Security Best Practices - Templates follow AWS security guidelines
  • ๐Ÿ“ Customizable - Extend with your own templates

๐Ÿš€ Installation

git clone https://github.com/pt1691/stack-forge.git
cd stack-forge
python3 -m venv .venv
source .venv/bin/activate
pip install -e .

๐Ÿ“– Workflow Example

# 1. Create a new project
mkdir my-platform && cd my-platform
forge init --name my-platform --org acmecorp

# 2. Add a stack (environment + resource group)
forge add-stack --name network --env dev

# 3. Add resources to the stack
forge add-resource --stack network --name main-vpc --type vpc
forge add-resource --stack network --name logs --type s3_bucket

# 4. Generate Terraform files
forge generate

# 5. Review what was created
tree infrastructure/

๐Ÿ“‹ Commands

Command Description
forge init Initialize a new Stack Forge project
forge add-stack Add a new infrastructure stack
forge add-resource Add a resource to a stack
forge generate Generate Terraform/Terragrunt files
forge show Show project configuration
forge validate Validate configuration
forge list-templates List available templates

๐Ÿ“ฆ Available Templates

Template Description
vpc VPC with public/private subnets, NAT gateways, flow logs
s3_bucket S3 bucket with versioning, encryption, lifecycle rules
eks EKS cluster with managed node groups, IRSA, encryption
rds RDS instance with Multi-AZ, automated backups
dynamodb DynamoDB table with auto-scaling
lambda Lambda function with IAM role, CloudWatch logs
iam_role IAM role with customizable policies
security_group Security group with configurable rules
secrets_manager Secrets Manager with rotation
ecr ECR repository with lifecycle policies

๐Ÿ“ Generated Structure

infrastructure/
โ”œโ”€โ”€ network/
โ”‚   โ”œโ”€โ”€ providers.tf          # AWS provider configuration
โ”‚   โ”œโ”€โ”€ backend.tf            # S3 backend for state
โ”‚   โ”œโ”€โ”€ main.tf               # Module calls
โ”‚   โ”œโ”€โ”€ terragrunt.hcl        # Terragrunt configuration
โ”‚   โ””โ”€โ”€ modules/
โ”‚       โ”œโ”€โ”€ main-vpc/
โ”‚       โ”‚   โ”œโ”€โ”€ main.tf
โ”‚       โ”‚   โ”œโ”€โ”€ variables.tf
โ”‚       โ”‚   โ””โ”€โ”€ outputs.tf
โ”‚       โ””โ”€โ”€ logs/
โ”‚           โ”œโ”€โ”€ main.tf
โ”‚           โ”œโ”€โ”€ variables.tf
โ”‚           โ””โ”€โ”€ outputs.tf

โš™๏ธ Configuration (forge.yaml)

version: "1.0"
name: my-platform
organization: mycompany
default_provider: aws
default_region: us-west-2
environments:
  - dev
  - staging
  - prod

stacks:
  - name: network
    environment: dev
    region: us-west-2
    use_terragrunt: true
    resources:
      - name: main-vpc
        type: vpc
        variables:
          vpc_cidr: "10.0.0.0/16"
          az_count: 3
          enable_nat_gateway: true
          
      - name: logs
        type: s3_bucket
        variables:
          versioning_enabled: true

๐Ÿ”ง Custom Templates

Add your own templates in ~/.stack-forge/templates/:

~/.stack-forge/templates/
โ””โ”€โ”€ my_custom_resource/
    โ”œโ”€โ”€ main.tf.j2
    โ”œโ”€โ”€ variables.tf.j2
    โ””โ”€โ”€ outputs.tf.j2

Templates use Jinja2 with these available variables:

  • {{ name }} - Resource name
  • {{ environment }} - Environment (dev/staging/prod)
  • {{ region }} - AWS region
  • {{ variables }} - Resource-specific variables
  • {{ tags }} - Merged tags

๐Ÿ“ Best Practices

  1. Use environments - Create separate stacks for dev/staging/prod
  2. DRY with Terragrunt - Enable use_terragrunt: true for DRY configs
  3. Consistent naming - Use descriptive stack and resource names
  4. Tag everything - Define global_tags in your project config

๐Ÿงช Development

# Install dev dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Run linter
ruff check .

๐Ÿ“ License

MIT License - see LICENSE for details.

๐Ÿ™‹โ€โ™‚๏ธ Author

Praneeth Turlapati


โญ If you find this useful, please star the repository!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stack_forge_infra-0.1.0.tar.gz (32.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

stack_forge_infra-0.1.0-py3-none-any.whl (40.8 kB view details)

Uploaded Python 3

File details

Details for the file stack_forge_infra-0.1.0.tar.gz.

File metadata

  • Download URL: stack_forge_infra-0.1.0.tar.gz
  • Upload date:
  • Size: 32.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for stack_forge_infra-0.1.0.tar.gz
Algorithm Hash digest
SHA256 72098a28c47a3ca3e240581cf5375cc0133a21fa565ad3d27a5c9b4ab30c112a
MD5 cf18eae996988ea7b763fd5501b5c845
BLAKE2b-256 1cfa131bffd2054dff55582e955453b02574a16950a044830cef87998bb98448

See more details on using hashes here.

Provenance

The following attestation bundles were made for stack_forge_infra-0.1.0.tar.gz:

Publisher: release.yml on pt1691/stack-forge

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file stack_forge_infra-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for stack_forge_infra-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 040f0b1745c284454f6cbd4564ed8f903b62cc6c8d6e2496268f509f16806769
MD5 e97a8e059a5530a1bb4875af361719c2
BLAKE2b-256 38c759c30c78795d0d67d36ad3099aa6d52863304d80aa510563b5589ea839b1

See more details on using hashes here.

Provenance

The following attestation bundles were made for stack_forge_infra-0.1.0-py3-none-any.whl:

Publisher: release.yml on pt1691/stack-forge

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page