Terraform configuration to provision the infrastructure required to deploy Gogs (Go Git Service) using Infrastructure as Code (IaC).
This repository contains Terraform code to provision the infrastructure required to run Gogs in a reproducible, automated, and scalable way.
Main goals of this project:
- Apply Infrastructure as Code best practices
- Separate environments (dev / prod)
- Use reusable Terraform modules
- Prepare the infrastructure for configuration with Ansible
- Enable CI/CD integration (e.g. Jenkins)
gogs-tf/
├── environments/
│ ├── dev/
│ └── prod/
├── modules/
│ ├── network/
│ ├── compute/
│ └── security/
├── .gitignore
└── README.md
Contains environment-specific Terraform configurations.
Each environment includes:
main.tf
variables.tf
outputs.tf
terraform.tfvars
backend.hcl
Examples:
- dev: development environment
- prod: production environment
Reusable Terraform modules that define infrastructure components such as:
- Networking (VPC, subnets, routing)
- Compute resources (EC2 instances)
- Security (Security Groups, IAM roles)
Modules are called from the environments layer.
Example usage:
module "network" {
source = "../../modules/network"
vpc_cidr = var.vpc_cidr
}Before using this project, make sure you have:
- Terraform
- Git
- Cloud provider credentials (e.g. AWS)
- Environment variables or credential files properly configured
git clone https://github.com/GeraldOpitz/gogs-tf.git
cd gogs-tf
git checkout GOGS-5-Terraform-Infrastructure-as-Codeterraform initterraform plan -var-file="environments/dev/terraform.tfvars"terraform apply -var-file="environments/dev/terraform.tfvars"terraform destroy -var-file="environments/dev/terraform.tfvars"- Infrastructure as Code (IaC)
- Environment separation (dev / prod)
- Modular Terraform architecture
- Ready for automation and CI/CD pipelines
This repository is part of a larger Gogs deployment stack:
- Terraform: infrastructure provisioning
- Ansible: configuration management
- Gogs: self-hosted Git service
- Jenkins: CI/CD automation