Hanzo
Hanzo Skills Reference

Hanzo Terraform Provider

The Hanzo Terraform Provider is a Stainless-generated Terraform SDK for managing Hanzo AI resources via Infrastructure as Code. Built on the HashiCorp Terraform Plugin Framework, it wraps the Hanzo...

Overview

The Hanzo Terraform Provider is a Stainless-generated Terraform SDK for managing Hanzo AI resources via Infrastructure as Code. Built on the HashiCorp Terraform Plugin Framework, it wraps the Hanzo Go SDK (github.com/hanzoai/go-sdk) to provide declarative resource management through Terraform. Currently in early alpha with provider scaffolding and authentication -- resources and data sources are being generated from the Hanzo OpenAPI spec.

Why Hanzo Terraform Provider?

  • Stainless-generated: Auto-generated from the Hanzo OpenAPI spec -- stays in sync with the API
  • Terraform Plugin Framework: Modern provider architecture (not legacy SDKv2)
  • Dual environment: Supports production and sandbox environments
  • Release automation: GoReleaser + release-please for versioned binary distribution
  • Terraform Registry: Published at registry.terraform.io/hanzoai/terraform-provider-hanzo

Tech Stack

  • Language: Go 1.24
  • Framework: HashiCorp Terraform Plugin Framework v1.15.0
  • SDK: github.com/hanzoai/go-sdk v0.1.0-alpha.4
  • Code generation: Stainless (from OpenAPI spec)
  • Release: GoReleaser + release-please + GPG signing
  • Version: v0.1.0-alpha.2

Current State

The provider is in early alpha. The provider.go registers authentication (API key via config or HANZO_API_KEY env var), base URL configuration, and environment selection. The Resources() and DataSources() methods currently return empty slices -- resource implementations will be generated as the Hanzo OpenAPI spec stabilizes.

When to use

  • Managing Hanzo AI infrastructure via Terraform
  • Integrating Hanzo resources into existing Terraform-managed infrastructure
  • Automating Hanzo service provisioning in CI/CD pipelines

Hard requirements

  1. Terraform CLI 1.0+
  2. Hanzo API key (via api_key config or HANZO_API_KEY env var)

Quick reference

ItemValue
Provider sourcehanzoai/terraform-provider-hanzo
Versionv0.1.0-alpha.2
LanguageGo 1.24
Go SDKgithub.com/hanzoai/go-sdk v0.1.0-alpha.4
Registryregistry.terraform.io/hanzoai/terraform-provider-hanzo
Repogithub.com/hanzoai/terraform-provider-hanzo
Branchmain
LicenseApache 2.0
Generated byStainless

Usage

terraform {
  required_providers {
    terraform-provider-hanzo = {
      source  = "hanzoai/terraform-provider-hanzo"
      version = "~> 0.1.0-alpha.2"
    }
  }
}

provider "terraform-provider-hanzo" {
  api_key = "hk-..."  # or set HANZO_API_KEY env var
}

Provider Configuration

PropertyEnvironment VariableRequiredDefault
api_keyHANZO_API_KEYYes--
base_urlHANZO_BASE_URLNoProduction URL
environment--No"production"

The environment attribute accepts "production" or "sandbox". Cannot be set simultaneously with base_url.

Repository Structure

main.go                          # Provider entry point (providerserver.Serve)
internal/
  provider.go                    # Provider config, auth, client initialization
  version.go                     # Version constant
  apiform/                       # API form encoding utilities
  apijson/                       # API JSON marshaling
  customfield/                   # Custom Terraform field types
  customvalidator/               # Custom validators
  importpath/                    # Import path utilities
  logging/                       # Structured logging
  test_helpers/                  # Test helpers
  types/                         # Terraform type definitions
bin/                             # Build scripts
docs/
  index.md                       # Terraform Registry docs
examples/                        # Usage examples
scripts/                         # CI/release scripts
tools/                           # Development tools
.goreleaser.yml                  # GoReleaser config (multi-platform builds)
.release-please-manifest.json    # Release automation
release-please-config.json       # Release-please configuration
terraform-registry-manifest.json # Registry metadata
CHANGELOG.md                     # Versioned changelog

Build and Development

# Build the provider
go build -o terraform-provider-hanzo

# Run tests
go test ./...

# Format code
go fmt ./...

# Lint
golangci-lint run

# Generate docs
go generate ./...

# Run with debug mode
go run main.go -debug

Release Process

Releases use GoReleaser with GPG signing:

# Tag and push
git tag v0.1.0-alpha.3
git push origin v0.1.0-alpha.3
# GitHub Actions runs GoReleaser -> multi-platform binaries -> Terraform Registry

Platforms: linux/amd64, linux/arm64, darwin/amd64, darwin/arm64, windows/amd64, freebsd/amd64

Environment Variables

HANZO_API_KEY=hk-...              # API authentication (required)
HANZO_BASE_URL=https://...        # Override API base URL

Troubleshooting

IssueCauseSolution
Missing api_keyNot configuredSet HANZO_API_KEY env var or provider config
Ambiguous URL errorBoth base_url and environment setUse only one
Provider not foundNot in registry yetInstall from source: go install
No resources availableAlpha stateResources are being generated from OpenAPI
  • hanzo/go-sdk.md - Go SDK (underlying client library)
  • hanzo/hanzo-operator.md - K8s operator (alternative for K8s-native infra)
  • hanzo/hanzo-charts.md - Helm charts (alternative for K8s deployments)

How is this guide?

Last updated on

On this page