Skip to content
SHC Docs

Example: digitalocean-shc

terraform/examples/digitalocean-shc builds droplets in one region and hands the cluster a digitalocean connection that can serve DNS, a load balancer and block volumes from one token. Cloudflare can take DNS instead.

  • modules/shc/digitalocean takes a size per group and an image. The region scopes the VPC and the reserved IPs, so there is one region.
  • shc_connection "digitalocean" carries the same token the provider uses, passed again as TF_VAR_do_token, plus the region. Its zones is empty when Cloudflare does DNS.
  • shc_config.platform adds storage.volumes.provider: digitalocean, so the cluster’s volumes are DigitalOcean block storage.
  • The README applies in two steps: -target=module.shc first for the substrate and bootstrap, then everything.
resource "shc_connection" "digitalocean" {
name = "digitalocean"
type = "digitalocean"
credentials = {
token = var.do_token
region = module.shc.region
}
zones = local.dns_is_do ? [var.dns_zone] : []
depends_on = [module.shc]
}

DIGITALOCEAN_TOKEN, TF_VAR_do_token and TF_VAR_dns_token come from the environment.

Terminal window
tofu -chdir=learn/shc/terraform/examples/digitalocean-shc init
tofu -chdir=learn/shc/terraform/examples/digitalocean-shc apply -var dns_zone=example.com -target=module.shc
tofu -chdir=learn/shc/terraform/examples/digitalocean-shc apply -var dns_zone=example.com
tofu -chdir=learn/shc/terraform/examples/digitalocean-shc destroy -var dns_zone=example.com

This page was not walked: no DigitalOcean credential is on the learning workstation. Track F’s DigitalOcean page covers the same account through the CLI.

Next: Example: linode-shc.