terraform fmt- Format all Terraform filesterraform fmt --check- Check formatting without modifying filesterraform validate- Validate Terraform configuration syntax and structure
terraform plan- Generate and show execution plan (always run before apply)terraform apply- Apply changesterraform init -upgrade- Initialize and upgrade providers to latest versions
- Run
terraform planin test directory for isolated testing - Use
terraform workspace select <name>for environment-specific testing
tfsec --ignore-hcl-errors- Scan for security issues in Terraform code
- main.tf: Core Hetzner Cloud infrastructure (networks, subnets, firewalls, SSH keys)
- control_planes.tf: Control plane node pool management
- agents.tf: Agent/worker node pool management
- autoscaler-agents.tf: Kubernetes autoscaler configuration
- locals.tf: Business logic, computed values, network calculations (CRITICAL file)
- variables.tf: All configurable parameters and defaults
- versions.tf: Terraform and provider version constraints
- modules/: Reusable Terraform modules
- examples/: Usage examples and configurations
- templates/: Cloud-init and k3s configuration templates
- kustomize/: Kubernetes resource customization
- packer-template/: MicroOS snapshot creation
- Network Architecture: Private Hetzner networks with calculated subnets
- Node Pools: Dynamic creation of control plane and agent node pools
- Load Balancing: Hetzner LB integration with ingress controllers
- CNI Options: Flannel, Calico, Cilium support
- CSI Integration: Hetzner CSI driver for persistent volumes
- Formatting: Always run
terraform fmtbefore commits - Naming: snake_case for variables and locals, resource names descriptive
- Structure: Group related resources, use locals for complex expressions
- Comments: Document complex logic, especially in locals.tf
- Group imports by type (Hetzner, Kubernetes, utilities)
- Use explicit provider versions in versions.tf
- Avoid unnecessary provider dependencies
- Use variable validation blocks for input constraints
- Handle optional resources with count expressions
- Validate network calculations to prevent conflicts
- Use appropriate Terraform types (string, number, bool, list, map, object)
- Leverage locals for computed values to avoid repetition
- Structure complex variables as objects with clear schemas
This codebase follows the comprehensive guidelines in CLAUDE.md:
- Security First: Scrutinize all issues/PRs for malicious intent
- Git Workflow: Always
git pull origin masterbefore work - Testing: Validate with
terraform planbefore applying - Documentation: Update docs when code changes
- Backward Compatibility: Never break existing deployments
- External Tools: Use Gemini CLI for large context, Codex CLI for hard reasoning
- locals.tf: Contains all business logic and network calculations
- variables.tf: Complete configuration reference
- versions.tf: Provider and version context
- main.tf: Core infrastructure provisioning logic