No description
Find a file
pypeaday 4994c23b40
All checks were successful
Mirror to Github / mirror (push) Successful in 5s
remove
2025-12-13 06:07:07 -06:00
.forgejo/workflows add mirror to link to github 2025-12-13 06:04:00 -06:00
terraform remove 2025-12-13 06:07:07 -06:00
.gitignore batman 2025-12-12 21:05:28 -06:00
docker-compose.yml batman 2025-12-12 21:05:28 -06:00
README.md update readme 2025-12-13 06:02:37 -06:00

Example Terraform Cloudflare Tunnel

This repo contains a quick path to setting up a cloudflare tunnel and cloudflared using terraform/open-tofu and docker-compose respectively.

NOTE: docker is totally not required for cloudflared - you can just run the binary

Cloudflare Tunnel

Setup a Cloudflare tunnel with terraform/open-tofu. The example uses a local state file, which isn't ideal for actual use. I use remote state with my self-hosted minio to store terraform state.

terraform {
  required_version = ">= 1.0"

  # uncomment and fill out if you want to use remote s3 backend for state storage
  # backend "s3" {
  #   endpoint = "https://s3.example.com"
  #   bucket   = "infrastructure-state"
  #   key      = "my-cloudflare-tunnel/terraform.tfstate"
  #   region   = "us-east-1"
  #   # copy paste from my homelab setup,
  #   # access_key                  = "ACCESSKEY"
  #   # secret_key                  = "SECRETKEY"
  #   skip_credentials_validation = true
  #   skip_metadata_api_check     = true
  #   use_path_style              = true
  # }

  required_providers {
    cloudflare = {
      source  = "cloudflare/cloudflare"
      version = "~> 4.0"
    }
  }
}

Cloudflared

TUNNEL_TOKEN=$(tofu output -raw tunnel_token) docker compose up -d