Contributing¶
Guidelines for contributing to this Terraform repository.
Branching Strategy¶
All changes must go through feature branches and pull requests.
Critical Rule
Never commit directly to the main branch. All changes must be made via pull requests.
Branch Naming¶
Use descriptive branch names with a type prefix:
| Prefix | Purpose | Example |
|---|---|---|
feat/ | New features | feat/add-rds-module |
fix/ | Bug fixes | fix/s3-encryption-config |
chore/ | Maintenance tasks | chore/update-provider-version |
docs/ | Documentation changes | docs/update-usage-guide |
refactor/ | Code restructuring | refactor/simplify-locals |
Workflow¶
-
Create a feature branch from
main: -
Implement changes following the commit conventions
-
Run pre-commit hooks before pushing:
-
Push and create a pull request:
-
Wait for CI/CD checks to pass
-
Merge after approval
Pull Request Process¶
PR Requirements¶
- Descriptive title following conventional commit format
- Clear description of changes and motivation
- All CI/CD checks passing
- At least one approval (for team repositories)
Automated Checks¶
The following checks run automatically on pull requests:
- Pre-commit CI (formatting, validation, linting, security)
- Terraform documentation generation
- Checkov security scanning
- Gitleaks secret detection
- Infracost cost estimation
- PR title linting
Review Guidelines¶
When reviewing Terraform PRs, check for:
- Security: No hardcoded secrets, encryption enabled, public access restricted
- Naming: Resources follow the
{prefix}-{env}-{type}-{name}pattern - Variables: All variables are typed and documented
- Outputs: All outputs have descriptions
- Modules: Reusable modules used where appropriate
- Cost: Review Infracost estimates for unexpected costs
Code Style¶
Terraform Conventions¶
- Use
snake_casefor all resource, variable, output, and local names - Include descriptions for all variables and outputs
- Use type constraints for all variables
- Prefer
localsfor computed values and repeated expressions - Keep resources organized: one primary resource type per file for complex modules
File Organization¶
Follow the standard Terraform file structure:
versions.tf # Version constraints and backend
providers.tf # Provider configuration
variables.tf # Input variables
locals.tf # Local values
main.tf # Resource definitions
outputs.tf # Output values
data.tf # Data sources (if needed)
Formatting¶
Terraform formatting is enforced automatically:
- Pre-commit hooks run
terraform fmt - CI/CD checks validate formatting
- Use 2-space indentation (enforced by
.editorconfig)