{"id":21359902,"url":"https://github.com/ujstor/coolify-hetzner-terraform","last_synced_at":"2026-01-02T08:35:49.240Z","repository":{"id":218007788,"uuid":"743830205","full_name":"Ujstor/coolify-hetzner-terraform","owner":"Ujstor","description":"Deploy Coolify self hosted service on Hetzner with Terraform","archived":false,"fork":false,"pushed_at":"2024-03-25T23:38:46.000Z","size":9,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-22T18:51:52.724Z","etag":null,"topics":["coolify","hetzner","self-hosted"],"latest_commit_sha":null,"homepage":"https://coolify.io/","language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Ujstor.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-16T04:37:08.000Z","updated_at":"2025-01-09T12:21:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"0b8b789c-d6a3-494f-9603-778d1b5bcaec","html_url":"https://github.com/Ujstor/coolify-hetzner-terraform","commit_stats":null,"previous_names":["ujstor/coolify-hetzner-terraform"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ujstor%2Fcoolify-hetzner-terraform","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ujstor%2Fcoolify-hetzner-terraform/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ujstor%2Fcoolify-hetzner-terraform/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ujstor%2Fcoolify-hetzner-terraform/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ujstor","download_url":"https://codeload.github.com/Ujstor/coolify-hetzner-terraform/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243835939,"owners_count":20355609,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["coolify","hetzner","self-hosted"],"created_at":"2024-11-22T05:30:30.705Z","updated_at":"2026-01-02T08:35:49.203Z","avatar_url":"https://github.com/Ujstor.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Self hosted Coolify instance on Hetzner with Terraform\n\nDeploy [Coolify](https://coolify.io/docs/) on Hetzner Cloud using the Terraform. This project aims to create a highly optimized, auto-upgradable, highly available and cost-effective self hosted Coolify instance for deployng your projects on Hetzner Cloud.\n\nDefault configuration will create a one server in Falkenstein Germnay with 2 VCPU, 4 GB RAM, 40 GB disk space, 20TB out traffic for 5.77EUR/month. Change configuration to your needs in `variables.tf` file, see Additional Configuration\n\n## Prerequisites\n\nBefore you begin, ensure you have the following:\n\n- A Hetzner Cloud account. You can sign up [here](https://hetzner.cloud/?ref=Ix9xCKNxJriM) (free €⁠20 in cloud credits for new users)\n- [Terraform](https://www.terraform.io/downloads.html) command-line tool installed\n \n Install Terraform:\n\n```bash\nwget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg\necho \"deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main\" | sudo tee /etc/apt/sources.list.d/hashicorp.list\nsudo apt update \u0026\u0026 sudo apt install terraform\n```\n\n## Deployment Steps\n\n### 1. Generate Hetzner API Token\n\nCreate new project in Hetzner console https://console.hetzner.cloud/projects \n\nObtain API token from Hetzner console that will be used by Terraform to interact with the platform. \nNavigate to your project and click on SECURITY \u003e API TOKENS \u003e GENERATE API (give read/write access)\n\nPaste API token in the `hcloud_token` variable in `variables.tf`. More secure way to store API token is to create `.auto.tfvars` file in the root of your project and paste API token there, sintax is same as in .env file (hcloud_token = \"API_TOKEN\"). This will overwrite default value. In same way other variabels can be changed from default values without having to change them in the code.\n\n\n### 2. Initialize and Apply Terraform\n\nInitialize Terraform and apply the configuration:\n\n```shell\ncd \u003cyour-project-folder\u003e\nterraform init --upgrade\nterraform validate\nterraform apply -auto-approve\n```\n\n### 3. Open UI or SSH into the server\n\nWhen Terraform finishes, give server a couple of minutes to install all dependencies. Coolify's UI will be available at: \n\n```shell\n# Coolify version 3\nSERVER_IP:3000\n\n# Coolify version 4\nSERVER_IP:8000\n```\nDefault installed Coolify version is 3, because it is easy to navigate for new users and ver. 4 is still in beta.\nYou can chage version in `server-config.sh` \n\nIf needed, you can ssh into the server with the following command:\n\n```shell\nssh root@\u003cserver-ip\u003e -i ~/.ssh/coolify_key.pem\n```\n\n### 4. Destroy infrastructure\n\nTo destroy the infrastructure run the following command:\n\n```shell\nterraform destroy -auto-approve\n```\n\n## Aditional Configuration\n\n### 1. Firewall Rules\n\nTo make the server access more secure, we created firewall rules that only allow traffic on certain ports.\n\nAdd more rules in `firewall.tf` file if you use service with specific port.\n\n```terraform\nrule {\n    destination_ips = []\n    direction       = \"in\"\n    port            = \"5432\"\n    protocol        = \"tcp\"\n    source_ips = [\n      \"0.0.0.0/0\",\n      \"::/0\",\n    ]\n  }\n  rule {\n    destination_ips = [\"0.0.0.0/0\"]\n    direction       = \"out\"\n    port            = \"5432\"\n    protocol        = \"tcp\"\n    source_ips = [\n      \"0.0.0.0/0\",\n      \"::/0\",\n    ]\n  }\n```\n\n### 2. List images, servers types and locations\n\nCheck the list of images, servers and prices on official Hetzner Cloud [website](https://www.hetzner.com/cloud).\nAlso, you can  query [REST API](https://docs.hetzner.cloud/#servers-create-a-server) with the same API_TOKEN we created earlier.\n\nOnly Debian and Ubuntu images are supported.\n\n```shell\nexport TF_HETZNER_TOKE= \u003cAPI_TOKEN\u003e\n\ncurl \\\n -H \"Authorization: Bearer $TF_HETZNER_TOKEN\" \\\n 'https://api.hetzner.cloud/v1/images'\n\ncurl \\\n -H \"Authorization: Bearer $TF_HETZNER_TOKEN\" \\\n 'https://api.hetzner.cloud/v1/server_types'\n\n curl \\\n -H \"Authorization: Bearer $TF_HETZNER_TOKEN\" \\\n 'https://api.hetzner.cloud/v1/locations'\n```\n\nYou can use fetch-data.sh to fetch the data from the API and save it to .json in data folder. Images are filtered  by type and architecture and only x86 servers are listed, ARM is excluded.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fujstor%2Fcoolify-hetzner-terraform","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fujstor%2Fcoolify-hetzner-terraform","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fujstor%2Fcoolify-hetzner-terraform/lists"}