Skip to content
SHC Docs

Example: gcp-shc

terraform/examples/gcp-shc builds a Google Cloud cluster and pins the module library to a published version with module_version. The platform is wired the same way as the Azure root: a DNS connection, one config document, the catalogue, Postgres and Gitea.

  • modules/shc/gcp takes a zone, a machine_type per group and a root_volume with a GCE disk type. networking.ip_range is accepted and ignored: a custom-mode network has no range of its own, only the subnet.
  • source is .../shc-gcp-${var.module_version}.tgz, so a variable chooses the module release. The ladder’s source was a path in the checkout.
  • Google’s own startup script preps the nodes; the provider’s SSH engine waits for it before installing shc by apt.
module "shc" {
source = "https://selfhostedcloud.org/terraform/0.1/modules/${var.module_version}/shc-gcp-${var.module_version}.tgz"
cluster_name = var.cluster_name
zone = var.zone
ssh_public_key = tls_private_key.cluster.public_key_openssh
node_groups = {
control = { count = var.node_count, machine_type = var.machine_type, runtime = "docker", control_plane = true }
}
root_volume = { size = 100, type = "pd-balanced" }
}

GOOGLE_APPLICATION_CREDENTIALS points at an administrator’s key file; TF_VAR_project, TF_VAR_dns_zone, TF_VAR_dns_token and TF_VAR_acme_email come from the environment. The example ships registry.tfrc; select it with TF_CLI_CONFIG_FILE or keep the ~/.tofurc from page 00.

Terminal window
tofu -chdir=learn/shc/terraform/examples/gcp-shc init
tofu -chdir=learn/shc/terraform/examples/gcp-shc apply
tofu -chdir=learn/shc/terraform/examples/gcp-shc destroy

This page was not walked: labs run on the learning project at Hetzner only. Track F’s GCP page covers the same account through the CLI.

Next: Example: digitalocean-shc.