Overview
Terrateam Self-Hosted is the on-premise, privately hosted version of Terrateam.
Prerequisites
Before you begin, ensure you have the following:
- Docker
- Docker Compose
Step 1: Create a Private Terrateam GitHub Application
Terrateam Self-Hosted requires a new Terrateam GitHub application to be created.
1. Clone the terrateamio/terrateam
repository:
2. Start the setup
container:
3. Navigate to http://localhost:3000 and follow the setup instructions.
Step 2: Deploy the Terrateam Server
Choose one of the following deployment methods based on your requirements and infrastructure setup:
Option 1: Docker Compose
1. Save your private Terrateam GitHub application settings file to .env
in your terrateam/docker/terrat
directory next to docker-compose.yml
:
Your .env
file should look like this but with actual values:
2. Register an Ngrok account and create an auth token.
3. Start Terrateam:
5. When the Terrateam server starts up, it will try to update the GitHub application Webhook URL using the Ngrok endpoint, which in turn populates the TERRAT_API_BASE environment variable. To disable, set the GITHUB_WEBHOOK_URL_UPDATE environment variable to FALSE.
Option 2: Kubernetes
1. Source your private Terrateam GitHub application settings file:
2. Create your Terrateam private GitHub application secrets:
3. Create your Terrateam database password secret:
4. Add the Terrateam Helm repository:
5. Install the Helm chart based on your specific setup:
GKE with an HTTPS load balancer and managed certificate
- Create a global static IP address:
- Show the IP:
- Add the global static IP to a DNS zone you control, for example, as terrateam.example.com
- Install the Helm chart:
Using Google-managed SSL certificates with Ingress can take up to 60 minutes to configure. The Ingress can be in a ready state while the certificate is still in the provisioning state.
Without Ingress
You can use NGINX-ingress and cert-manager to expose the terrateam-server
service.
Custom
Specify a custom my-values.yaml
for installation:
6. When the Terrateam server starts up, it will try to update the GitHub application Webhook URL using the Helm chart value server.dns_name
, which in turn populates the TERRAT_API_BASE
environment variable. To disable, set the GITHUB_WEBHOOK_URL_UPDATE
environment variable to FALSE
.
Option 3: Manual Instructions
Components
Terrateam consists of two components:
- Terrateam server ghcr.io/terrateamio/terrat-oss:latest
- PostgreSQL database (at least v14)
PostgreSQL Database
Set the host auth method to md5
Create the Terrateam database
Set the password authentication method
Create the Terrateam user
Environment Variables
Set the following environment variables in the Terrateam server container:
Key | Description |
---|---|
DB_HOST | Database host |
DB_NAME | Database name |
DB_PORT | Database port |
DB_USER | Database user |
DB_PASS | Database password |
GITHUB_APP_ID | Github application id |
TERRAT_API_BASE | Terrateam public-facing URL including a trailing /api e.g. https://terrateam.example.com/api |
GITHUB_APP_CLIENT_ID | GitHub application client id |
GITHUB_APP_CLIENT_SECRET | GitHub application client secret |
GITHUB_APP_PEM | GitHub application PEM |
GITHUB_WEBHOOK_SECRET | GitHub application webhook secret |
Docker Run
Webhook URL
When the Terrateam server starts up, it will try to update the GitHub application Webhook URL
using the TERRAT_API_BASE
environment variable. To disable, set the GITHUB_WEBHOOK_URL_UPDATE
environment variable to FALSE
.
Step 3: Install the Terrateam GitHub Application
1. Navigate to the GitHub application settings page for your Terrateam GitHub application.
2. Click “Install App” and select the repositories you want to use with Terrateam.
3. Click “Install” to complete the installation.
Step 4: Start Using Terrateam
Terrateam is now set up and ready to use with your Terraform and OpenTofu repositories. Navigate to our Quickstart Guide Step 2 for next steps.
Troubleshooting
If you encounter any issues during the installation process, refer to the following troubleshooting tips:
- Ensure that your Terrateam server is running and accessible from the internet.
- Double-check that your GitHub application settings are correct and match the values in your Terrateam server environment variables.
- Verify that your database connection string is correct and that the Terrateam user has the necessary permissions.
- Check the logs of your Terrateam server for any error messages or warnings.
- Make sure you’ve installed your private GitHub application after the Terrateam server is successfully up and running.
If you’re still having trouble, reach out to the Terrateam support team or community for assistance.
Frequently Asked Questions
How Does Terrateam Self-Hosted Interact with My Source Code?
Terrateam never stores source code and never clones repositories. Terrateam uses the GitHub API to retrieve source code and interact with the repository.
Does the Terrateam Server Work with GitHub Enterprise Server?
Yes. To use Terrateam with GitHub Enterprise Server, set the following environment variables:
Is the Terrateam Server Horizontally Scalable?
Yes. Add as many Terrateam servers as you want as long as they’re all pointing to the same database.