Terraform Template Repository
Template repository for Terraform projects with CI/CD pipeline.
Pipeline Stages
- Lint & Validate - Format check and syntax validation
- Security Scan - Checkov and tfsec security scanning
- Plan - Terraform init and plan with artifact upload
- Apply - Apply with manual approval (production environment)
- Destroy - Manual destroy with special approval (production-destroy environment)
Setup
-
Update workflow variables (
.gitea/workflows/terraform.yml):- Line 23:
TF_VERSION- Your Terraform version - Line 24:
WORKING_DIR- Path to your Terraform code
- Line 23:
-
Configure provider credentials (lines 103-113):
- Uncomment your cloud provider (AWS/Azure/GCP)
- Add secrets to repository: Settings → Secrets → Actions
-
Create environments (Settings → Environments):
production- For apply operations (add reviewers)production-destroy- For destroy operations (add senior reviewers)
-
Add your Terraform code to
./terraform/directory
Required Secrets
AWS:
AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEY
Azure:
ARM_CLIENT_IDARM_CLIENT_SECRETARM_SUBSCRIPTION_IDARM_TENANT_ID
Backend (optional):
BACKEND_ACCESS_KEYBACKEND_SECRET_KEY
Usage
- Push to main/develop → Runs lint, security, plan
- Create PR to main → Runs full pipeline, posts plan as comment
- Manual trigger → Actions tab → Run workflow → Select action (plan/apply/destroy)
Description